2014-05-08 19:46:08 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-06-25 00:56:50 +02:00
|
|
|
# Exit on command errors and treat unset variables as an error
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
# 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-04 16:18:43 +02:00
|
|
|
path_url=$(ynh_app_setting_get "$app" path)
|
2017-06-25 00:56:50 +02:00
|
|
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
2017-07-04 16:18:43 +02:00
|
|
|
root_access=$(ynh_app_setting_get "$app" root_access)
|
2014-05-08 19:46:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Remove trailing "/" for next commands
|
2017-06-25 00:56:50 +02:00
|
|
|
path_url=${path_url%/}
|
2014-05-08 19:46:08 +02:00
|
|
|
|
|
|
|
|
2017-06-25 00:56:50 +02:00
|
|
|
# Copy source files
|
|
|
|
src_path=/var/www/$app
|
|
|
|
sudo rm -rf $src_path
|
2017-07-04 16:18:43 +02:00
|
|
|
sudo mkdir -p $src_path
|
|
|
|
if [[ $root_access -eq 1 ]]; then
|
|
|
|
#copy files from with_root_access folder to the src_path
|
|
|
|
sudo cp -a ../sources/with_root_access/. $src_path
|
|
|
|
else
|
|
|
|
#copy files from root_access_disabled folder to the src_path
|
|
|
|
sudo cp -a ../sources/root_access_disabled/. $src_path
|
|
|
|
fi
|
2014-05-08 19:46:08 +02:00
|
|
|
|
|
|
|
# Files owned by root, www-data can just read
|
2017-06-25 00:56:50 +02:00
|
|
|
sudo find $src_path -type f | xargs sudo chmod 644
|
|
|
|
sudo find $src_path -type d | xargs sudo chmod 755
|
|
|
|
sudo chown -R root: $src_path
|
2014-05-08 19:46:08 +02:00
|
|
|
|
2014-07-22 16:08:09 +02:00
|
|
|
|
2014-05-08 19:46:08 +02:00
|
|
|
# Modify Nginx configuration file and copy it to Nginx conf directory
|
2017-06-25 00:56:50 +02:00
|
|
|
nginx_conf=../conf/nginx.conf
|
|
|
|
sed -i "s@YNH_WWW_PATH@$path_url@g" $nginx_conf
|
|
|
|
sed -i "s@YNH_WWW_ALIAS@$src_path/@g" $nginx_conf
|
|
|
|
sudo cp $nginx_conf /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
sudo chown root: /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
sudo chmod 600 /etc/nginx/conf.d/$domain.d/$app.conf
|
|
|
|
|
|
|
|
# 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
|
2014-05-08 19:46:08 +02:00
|
|
|
sudo service nginx reload
|
|
|
|
sudo yunohost app ssowatconf
|