2016-10-05 19:44:08 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
|
set -eu
|
|
|
|
|
|
2017-02-22 16:51:47 +01:00
|
|
|
|
source .functions
|
|
|
|
|
|
2016-10-05 19:44:08 +02:00
|
|
|
|
# See comments in install script
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
|
|
# Source YunoHost helpers
|
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
|
|
# Retrieve app settings
|
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
|
|
|
|
path=$(ynh_app_setting_get "$app" path)
|
|
|
|
|
admin=$(ynh_app_setting_get "$app" admin)
|
|
|
|
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
|
|
|
|
|
2017-02-22 16:51:47 +01:00
|
|
|
|
# Check path and correct if required
|
|
|
|
|
CHECK_PATH
|
2016-10-05 19:44:08 +02:00
|
|
|
|
|
|
|
|
|
# Copy source files
|
2017-02-27 19:06:31 +01:00
|
|
|
|
#src_path=/var/www/$app
|
|
|
|
|
#sudo mkdir -p $src_path
|
|
|
|
|
#sudo cp -a ../sources/. $src_path
|
|
|
|
|
|
|
|
|
|
# Update flarum
|
|
|
|
|
sudo su - www-data -s /bin/bash -c "cd /var/www/${app} && composer update"
|
2016-10-05 19:44:08 +02:00
|
|
|
|
|
|
|
|
|
# Set permissions to app files
|
|
|
|
|
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
2017-02-22 15:33:05 +01:00
|
|
|
|
sudo chown -R www-data:www-data $src_path
|
|
|
|
|
sudo chmod -R 755 $src_path
|
2016-10-05 19:44:08 +02:00
|
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
2017-02-22 16:51:47 +01:00
|
|
|
|
### Nginx ###
|
2017-02-22 19:06:03 +01:00
|
|
|
|
nginxconf="../conf/nginx.conf"
|
|
|
|
|
if [ $path = "/" ]; then
|
|
|
|
|
sed -i "s@YNH_WWW_ROOTPATH@@g" ../conf/nginx.conf
|
2017-02-27 19:06:31 +01:00
|
|
|
|
sed -i "s@YNH_WWW_ROOTAPP@/@g" ../conf/nginx.conf
|
2017-02-22 16:51:47 +01:00
|
|
|
|
else
|
2017-02-22 19:06:03 +01:00
|
|
|
|
sed -i "s@YNH_WWW_ROOTPATH@$path@g" ../conf/nginx.conf
|
2017-02-27 19:06:31 +01:00
|
|
|
|
sed -i "s@YNH_WWW_ROOTAPP@$path$path@g" ../conf/nginx.conf
|
2017-02-22 16:51:47 +01:00
|
|
|
|
fi
|
2017-02-22 19:06:03 +01:00
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" $nginxconf
|
|
|
|
|
sed -i "s@YNH_WWW_FINALPATH@$final_path@g" $nginxconf
|
2017-02-22 19:15:33 +01:00
|
|
|
|
sed -i "s@YNH_WWW_APP@$final_path@g" $nginxconf
|
2017-02-22 19:06:03 +01:00
|
|
|
|
sudo cp $nginxconf /etc/nginx/conf.d/$domain.d/$app.conf
|
2017-02-22 16:51:47 +01:00
|
|
|
|
|
2016-10-05 19:44:08 +02:00
|
|
|
|
# If a dedicated php-fpm process is used:
|
|
|
|
|
#
|
|
|
|
|
sed -i "s@YNH_WWW_APP@$app@g" $nginx_conf
|
|
|
|
|
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
2017-02-22 15:33:05 +01:00
|
|
|
|
sudo chmod 644 /etc/nginx/conf.d/$domain.d/$app.conf
|
2016-10-05 19:44:08 +02:00
|
|
|
|
|
|
|
|
|
### PHP ###
|
|
|
|
|
# If a dedicated php-fpm process is used:
|
|
|
|
|
# # Modify PHP-FPM pool configuration and copy it to the pool directory
|
|
|
|
|
sed -i "s@YNH_WWW_APP@$app@g" ../conf/php-fpm.conf
|
|
|
|
|
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" ../conf/php-fpm.conf
|
|
|
|
|
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
|
|
|
|
sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
|
|
|
sudo chown root: $finalphpconf
|
|
|
|
|
sudo chmod 644 $finalphpconf
|
2017-02-22 15:29:34 +01:00
|
|
|
|
sudo service php5-fpm reload
|
2016-10-05 19:44:08 +02:00
|
|
|
|
### PHP end ###
|
|
|
|
|
|
|
|
|
|
# If app is public, add url to SSOWat conf as skipped_uris
|
|
|
|
|
if [[ $is_public -eq 1 ]]; then
|
|
|
|
|
# See install script
|
|
|
|
|
ynh_app_setting_set "$app" unprotected_uris "/"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Reload nginx service
|
|
|
|
|
sudo service nginx reload
|