2015-02-26 23:40:40 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-11-05 13:34:17 +01:00
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
2015-02-26 23:40:40 +01:00
|
|
|
|
2020-11-05 13:34:17 +01:00
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
2015-02-26 23:40:40 +01:00
|
|
|
|
2020-11-05 13:34:17 +01:00
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Loading installation settings..." --weight=1
|
2015-02-26 23:40:40 +01:00
|
|
|
|
2020-11-05 13:34:17 +01:00
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
2015-02-26 23:40:40 +01:00
|
|
|
|
2020-11-05 13:34:17 +01:00
|
|
|
domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
|
|
path_url=$(ynh_app_setting_get --app=$app --key=path)
|
2020-11-27 12:41:05 +01:00
|
|
|
is_public=$(ynh_app_setting_get --app=$app --key=is_public)
|
2020-11-05 13:34:17 +01:00
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
2015-02-26 23:40:40 +01:00
|
|
|
|
2020-11-05 13:34:17 +01:00
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=2
|
|
|
|
|
|
|
|
# Fix is_public as a boolean value
|
|
|
|
if [ "$is_public" = "Yes" ]; then
|
|
|
|
ynh_app_setting_set --app=$app --key=is_public --value=1
|
|
|
|
is_public=1
|
|
|
|
elif [ "$is_public" = "No" ]; then
|
|
|
|
ynh_app_setting_set --app=$app --key=is_public --value=0
|
|
|
|
is_public=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If final_path doesn't exist, create it
|
|
|
|
if [ -z "$final_path" ]; then
|
|
|
|
final_path=/var/www/$app
|
|
|
|
ynh_app_setting_set --app=$app --key=final_path --value=$final_path
|
|
|
|
fi
|
|
|
|
|
2021-02-20 00:02:27 +01:00
|
|
|
# Cleaning legacy permissions
|
|
|
|
if ynh_legacy_permissions_exists; then
|
|
|
|
ynh_legacy_permissions_delete_all
|
|
|
|
|
|
|
|
ynh_app_setting_delete --app=$app --key=is_public
|
|
|
|
fi
|
|
|
|
|
2020-11-05 13:34:17 +01:00
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
2020-11-05 13:58:06 +01:00
|
|
|
ynh_script_progression --message="Backing up ChtickyNotes before upgrading (may take a while)..." --weight=1
|
2020-11-05 13:34:17 +01:00
|
|
|
|
|
|
|
# Backup the current version of the app
|
|
|
|
ynh_backup_before_upgrade
|
|
|
|
ynh_clean_setup () {
|
|
|
|
# restore it if the upgrade fails
|
|
|
|
ynh_restore_upgradebackup
|
|
|
|
}
|
|
|
|
# Exit if an error occurs during the execution of the script
|
|
|
|
ynh_abort_if_errors
|
|
|
|
|
2020-11-27 12:41:05 +01:00
|
|
|
#=================================================
|
|
|
|
# CREATE DEDICATED USER
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
|
|
|
|
|
|
|
# Create a dedicated user (if not existing)
|
|
|
|
ynh_system_user_create --username=$app
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# PHP-FPM CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Configuring PHP-FPM..."
|
|
|
|
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
|
|
ynh_add_fpm_config --usage=low --footprint=low
|
|
|
|
|
2020-11-05 13:34:17 +01:00
|
|
|
#=================================================
|
|
|
|
# SECURE FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
cp -a ../sources/* $final_path
|
2020-11-27 12:41:05 +01:00
|
|
|
chown -R $app: $final_path
|
2020-11-05 13:34:17 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
|
|
|
|
|
|
|
# Create a dedicated nginx config
|
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
|
|
|
|
|
|
ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
|
|
|
|
2020-11-05 13:58:06 +01:00
|
|
|
ynh_script_progression --message="Upgrade of ChtickyNotes completed" --last
|