123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #!/bin/bash
- # PirateBox app for YunoHost
- # Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
- # Contribute at https://github.com/jvaubourg/piratebox_ynh
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Affero General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU Affero General Public License for more details.
- #
- # You should have received a copy of the GNU Affero General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- # Retrieve arguments
- domain=${1}
- url_path=${2}
- # Check domain/path availability
- sudo yunohost app checkurl ${domain}${url_path} -a piratebox
- if [ ! $? -eq 0 ]; then
- exit 1
- fi
- # Install packages
- packages='php5-fpm iptables libnet-dns-perl'
- export DEBIAN_FRONTEND=noninteractive
- sudo apt-get --assume-yes --force-yes install ${packages}
- if [ $? -ne 0 ]; then
- sudo apt-get update
- sudo apt-get --assume-yes --force-yes install ${packages}
- fi
- # Create web user
- sudo useradd -r dropcenter
- # Copy confs
- sudo install -b -o root -g root -m 0644 ../conf/nginx_piratebox.conf "/etc/nginx/conf.d/piratebox.conf"
- sudo install -b -o root -g root -m 0644 ../conf/nginx_dropcenter.conf "/etc/nginx/conf.d/${domain}.d/dropcenter.conf"
- sudo install -b -o root -g root -m 0644 ../conf/phpfpm_dropcenter.conf /etc/php5/fpm/pool.d/dropcenter.conf
- # Copy web sources
- sudo mkdir -pm 0755 /var/www/dropcenter/
- sudo cp -a ../sources/* /var/www/dropcenter/
- sudo mkdir /var/www/dropcenter/tpl/tmp/
- sudo chown -R root: /var/www/dropcenter/
- sudo chmod -R 0644 /var/www/dropcenter/*
- sudo find /var/www/dropcenter/ -type d -exec chmod +x {} \;
- # Fix permissions
- sudo chown -R dropcenter: /var/www/dropcenter/tpl/tmp/
- sudo chown -R dropcenter: /var/www/dropcenter/uploads/
- # Create fixed DC user
- sudo tee /var/www/dropcenter/uploads/.dc/.user.dc.php > /dev/null << EOF
- <?php /*{"login":"pirate","avatar":"","password":"","rank":"admin","mail":"","notifMail":"off","lang":"en - English"}*/ ?>
- EOF
- sudo touch /var/www/dropcenter/uploads/avatars/pirate.jpg
- # Fix confs
- ## nginx
- sudo sed "s|<TPL:URL_PATH>|${url_path}|g" -i "/etc/nginx/conf.d/piratebox.conf"
- sudo sed "s|<TPL:DOMAIN>|${domain}|g" -i "/etc/nginx/conf.d/piratebox.conf"
- sudo sed "s|<TPL:NGINX_LOCATION>|${url_path}|g" -i "/etc/nginx/conf.d/${domain}.d/dropcenter.conf"
- sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/dropcenter/|g' -i "/etc/nginx/conf.d/${domain}.d/dropcenter.conf"
- sudo sed 's|<TPL:PHP_NAME>|dropcenter|g' -i "/etc/nginx/conf.d/${domain}.d/dropcenter.conf"
- ## php-fpm
- sudo sed 's|<TPL:PHP_NAME>|dropcenter|g' -i /etc/php5/fpm/pool.d/dropcenter.conf
- sudo sed 's|<TPL:PHP_USER>|dropcenter|g' -i /etc/php5/fpm/pool.d/dropcenter.conf
- sudo sed 's|<TPL:PHP_GROUP>|dropcenter|g' -i /etc/php5/fpm/pool.d/dropcenter.conf
- sudo sed 's|<TPL:NGINX_REALPATH>|/var/www/dropcenter/|g' -i /etc/php5/fpm/pool.d/dropcenter.conf
- sudo sed 's|^;\?\s*max_execution_time.\+|max_execution_time = 600|' -i /etc/php5/fpm/php.ini
- # Install fakedns
- sudo install -o root -g root -m 0755 ../conf/piratebox_fakedns /usr/local/bin/
- # Copy init script
- sudo install -o root -g root -m 0755 ../conf/init_ynh-piratebox /etc/init.d/ynh-piratebox
- # Update firewall
- sudo yunohost firewall allow --no-upnp UDP 4253
- sudo yunohost firewall allow --no-upnp TCP 4280
- # Set default inits
- sudo yunohost service add php5-fpm
- sudo yunohost service enable php5-fpm
- sudo service php5-fpm restart
- sudo service nginx reload
- sudo yunohost service add ynh-piratebox
- sudo yunohost service enable ynh-piratebox
- sudo service ynh-piratebox start
- # Update SSO
- sudo yunohost app setting piratebox skipped_uris -v /
- sudo yunohost app ssowatconf
- exit 0
|