install 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. # PirateBox app for YunoHost
  3. # Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
  4. # Contribute at https://github.com/jvaubourg/piratebox_ynh
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. # Retrieve arguments
  19. domain=${1}
  20. url_path=/piratebox
  21. # Check domain/path availability
  22. sudo yunohost app checkurl ${domain}${url_path} -a piratebox
  23. if [ ! $? -eq 0 ]; then
  24. exit 1
  25. fi
  26. # Install packages
  27. packages='php5-fpm iptables libnet-dns-perl'
  28. export DEBIAN_FRONTEND=noninteractive
  29. sudo apt-get --assume-yes --force-yes install ${packages}
  30. if [ $? -ne 0 ]; then
  31. sudo apt-get update
  32. sudo apt-get --assume-yes --force-yes install ${packages}
  33. fi
  34. # Copy confs
  35. sudo mkdir -pm 0755 /var/log/nginx/
  36. sudo mkdir -pm 0755 /var/spool/piratebox/
  37. sudo chown www-data: /var/spool/piratebox/
  38. sudo install -b -o root -g root -m 0644 ../conf/nginx_captive-piratebox.conf /etc/nginx/conf.d/captive-piratebox.conf
  39. sudo install -b -o root -g root -m 0644 ../conf/nginx_piratebox.conf "/etc/nginx/conf.d/${domain}.d/piratebox.conf"
  40. sudo install -b -o root -g root -m 0644 ../conf/phpfpm_piratebox.conf /etc/php5/fpm/pool.d/piratebox.conf
  41. # Copy web sources
  42. sudo mkdir -pm 0755 /var/www/piratebox/
  43. sudo cp -a ../sources/* /var/www/piratebox/
  44. sudo mkdir /var/www/piratebox/tpl/tmp/
  45. sudo chown -R root: /var/www/piratebox/
  46. sudo chmod -R 0644 /var/www/piratebox/*
  47. sudo find /var/www/piratebox/ -type d -exec chmod +x {} \;
  48. # Fix permissions
  49. sudo chown -R www-data: /var/www/piratebox/tpl/tmp/
  50. sudo chown -R www-data: /var/www/piratebox/uploads/
  51. # Create fixed DC user
  52. sudo tee /var/www/piratebox/uploads/.dc/.user.dc.php > /dev/null << EOF
  53. <?php /*{"login":"pirate","avatar":"","password":"","rank":"admin","mail":"","notifMail":"off","lang":"en - English"}*/ ?>
  54. EOF
  55. sudo touch /var/www/piratebox/uploads/avatars/pirate.jpg
  56. # Fix confs
  57. ## nginx
  58. sudo sed "s|<TPL:DOMAIN>|${domain}|g" -i /etc/nginx/conf.d/captive-piratebox.conf
  59. sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/piratebox/|g' -i /etc/nginx/conf.d/captive-piratebox.conf
  60. sudo sed 's|<TPL:PHP_NAME>|piratebox|g' -i /etc/nginx/conf.d/captive-piratebox.conf
  61. ## php-fpm
  62. sudo sed 's|<TPL:PHP_NAME>|piratebox|g' -i /etc/php5/fpm/pool.d/piratebox.conf
  63. sudo sed 's|<TPL:PHP_USER>|www-data|g' -i /etc/php5/fpm/pool.d/piratebox.conf
  64. sudo sed 's|<TPL:PHP_GROUP>|www-data|g' -i /etc/php5/fpm/pool.d/piratebox.conf
  65. sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/piratebox/|g' -i /etc/php5/fpm/pool.d/piratebox.conf
  66. # Install fakedns
  67. sudo install -o root -g root -m 0755 ../conf/piratebox_fakedns /usr/local/bin/
  68. # Copy init script
  69. sudo install -o root -g root -m 0755 ../conf/init_ynh-piratebox /etc/init.d/ynh-piratebox
  70. # Update firewall
  71. sudo yunohost firewall allow --no-upnp UDP 4253
  72. sudo yunohost firewall allow --no-upnp TCP 4280
  73. # Set default inits
  74. sudo yunohost service add php5-fpm
  75. sudo yunohost service enable php5-fpm
  76. sudo service php5-fpm restart
  77. sudo service nginx reload
  78. sudo yunohost service add ynh-piratebox
  79. sudo yunohost service enable ynh-piratebox
  80. sudo service ynh-piratebox start
  81. # Update SSO
  82. sudo yunohost app setting piratebox skipped_uris -v /
  83. sudo yunohost app ssowatconf
  84. exit 0