#!/bin/bash set -eu source _common.sh source /usr/share/yunohost/helpers # manage script failure ynh_abort_if_errors # retrieve arguments app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get "$app" domain) path_url=$(ynh_app_setting_get "$app" path) is_public=$(ynh_app_setting_get "$app" is_public) admin_user=$(ynh_app_setting_get "$app" admin_user) backup_core_only=$(ynh_app_setting_get "$app" backup_core_only) # definie useful vars final_path="/var/www/$app" data_path="/home/yunohost.app/$app" # use prior backup and restore on error only if backup feature exists on installed instance if [ -f "/etc/yunohost/apps/$app/scripts/backup" ] ; then ynh_backup_before_upgrade # Backup the current version of the app ynh_clean_setup () { ynh_restore_upgradebackup } fi # add required packages ynh_install_app_dependencies "$PKG_DEPENDENCIES" # create a dedicated system user ynh_system_user_create "$app" # download & unpack bozon TMPDIR=$(mktemp -d) ynh_setup_source "$TMPDIR" # clean & copy files needed to final folder myynh_clean_source [ -e "$TMPDIR/config.php" ] && rm "$TMPDIR/config.php" cp -a "$TMPDIR/." "$final_path" rm -R "$TMPDIR" # set permissions myynh_set_permissions # configure nginx settings if [ "$path_url" != "/" ]; then ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf" fi ynh_add_nginx_config # copy and set php-fpm configuration ynh_add_fpm_config # if app is private, remove url to SSOWat conf from skipped_uris if [ $is_public -eq 0 ] then ynh_app_setting_delete "$app" unprotected_regex # in old script unprotected_regex was used in place of protected_regex # escape magic chars in vars (lua magic chars are ().%+-*?[^$ according to https://www.lua.org/pil/20.2.html) domainluaregex=$(echo "$domain" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g') pathluaregex=$([ "$path_url" == "/" ] || echo "$path_url" | sed -e 's/[]().%+*?[^$[]/\%&/g' | sed -e 's/\-/\%&/g') regexList="${domainluaregex}${pathluaregex}/index%.php$","${domainluaregex}${pathluaregex}/index%.php%?p=.*$" ynh_app_setting_set "$app" protected_regex "$regexList" else ynh_app_setting_set "$app" unprotected_uris "/" fi # Purge php sessions stored in /var/lib/phpx/sessions if [ -d "/usr/lib/php5" ]; then [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean elif [ -d "/usr/lib/php" ]; then [ -x /usr/lib/php/sessionclean ] && /usr/lib/php/sessionclean fi