diff --git a/scripts/upgrade b/scripts/upgrade index 266aad5..6f64f86 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -3,5 +3,43 @@ # Exit on command errors and treat unset variables as an error set -eu +# See comments in install script +app=phpsysinfo + # Source YunoHost helpers -. /usr/share/yunohost/helpers \ No newline at end of file +. /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) + +# Remove trailing "/" for next commands +path=${path%/} + +# Copy source files +final_path=/var/www/$app +sudo mkdir -p $final_path +sudo cp -a ../sources/. $final_path + +# Set permissions to app files +# you may need to make some file and/or directory writeable by www-data (nginx user) +sudo chown -R root:root $final_path + +# Modify Nginx configuration file and copy it to Nginx conf directory +sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf +sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /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 "/" + # Remove old settings + ynh_app_setting_delete "$app" skipped_uris +fi + +# Restart services +sudo service nginx reload \ No newline at end of file