2017-01-08 12:17:57 +01:00
|
|
|
#!/bin/bash
|
2016-03-23 19:30:43 +01:00
|
|
|
|
2017-07-26 21:32:00 +02:00
|
|
|
set -eu
|
2017-07-03 21:07:56 +02:00
|
|
|
source _common.sh
|
2016-10-13 06:51:38 +02:00
|
|
|
source /usr/share/yunohost/helpers
|
2016-04-26 20:37:18 +02:00
|
|
|
|
2017-07-03 21:07:56 +02:00
|
|
|
# manage script failure
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2016-04-26 20:17:50 +02:00
|
|
|
# retrieve arguments
|
2016-10-13 06:51:38 +02:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get "$app" domain)
|
2017-07-03 21:07:56 +02:00
|
|
|
path_url=$(ynh_app_setting_get "$app" path)
|
2016-10-13 06:51:38 +02:00
|
|
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
2017-07-03 21:07:56 +02:00
|
|
|
admin_user=$(ynh_app_setting_get "$app" admin_user)
|
|
|
|
backup_core_only=$(ynh_app_setting_get "$app" backup_core_only)
|
2016-04-26 20:17:50 +02:00
|
|
|
|
|
|
|
# definie useful vars
|
2017-07-03 21:07:56 +02:00
|
|
|
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 () {
|
2018-02-05 19:37:22 +01:00
|
|
|
ynh_restore_upgradebackup
|
2017-07-03 21:07:56 +02:00
|
|
|
}
|
|
|
|
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
|
2017-09-22 19:33:28 +02:00
|
|
|
myynh_clean_source
|
|
|
|
[ -e "$TMPDIR/config.php" ] && rm "$TMPDIR/config.php"
|
|
|
|
cp -a "$TMPDIR/." "$final_path"
|
|
|
|
rm -R "$TMPDIR"
|
2016-04-26 20:39:15 +02:00
|
|
|
|
2017-07-03 21:07:56 +02:00
|
|
|
# set permissions
|
2017-07-07 17:03:57 +02:00
|
|
|
myynh_set_permissions
|
2016-04-26 20:17:50 +02:00
|
|
|
|
|
|
|
# configure nginx settings
|
2018-05-26 14:44:52 +02:00
|
|
|
if [ "$path_url" != "/" ]; then
|
|
|
|
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
|
|
|
|
fi
|
2018-05-26 13:17:41 +02:00
|
|
|
ynh_add_nginx_config
|
2016-03-23 19:30:43 +01:00
|
|
|
|
2016-05-23 20:59:08 +02:00
|
|
|
# copy and set php-fpm configuration
|
2018-05-26 13:17:41 +02:00
|
|
|
ynh_add_fpm_config
|
2016-05-23 20:59:08 +02:00
|
|
|
|
2016-04-26 20:17:50 +02:00
|
|
|
# if app is private, remove url to SSOWat conf from skipped_uris
|
2017-07-03 21:07:56 +02:00
|
|
|
if [ $is_public -eq 0 ]
|
2016-04-26 20:17:50 +02:00
|
|
|
then
|
2017-07-03 21:07:56 +02:00
|
|
|
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 "/"
|
2016-04-26 20:17:50 +02:00
|
|
|
fi
|
2016-03-23 19:30:43 +01:00
|
|
|
|
2018-05-26 13:17:41 +02:00
|
|
|
# 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
|