2018-08-26 19:04:08 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC STARTING
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# LOAD SETTINGS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
|
|
path_url=$(ynh_app_setting_get $app path)
|
|
|
|
final_path=$(ynh_app_setting_get $app final_path)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK THE PATH
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
path_url=$(ynh_normalize_url_path $path_url) # Vérifie et corrige la syntaxe du path.
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ACTIVATE MAINTENANCE MODE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_maintenance_mode_ON
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
|
|
|
ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie dans $final_path
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=================================================
|
2018-08-26 19:36:20 +02:00
|
|
|
# UPGRADE DEPENDENCIES
|
2018-08-26 19:04:08 +02:00
|
|
|
#=================================================
|
|
|
|
|
2018-08-26 19:36:20 +02:00
|
|
|
ynh_install_app_dependencies python-virtualenv sqlite3 zlib1g-dev
|
2018-08-26 19:04:08 +02:00
|
|
|
|
|
|
|
#=================================================
|
2018-08-26 19:36:20 +02:00
|
|
|
# NGINX CONFIGURATION
|
2018-08-26 19:04:08 +02:00
|
|
|
#=================================================
|
|
|
|
|
2018-08-26 19:36:20 +02:00
|
|
|
ynh_add_nginx_config
|
2018-08-26 19:04:08 +02:00
|
|
|
|
|
|
|
#=================================================
|
2018-08-26 19:36:20 +02:00
|
|
|
# CREATE DEDICATED USER
|
2018-08-26 19:04:08 +02:00
|
|
|
#=================================================
|
|
|
|
|
2018-08-26 19:36:20 +02:00
|
|
|
ynh_system_user_create $app # Create the dedicated user, if not exist
|
2018-08-26 19:04:08 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
|
|
|
# SETUP LOGROTATE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_use_logrotate --non-append
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_add_systemd_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALISATION
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# SECURING FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
# Les fichiers appartiennent à root
|
|
|
|
chown -R root: $final_path
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SSOWAT
|
|
|
|
#=================================================
|
|
|
|
|
2018-08-26 19:36:20 +02:00
|
|
|
# Make app public
|
|
|
|
ynh_app_setting_set $app skipped_uris "/"
|
2018-08-26 19:04:08 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_system_reload --service_name=nginx
|
|
|
|
|
2018-08-26 19:36:20 +02:00
|
|
|
#=================================================
|
|
|
|
# RESTART YUNORUNNER
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_system_reload --service_name=yunorunner --action=restart
|
|
|
|
|
|
|
|
|
2018-08-26 19:04:08 +02:00
|
|
|
#=================================================
|
|
|
|
# DEACTIVE MAINTENANCE MODE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_maintenance_mode_OFF
|