2019-02-17 19:06:33 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC START
|
|
|
|
#=================================================
|
|
|
|
# IMPORT GENERIC HELPERS
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
source _common.sh
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
2022-07-29 00:43:33 +02:00
|
|
|
#=================================================
|
|
|
|
# CHECK VERSION
|
|
|
|
#=================================================
|
|
|
|
|
|
|
|
upgrade_type=$(ynh_check_app_version_changed)
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# STANDARD UPGRADE STEPS
|
|
|
|
#=================================================
|
|
|
|
# STOP SYSTEMD SERVICE
|
|
|
|
#=================================================
|
2022-10-05 22:54:13 +02:00
|
|
|
ynh_script_progression --message="Stopping a systemd service..." --weight=1
|
2022-07-29 00:43:33 +02:00
|
|
|
|
|
|
|
ynh_systemd_action --service_name=$app --action="stop"
|
2019-02-17 19:06:33 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# ENSURE DOWNWARD COMPATIBILITY
|
|
|
|
#=================================================
|
2022-07-29 00:43:33 +02:00
|
|
|
ynh_script_progression --message="Ensuring downward compatibility..." --weight=1
|
2019-02-17 19:06:33 +01:00
|
|
|
|
|
|
|
# If db_name doesn't exist, create it
|
|
|
|
if [ -z $db_name ]; then
|
|
|
|
db_name=$(ynh_sanitize_dbid $app)
|
2023-08-16 18:11:35 +02:00
|
|
|
#REMOVEME? ynh_app_setting_set $app db_name $db_name
|
2019-02-17 19:06:33 +01:00
|
|
|
fi
|
|
|
|
|
2023-08-16 18:11:35 +02:00
|
|
|
# If install_dir doesn't exist, create it
|
|
|
|
if [ -z $install_dir ]; then
|
|
|
|
#REMOVEME? install_dir=/opt/yunohost/$app
|
|
|
|
#REMOVEME? ynh_app_setting_set $app install_dir $install_dir
|
2019-02-17 19:06:33 +01:00
|
|
|
fi
|
|
|
|
|
2022-07-29 00:43:33 +02:00
|
|
|
# If data directory doesn't exists
|
2023-08-16 18:11:35 +02:00
|
|
|
if [ -z $install_dir/data ]; then
|
|
|
|
mkdir $install_dir/data
|
2022-07-29 00:43:33 +02:00
|
|
|
fi
|
2019-02-17 19:06:33 +01:00
|
|
|
|
2022-07-29 00:43:33 +02:00
|
|
|
# check data directory permission
|
2023-08-16 18:11:35 +02:00
|
|
|
chown -R $app: $install_dir/data
|
2019-02-17 19:06:33 +01:00
|
|
|
|
|
|
|
#=================================================
|
2022-07-29 00:43:33 +02:00
|
|
|
# CREATE DEDICATED USER
|
2019-02-17 19:06:33 +01:00
|
|
|
#=================================================
|
2023-08-16 18:11:35 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Making sure dedicated system user exists..." --weight=2
|
2019-02-17 19:06:33 +01:00
|
|
|
|
2022-07-29 00:43:33 +02:00
|
|
|
# Create a dedicated user (if not existing)
|
2023-08-16 18:11:35 +02:00
|
|
|
#REMOVEME? ynh_system_user_create --username=$app --home_dir="$install_dir"
|
2019-02-17 19:06:33 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
|
|
|
#=================================================
|
|
|
|
|
2022-07-29 00:43:33 +02:00
|
|
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
|
|
|
then
|
2022-10-05 22:54:13 +02:00
|
|
|
ynh_script_progression --message="Upgrading source files..." --weight=1
|
2022-07-29 00:43:33 +02:00
|
|
|
|
|
|
|
# Download, check integrity, uncompress and patch the source from app.src
|
2023-08-16 18:11:35 +02:00
|
|
|
ynh_setup_source --dest_dir="$install_dir"
|
2022-07-29 00:43:33 +02:00
|
|
|
fi
|
|
|
|
|
2023-08-16 18:11:35 +02:00
|
|
|
chmod 750 "$install_dir"
|
|
|
|
chmod -R o-rwx "$install_dir"
|
|
|
|
chown -R $app:www-data "$install_dir"
|
2019-02-17 19:06:33 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# NGINX CONFIGURATION
|
|
|
|
#=================================================
|
2020-11-22 15:27:37 +01:00
|
|
|
ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2
|
2019-02-17 19:06:33 +01:00
|
|
|
|
2020-11-30 15:07:53 +01:00
|
|
|
# Create a dedicated NGINX config
|
2019-02-17 19:06:33 +01:00
|
|
|
ynh_add_nginx_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SPECIFIC UPGRADE
|
|
|
|
#=================================================
|
2022-07-29 00:43:33 +02:00
|
|
|
# UPDATE A CONFIG FILE
|
|
|
|
#=================================================
|
2022-10-05 22:54:13 +02:00
|
|
|
ynh_script_progression --message="Updating a configuration file..." --weight=1
|
2019-02-17 19:06:33 +01:00
|
|
|
|
2023-08-16 18:11:35 +02:00
|
|
|
ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config.yml"
|
2019-02-17 19:06:33 +01:00
|
|
|
|
2023-08-16 18:11:35 +02:00
|
|
|
chmod 400 "$install_dir/config.yml"
|
|
|
|
chown $app:$app "$install_dir/config.yml"
|
2019-02-17 19:06:33 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# SETUP SYSTEMD
|
|
|
|
#=================================================
|
2022-10-05 22:54:13 +02:00
|
|
|
ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
|
2019-02-17 19:06:33 +01:00
|
|
|
|
|
|
|
# Create a dedicated systemd config
|
2022-07-29 00:43:33 +02:00
|
|
|
architecture=$YNH_ARCH
|
2019-02-17 19:06:33 +01:00
|
|
|
ynh_add_systemd_config
|
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# GENERIC FINALIZATION
|
|
|
|
#=================================================
|
2022-07-29 00:43:33 +02:00
|
|
|
# INTEGRATE SERVICE IN YUNOHOST
|
2020-11-22 15:27:37 +01:00
|
|
|
#=================================================
|
2022-10-05 22:54:13 +02:00
|
|
|
ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
|
2020-11-22 15:27:37 +01:00
|
|
|
|
|
|
|
yunohost service add $app
|
|
|
|
|
2019-02-17 19:06:33 +01:00
|
|
|
#=================================================
|
2022-07-29 00:43:33 +02:00
|
|
|
# START SYSTEMD SERVICE
|
2019-03-10 13:43:27 +01:00
|
|
|
#=================================================
|
2022-10-05 22:54:13 +02:00
|
|
|
ynh_script_progression --message="Starting a systemd service..." --weight=1
|
2019-03-10 13:43:27 +01:00
|
|
|
|
2022-07-29 00:43:33 +02:00
|
|
|
ynh_systemd_action --service_name=$app --action="start"
|
2019-03-10 13:43:27 +01:00
|
|
|
|
2019-02-17 19:06:33 +01:00
|
|
|
#=================================================
|
|
|
|
# RELOAD NGINX
|
|
|
|
#=================================================
|
2023-08-16 18:11:35 +02:00
|
|
|
#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1
|
2019-02-17 19:06:33 +01:00
|
|
|
|
2023-08-16 18:11:35 +02:00
|
|
|
#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload
|
2020-11-30 15:07:53 +01:00
|
|
|
|
|
|
|
#=================================================
|
|
|
|
# END OF SCRIPT
|
|
|
|
#=================================================
|
2019-03-10 17:11:52 +01:00
|
|
|
|
2020-11-22 15:27:37 +01:00
|
|
|
ynh_script_progression --message="Upgrade of $app completed" --last
|