From cc90d8a9d48fbd9927b457b7afcfa4f2d4e663a3 Mon Sep 17 00:00:00 2001 From: leonard Date: Sat, 2 Dec 2023 09:50:04 +0100 Subject: [PATCH] fix upgrade --- scripts/restore | 1 + scripts/upgrade | 52 +++++++++++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/scripts/restore b/scripts/restore index 47f5ff2..6b9f503 100755 --- a/scripts/restore +++ b/scripts/restore @@ -24,6 +24,7 @@ ynh_systemd_action --service_name="nginx" --action="reload" ynh_script_progression --message="Restoring the app main directory..." --weight=1 ynh_restore_file --origin_path="$install_dir" +rm $install_dir/gunicorn.pid #================================================= # RESTORE THE DATA DIRECTORY diff --git a/scripts/upgrade b/scripts/upgrade index ce47a5e..1a7be5e 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -19,20 +19,42 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= -# "REBUILD" THE APP (DEPLOY NEW SOURCES, RERUN NPM BUILD...) +# SETUP SYSTEMD #================================================= -# DOWNLOAD, CHECK AND UNPACK SOURCE +ynh_script_progression --message="Configuring systemd service '$app'..." --weight=5 + +ynh_add_systemd_config --service=$app --template="systemd.service" + #================================================= +# PYTHON VIRTUALENV +#================================================= +ynh_script_progression --message="Create and setup Python virtualenv..." --weight=45 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=1 +ynh_add_config --template="requirements.txt" --destination="$install_dir/requirements.txt" - # Download, check integrity, uncompress and patch the source from manifest.toml - ynh_setup_source --dest_dir="$install_dir" -fi +myynh_setup_python_venv + +#================================================= +# copy config files +# ================================================ +ynh_script_progression --message="Create $app configuration files..." + +ynh_add_config --template="gunicorn.conf.py" --destination="$install_dir/gunicorn.conf.py" + +#================================================= +# SETUP LOGROTATE +#================================================= +ynh_script_progression --message="Upgrading logrotate configuration..." + +# Use logrotate to manage app-specific logfile(s) +ynh_use_logrotate --logfile="$log_file" --specific_user=$app --non-append + +#================================================= +# SECURE FILES AND DIRECTORIES +#================================================= +ynh_script_progression --message="Set file permissions..." +myynh_fix_file_permissions -chown -R $app:www-data "$install_dir" #================================================= # REAPPLY SYSTEM CONFIGURATIONS @@ -45,18 +67,6 @@ ynh_add_systemd_config yunohost service add $app --description="A short description of the app" --log="/var/log/$app/$app.log" -#================================================= -# RECONFIGURE THE APP (UPDATE CONF, APPLY MIGRATIONS...) -#================================================= -# UPDATE A CONFIG FILE -#================================================= -#ynh_script_progression --message="Updating a configuration file..." --weight=1 - -#ynh_add_config --template="some_config_file" --destination="$install_dir/some_config_file" - -#chmod 400 "$install_dir/some_config_file" -#chown $app:$app "$install_dir/some_config_file" - #================================================= # START SYSTEMD SERVICE #=================================================