mirror of
https://github.com/YunoHost-Apps/bozon_ynh.git
synced 2024-09-03 18:16:09 +02:00
151 lines
5.3 KiB
Bash
151 lines
5.3 KiB
Bash
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC START
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1
|
|
|
|
#REMOVEME? app=$YNH_APP_INSTANCE_NAME
|
|
|
|
#REMOVEME? domain=$(ynh_app_setting_get --app=$app --key=domain)
|
|
#REMOVEME? path=$(ynh_app_setting_get --app=$app --key=path)
|
|
#REMOVEME? admin_user=$(ynh_app_setting_get --app=$app --key=admin_user)
|
|
#REMOVEME? #REMOVEME? install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
|
#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_dir)
|
|
|
|
#=================================================
|
|
# CHECK VERSION
|
|
#=================================================
|
|
ynh_script_progression --message="Checking version..." --weight=1
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
#=================================================
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
#=================================================
|
|
#REMOVEME? ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=3
|
|
|
|
# Backup the current version of the app
|
|
#REMOVEME? ynh_backup_before_upgrade
|
|
#REMOVEME? ynh_clean_setup () {
|
|
# Restore it if the upgrade fails
|
|
#REMOVEME? ynh_restore_upgradebackup
|
|
}
|
|
# Exit if an error occurs during the execution of the script
|
|
#REMOVEME? ynh_abort_if_errors
|
|
|
|
#=================================================
|
|
# STANDARD UPGRADE STEPS
|
|
#=================================================
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
#=================================================
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
|
|
|
# Cleaning legacy permissions
|
|
#REMOVEME? if ynh_legacy_permissions_exists; then
|
|
#REMOVEME? ynh_legacy_permissions_delete_all
|
|
|
|
ynh_app_setting_delete --app=$app --key=is_public
|
|
fi
|
|
|
|
# If install_dir doesn't exist, create it
|
|
if [ -z "$install_dir" ]; then
|
|
#REMOVEME? install_dir="/var/www/$app"
|
|
#REMOVEME? ynh_app_setting_set --app="$app" --key=install_dir --value="$install_dir"
|
|
fi
|
|
# If data_dir doesn't exist, create it
|
|
if [ -z "$data_dir" ]; then
|
|
data_dir="/home/yunohost.app/$app"
|
|
#REMOVEME? ynh_app_setting_set --app="$app" --key=data_dir --value="$data_dir"
|
|
fi
|
|
|
|
#=================================================
|
|
# CREATE DEDICATED USER
|
|
#=================================================
|
|
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
|
|
|
|
# Create a dedicated user (if not existing)
|
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
|
|
|
#=================================================
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
#=================================================
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
then
|
|
# download & unpack bozon
|
|
ynh_script_progression --message="Setting up source files..." --weight=2
|
|
## download source
|
|
tmpdir=$(mktemp -d)
|
|
ynh_setup_source --dest_dir="$tmpdir"
|
|
## clean & copy files needed to final folder
|
|
myynh_clean_source
|
|
[ -e "$tmpdir/config.php" ] && ynh_secure_remove "$tmpdir/config.php"
|
|
cp -a "$tmpdir/." "$install_dir"
|
|
ynh_secure_remove "$tmpdir"
|
|
fi
|
|
|
|
## set permissions
|
|
myynh_set_permissions
|
|
|
|
#=================================================
|
|
# UPGRADE DEPENDENCIES
|
|
#=================================================
|
|
#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1
|
|
|
|
#REMOVEME? ynh_install_app_dependencies $pkg_dependencies
|
|
|
|
#=================================================
|
|
# PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading PHP-FPM configuration..." --weight=1
|
|
|
|
# Create a dedicated PHP-FPM config
|
|
ynh_add_fpm_config
|
|
|
|
#=================================================
|
|
# NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=1
|
|
|
|
if [ "$path" != "/" ]; then
|
|
ynh_replace_string --match_string="^#sub_path_only" --replace_string="" --target_file="../conf/nginx.conf"
|
|
fi
|
|
ynh_add_nginx_config
|
|
|
|
#=================================================
|
|
# SPECIFIC UPGRADE
|
|
#=================================================
|
|
# CLEAN PHP SESSIONS STORED IN /var/lib/phpx/sessions
|
|
#=================================================
|
|
ynh_script_progression --message="Cleaning php sessions stored..." --weight=1
|
|
|
|
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
|
|
|
|
#=================================================
|
|
# GENERIC FINALIZATION
|
|
#=================================================
|
|
# RELOAD NGINX
|
|
#=================================================
|
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
|
|
|
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|