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)
|
2018-10-14 17:45:28 +02:00
|
|
|
port=$(ynh_app_setting_get $app port)
|
2018-08-26 19:04:08 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
|
|
|
|
2018-10-14 17:45:28 +02:00
|
|
|
# If port doesn't exist, create it
|
|
|
|
if [ -z "$port" ]; then
|
|
|
|
port=4242
|
|
|
|
ynh_app_setting_set $app port $port
|
|
|
|
fi
|
|
|
|
|
2018-08-26 19:04:08 +02:00
|
|
|
#=================================================
|
|
|
|
# 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 SYSTEMD
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_add_systemd_config
|
2019-01-10 14:17:53 +01:00
|
|
|
echo -e "\e[93m\e[1m[WARN]\e[0m Please have a look to the diff of your systemd conf file. The upgrade could have broken this CI." >&2
|
2018-08-26 19:04:08 +02:00
|
|
|
|
2018-10-14 17:45:28 +02:00
|
|
|
#=================================================
|
|
|
|
# CHANGE PORT IN YUNORUNNER
|
|
|
|
#=================================================
|
|
|
|
|
2018-11-04 20:48:37 +01:00
|
|
|
ynh_replace_string "__PORT__" "$port" "/etc/systemd/system/$app.service"
|
|
|
|
ynh_store_file_checksum "/etc/systemd/system/$app.service"
|
|
|
|
systemctl daemon-reload
|
2018-10-14 17:45:28 +02:00
|
|
|
|
2018-08-26 19:04:08 +02:00
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALISATION
|
|
|
|
#=================================================
|
|
|
|
#=================================================
|
|
|
|
# SECURING FILES AND DIRECTORIES
|
|
|
|
#=================================================
|
|
|
|
|
2018-08-28 12:47:16 +02:00
|
|
|
chown -R $app:root $final_path
|
2018-08-26 19:04:08 +02:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# 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
|
|
|
|
#=================================================
|
|
|
|
|
2018-10-14 17:45:28 +02:00
|
|
|
ynh_system_reload --service_name=$app --action=restart
|
2018-08-26 19:36:20 +02:00
|
|
|
|
|
|
|
|
2018-08-26 19:04:08 +02:00
|
|
|
#=================================================
|
|
|
|
# DEACTIVE MAINTENANCE MODE
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
ynh_maintenance_mode_OFF
|