postinst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #! /bin/bash
  2. # Configuration Apache2
  3. if [ -f /tmp/api.conf.in ];
  4. then
  5. sed "s/USER_LOGIN/${SUDO_USER}/g" /tmp/api.conf.in > /etc/apache2/sites-available/api.conf
  6. fi
  7. if [ -f /etc/apache2/ports.conf ];
  8. then
  9. [ -z "$(grep 10302 /etc/apache2/ports.conf)" ] && ed -s /etc/apache2/ports.conf <<EOF
  10. /Listen\ 443
  11. +i
  12. Listen 10302
  13. .
  14. /Listen\ 443
  15. +i
  16. Listen 10302
  17. .
  18. w
  19. EOF
  20. fi
  21. a2enmod headers
  22. a2enmod rewrite
  23. a2enmod ssl
  24. a2ensite api.conf
  25. # Configuration PHP
  26. for i in /etc/php/*/apache2/php.ini;
  27. do
  28. if [ -f ${i} ];
  29. then
  30. ed -s ${i} <<EOF
  31. /upload_max_filesize
  32. s/2M/30M
  33. .
  34. w
  35. EOF
  36. fi
  37. done
  38. # Redemarrage du serveur Apache2
  39. systemctl restart apache2
  40. # Configuration de la base de donnees
  41. mysql_secure_installation
  42. mysql -u root <<EOF
  43. CREATE USER IF NOT EXISTS 'newuser'@'localhost';
  44. SET PASSWORD FOR 'newuser'@'localhost' = PASSWORD( 'password' );
  45. GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
  46. FLUSH PRIVILEGES;
  47. exit
  48. EOF
  49. # Ajoute les tables de Math-Cloud
  50. if [ -f /tmp/iimt_mathcloud.sql ] &&
  51. [ -f /tmp/iimt_mathcloud_audit.sql ] &&
  52. [ -f /tmp/iimt_mathcloud_shadow.sql ];
  53. then
  54. mysql -u root <<EOF
  55. SOURCE /tmp/iimt_mathcloud.sql
  56. SOURCE /tmp/iimt_mathcloud_audit.sql
  57. SOURCE /tmp/iimt_mathcloud_shadow.sql
  58. exit
  59. EOF
  60. fi
  61. # Redemarrage de la base de donnees
  62. systemctl restart mysql
  63. # Installation de nvm
  64. cd /home/${SUDO_USER}
  65. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh |bash
  66. chown -R ${SUDO_USER}:${SUDO_USER} .nvm
  67. # Copie des cles SSH
  68. cp /tmp/sshFabrice.zip /home/${SUDO_USER}/.ssh/
  69. chown ${SUDO_USER}:${SUDO_USER} /home/${SUDO_USER}/.ssh/sshFabrice.zip
  70. # Configuration du compte utilisateur
  71. if [ ! -d /home/${SUDO_USER}/Git ];
  72. then
  73. mkdir /home/${SUDO_USER}/Git
  74. chown -R ${SUDO_USER}:${SUDO_USER} /home/${SUDO_USER}/Git
  75. fi
  76. if [ ! -f /home/${SUDO_USER}/Git/gitClone.sh ];
  77. then
  78. cat > /home/${SUDO_USER}/Git/gitClone.sh <<EOF
  79. #! /bin/bash
  80. git clone ssh://iimt@gogs.iimt.fr:iimt/MAth-Cloud-3.0.0.git
  81. EOF
  82. chmod +x /home/${SUDO_USER}/Git/gitClone.sh
  83. chown ${SUDO_USER}:${SUDO_USER} /home/${SUDO_USER}/Git/gitClone.sh
  84. fi