2017-07-02 12:41:05 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
|
set -eu
|
|
|
|
|
|
2017-07-05 12:28:42 +02:00
|
|
|
|
source .fonctions
|
|
|
|
|
|
2017-07-02 12:41:05 +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)
|
2017-07-05 12:28:42 +02:00
|
|
|
|
path=$(ynh_app_setting_get "$app" path)
|
2017-07-02 12:41:05 +02:00
|
|
|
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
|
|
|
|
|
|
|
|
|
|
2017-07-05 12:28:42 +02:00
|
|
|
|
# Check final_path directory
|
|
|
|
|
final_path=/var/www/$app
|
|
|
|
|
[[ ! -d $final_path ]] && ynh_die \
|
|
|
|
|
"The destination directory '$final_path' does not exist.\
|
2017-07-03 21:21:48 +02:00
|
|
|
|
The app is not correctly installed, you should remove it first."
|
|
|
|
|
|
|
|
|
|
# Move old app dir
|
2017-07-05 12:28:42 +02:00
|
|
|
|
sudo mv ${final_path} ${final_path}.old
|
2017-07-03 21:21:48 +02:00
|
|
|
|
|
|
|
|
|
# Copy source files
|
2017-07-05 12:28:42 +02:00
|
|
|
|
sudo mkdir -p $final_path
|
|
|
|
|
# Get source
|
|
|
|
|
SETUP_SOURCE
|
2017-07-02 12:41:05 +02:00
|
|
|
|
|
2017-07-03 21:21:48 +02:00
|
|
|
|
# restore data
|
2017-07-05 12:28:42 +02:00
|
|
|
|
sudo cp -a ${final_path}.old/data ${final_path}
|
2017-07-02 12:41:05 +02:00
|
|
|
|
|
2017-07-03 21:21:48 +02:00
|
|
|
|
# delete temp directory
|
2017-07-05 12:28:42 +02:00
|
|
|
|
sudo rm -Rf ${final_path}.old
|
2017-07-02 12:41:05 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set permissions to app files
|
|
|
|
|
# you may need to make some file and/or directory writeable by www-data (nginx user)
|
2017-07-05 12:28:42 +02:00
|
|
|
|
sudo chown -R root: $final_path
|
2017-07-02 12:41:05 +02:00
|
|
|
|
|
|
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
|
|
|
nginx_conf=../conf/nginx.conf
|
2017-07-05 12:28:42 +02:00
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path@g" $nginx_conf
|
|
|
|
|
sed -i "s@YNH_WWW_ALIAS@$final_path/@g" $nginx_conf
|
2017-07-02 12:41:05 +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
|
|
|
|
|
|
|
|
|
|
### PHP (remove if not used) ###
|
|
|
|
|
# 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
|
2017-07-05 12:28:42 +02:00
|
|
|
|
# sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/php-fpm.conf
|
2017-07-02 12:41:05 +02:00
|
|
|
|
# finalphpconf=/etc/php5/fpm/pool.d/$app.conf
|
|
|
|
|
# sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
|
|
|
# sudo chown root: $finalphpconf
|
|
|
|
|
# sudo chmod 644 $finalphpconf
|
|
|
|
|
# sudo service php5-fpm restart
|
|
|
|
|
### 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
|
|
|
|
|
|
2017-07-05 12:28:42 +02:00
|
|
|
|
sudo chmod -R 777 $final_path/data
|
2017-07-02 12:41:05 +02:00
|
|
|
|
# Reload nginx service
|
|
|
|
|
sudo service nginx reload
|