postinst 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. # Installation de certbot (client ACME de Let's Encrypt pour les certificats)
  3. snap install --classic certbot
  4. # Configuration Apache2
  5. [ -z "$(grep \/var\/www\/www /etc/apache2/apache2.conf)" ] && ed -s /etc/apache2/apache2.conf <<EOF
  6. /\#<Directory
  7. -i
  8. <Directory /var/www/www/>
  9. Options Indexes FollowSymLinks
  10. AllowOverride None
  11. Require all granted
  12. </Directory>
  13. .
  14. w
  15. EOF
  16. a2enmod headers
  17. a2enmod rewrite
  18. a2enmod ssl
  19. a2ensite api.conf
  20. a2ensite www.conf
  21. a2ensite cro.conf
  22. # Configuration PHP
  23. for i in /etc/php/*/apache2/php.ini;
  24. do
  25. if [ -f ${i} ];
  26. then
  27. ed -s ${i} <<EOF
  28. /upload_max_filesize
  29. s/2M/30M
  30. .
  31. w
  32. EOF
  33. fi
  34. done
  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