postinst 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. if [ -f /etc/php/7.4/apache2/php.ini ];
  27. then
  28. ed -s /etc/php/7.4/apache2/php.ini <<EOF
  29. /upload_max_filesize
  30. s/2M/30M
  31. .
  32. w
  33. EOF
  34. fi
  35. # Redemarrage du serveur Apache2
  36. systemctl restart apache2
  37. # Configuration de la base de donnees
  38. mysql_secure_installation
  39. mysql -u root <<EOF
  40. CREATE USER IF NOT EXISTS 'newuser'@'localhost';
  41. SET PASSWORD FOR 'newuser'@'localhost' = PASSWORD( 'password' );
  42. GRANT ALL PRIVILEGES ON *.* TO 'newuser'@'localhost';
  43. FLUSH PRIVILEGES;
  44. exit
  45. EOF
  46. # Ajoute les tables de Math-Cloud
  47. if [ -f /tmp/iimt_mathcloud.sql ] &&
  48. [ -f /tmp/iimt_mathcloud_audit.sql ] &&
  49. [ -f /tmp/iimt_mathcloud_shadow.sql ];
  50. then
  51. mysql -u root <<EOF
  52. SOURCE /tmp/iimt_mathcloud.sql
  53. SOURCE /tmp/iimt_mathcloud_audit.sql
  54. SOURCE /tmp/iimt_mathcloud_shadow.sql
  55. exit
  56. EOF
  57. fi
  58. # Redemarrage de la base de donnees
  59. systemctl restart mysql
  60. # Copie des cles SSH
  61. cp /tmp/sshFabrice.zip /home/${SUDO_USER}/.ssh/
  62. chown ${SUDO_USER}:${SUDO_USER} /home/${SUDO_USER}/.ssh/sshFabrice.zip
  63. # Configuration du compte utilisateur
  64. if [ ! -d /home/${SUDO_USER}/Git ];
  65. then
  66. mkdir /home/${SUDO_USER}/Git
  67. chown -R ${SUDO_USER}:${SUDO_USER} /home/${SUDO_USER}/Git
  68. fi
  69. if [ ! -f /home/${SUDO_USER}/Git/gitClone.sh ];
  70. then
  71. cat > /home/${SUDO_USER}/Git/gitClone.sh <<EOF
  72. #! /bin/bash
  73. git clone ssh://iimt@gogs.iimt.fr:iimt/MAth-Cloud-3.0.0.git
  74. EOF
  75. chmod +x /home/${SUDO_USER}/Git/gitClone.sh
  76. chown ${SUDO_USER}:${SUDO_USER} /home/${SUDO_USER}/Git/gitClone.sh
  77. fi