From d3423ad2750e465e694a91a8945a9bc9790574c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Mon, 4 Mar 2024 15:42:05 +0100 Subject: [PATCH] cleanup paths shitfuck --- scripts/_common.sh | 57 ++++++++------------ scripts/backup | 28 ---------- scripts/change_url | 104 +++++------------------------------- scripts/install | 2 +- scripts/restore | 121 ++++++++++------------------------------- scripts/upgrade | 130 ++++++++++----------------------------------- 6 files changed, 91 insertions(+), 351 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index b8a4b65..89fea56 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,62 +4,47 @@ # COMMON VARIABLES #================================================= +env_path="$install_dir/envs/prod" + #================================================= # PERSONAL HELPERS #================================================= function set_permissions { - mkdir -p $data_dir + chmod 750 "$data_dir" + chown -R "$app:$app" "$data_dir" + setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx "$data_dir" - env_path=$install_dir/envs/prod - mkdir -p $env_path - - chown -R $app:$app $data_dir - chmod o-rwx $data_dir - setfacl -n -R -m u:www-data:rx -m d:u:www-data:rx $data_dir - - chown -R root:$app $install_dir - chmod -R g=u,g-w,o-rwx $install_dir - setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx $install_dir - setfacl -n -R -m user:www-data:- -m default:user:www-data:- $install_dir/envs + chmod 750 "$install_dir" + chown -R "$app:$app" "$install_dir" + setfacl -n -R -m user:www-data:rx -m default:user:www-data:rx "$install_dir" + setfacl -n -R -m user:www-data:- -m default:user:www-data:- "$install_dir/envs" } function set_up_virtualenv { - env_path=$install_dir/envs/prod - mkdir -p $env_path + mkdir -p "$env_path" ynh_add_config --template="requirements-ynh.txt" --destination="$install_dir/requirements-ynh.txt" - pushd $install_dir || ynh_die - chown -R $app:$app $install_dir - ynh_exec_warn_less ynh_exec_as $app python3 -m venv $install_dir/venv - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U wheel pip --cache-dir $install_dir/.cache/pip setuptools - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements.txt - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-setup.txt - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/pip --cache-dir $install_dir/.cache/pip install -U --requirement $install_dir/requirements-ynh.txt - set_permissions - popd || ynh_dies + ynh_exec_warn_less ynh_exec_as "$app" python3 -m venv "$install_dir/venv" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U wheel pip --cache-dir "$install_dir/.cache/pip" setuptools + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements.txt" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/source/requirements-setup.txt" + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/pip" --cache-dir "$install_dir/.cache/pip" install -U --requirement "$install_dir/requirements-ynh.txt" + set_permissions } function initialize_db { - pushd $install_dir || ynh_die - chown -R $app:$app $install_dir - perform_db_migrations - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 - set_permissions - popd || ynh_die + perform_db_migrations + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" createsuperuser --username "$admin" --email "$admin_email" --noinput -v 0 } function upgrade_db { - pushd $install_dir || ynh_die - chown -R $app:$app $install_dir - perform_db_migrations - set_permissions - popd || ynh_die + perform_db_migrations } function perform_db_migrations { - echo "y" | ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py makemigrations --merge - ynh_exec_warn_less ynh_exec_as $app $install_dir/venv/bin/envdir $env_path $install_dir/venv/bin/python $install_dir/manage.py migrate + yes | ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" makemigrations --merge + ynh_exec_warn_less ynh_exec_as "$app" "$install_dir/venv/bin/envdir" "$env_path" "$install_dir/venv/bin/python" "$install_dir/source/manage.py" migrate } #================================================= diff --git a/scripts/backup b/scripts/backup index 6e967ef..37e8cfa 100755 --- a/scripts/backup +++ b/scripts/backup @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,25 +8,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - true -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_print_info --message="Loading installation settings..." - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -get_app_settings - #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -52,18 +31,11 @@ ynh_backup --src_path="$data_dir" --is_big ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP SYSTEMD -#================================================= - ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app-celery.service" ynh_backup --src_path="/etc/systemd/system/$app-beat.service" ynh_backup --src_path="/etc/systemd/system/$app.socket" - #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= diff --git a/scripts/change_url b/scripts/change_url index 94ec32a..8f209e2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,70 +7,15 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -#REMOVEME? old_domain=$YNH_APP_OLD_DOMAIN -#REMOVEME? old_path=$YNH_APP_OLD_PATH - -#REMOVEME? new_domain=$YNH_APP_NEW_DOMAIN -#REMOVEME? new_path="/" - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -get_app_settings - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -#REMOVEME? ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - #REMOVEME? ynh_clean_check_starting - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. -#REMOVEME? ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # 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 - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -#REMOVEME? change_domain=0 -#REMOVEME? if [ "$old_domain" != "$new_domain" ] -then - #REMOVEME? change_domain=1 -fi - -#REMOVEME? change_path=0 -#REMOVEME? if [ "$old_path" != "$new_path" ] -then - #REMOVEME? change_path=1 -fi - -#================================================= -# STANDARD MODIFICATIONS #================================================= # STOP SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Stopping systemd services..." --weight=1 +ynh_script_progression --message="Stopping $app's systemd services..." --weight=1 -ynh_systemd_action --service_name=$app-celery --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app.socket --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app.socket" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF @@ -81,45 +24,26 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config -#REMOVEME? nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location -#REMOVEME? ynh_delete_file_checksum --file="$nginx_conf_path" -#REMOVEME? mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location -#REMOVEME? ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - #================================================= # SPECIFIC MODIFICATIONS #================================================= -echo $new_domain > $install_dir/envs/prod/DEFAULT_BASE_URL -echo "$app@$new_domain" > $install_dir/envs/prod/DEFAULT_FROM_EMAIL -echo "$app@$new_domain" > $install_dir/envs/prod/SERVER_EMAIL +ynh_script_progression --message="Updating $app's configuration files..." --weight=1 + +echo "$new_domain" > "$env_path/envs/prod/DEFAULT_BASE_URL" +echo "$app@$new_domain" > "$env_path/envs/prod/DEFAULT_FROM_EMAIL" +echo "$app@$new_domain" > "$env_path/envs/prod/SERVER_EMAIL" set_permissions -#================================================= -# GENERIC FINALISATION #================================================= # START SYSTEMD SERVICES #================================================= ynh_script_progression --message="Starting systemd services..." --weight=1 -ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? #REMOVEME? ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 81c0dc3..3a6766f 100755 --- a/scripts/install +++ b/scripts/install @@ -23,7 +23,7 @@ ynh_app_setting_set --app="$app" --key="random_key" --value="$secret_key" ynh_script_progression --message="Setting up source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src -ynh_setup_source --dest_dir="$install_dir" +ynh_setup_source --dest_dir="$install_dir/source" set_permissions diff --git a/scripts/restore b/scripts/restore index 47b0161..45484f9 100755 --- a/scripts/restore +++ b/scripts/restore @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -10,43 +8,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting -} -# Exit if an error occurs during the execution of the script -#REMOVEME? ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -#REMOVEME? ynh_script_progression --message="Loading installation settings..." --weight=1 - -#REMOVEME? app=$YNH_APP_INSTANCE_NAME - -get_app_settings - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -#REMOVEME? ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -#REMOVEME? test ! -d $install_dir \ - || ynh_die --message="There is already a directory: $install_dir " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -#REMOVEME? ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -#REMOVEME? ynh_system_user_create --username=$app --home_dir=$install_dir - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -61,83 +22,55 @@ ynh_script_progression --message="Restoring the data directory..." ynh_restore_file --origin_path="$data_dir" --not_mandatory -mkdir -p $data_dir - -chmod 750 "$data_dir" chmod -R o-rwx "$data_dir" -chown -R $app:www-data "$data_dir" +chown -R "$app:www-data" "$data_dir" #================================================= -# SPECIFIC RESTORATION +# RESTORE THE DATA DIRECTORY #================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=1 +ynh_script_progression --message="Restoring the data directory..." --weight=1 -# Define and install dependencies -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies +ynh_restore_file --origin_path="$data_dir" --not_mandatory -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." +chown -R "$app:www-data" "$data_dir" -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - -#================================================= -# RESTORE THE POSTGRESQL DATABASE -#================================================= -#REMOVEME? ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 - -#REMOVEME? ynh_psql_test_if_first_run -#REMOVEME? db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) -#REMOVEME? ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql - -#================================================= -# RESTORE USER RIGHTS -#================================================= # Restore permissions on app files set_permissions #================================================= -# RESTORE SYSTEMD +# RESTORE THE PSQL DATABASE #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=1 + +ynh_psql_connect_as --user="$db_user" --password="$db_pwd" --database="$db_name" < ./db.sql + +#================================================= +# RESTORE SYSTEM CONFIGURATIONS +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 + +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-celery.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-beat.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.socket" -systemctl enable $app-celery --quiet -systemctl enable $app-beat --quiet -systemctl enable $app --quiet -systemctl enable $app.socket --quiet +systemctl enable "$app-celery" --quiet +systemctl enable "$app-beat" --quiet +systemctl enable "$app" --quiet +systemctl enable "$app.socket" --quiet +yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 -yunohost service add $app --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting systemd services..." --weight=1 - -ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 86d9f09..8605a4d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,7 +1,5 @@ #!/bin/bash -#================================================= -# GENERIC START #================================================= # IMPORT GENERIC HELPERS #================================================= @@ -9,103 +7,42 @@ 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 - -get_app_settings - -#================================================= -# CHECK VERSION -#================================================= -ynh_script_progression --message="Checking version..." - -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=1 - -# Backup the current version of the app -#REMOVEME? ynh_backup_before_upgrade -#REMOVEME? ynh_clean_setup () { - ynh_clean_check_starting - # 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 #================================================= # STOP SYSTEMD SERVICES #================================================= -ynh_script_progression --message="Stopping systemd services..." --weight=1 +ynh_script_progression --message="Stopping $app's systemd services..." --weight=1 -ynh_systemd_action --service_name=$app.socket --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="stop" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-celery --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app.socket" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="stop" --log_path="/var/log/$app/$app.log" -systemctl disable $app.socket --quiet -systemctl disable $app --quiet -systemctl disable $app-beat --quiet -systemctl disable $app-celery --quiet +systemctl disable "$app.socket" --quiet +systemctl disable "$app" --quiet +systemctl disable "$app-beat" --quiet +systemctl disable "$app-celery" --quiet #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --time --weight=1 -if [ -z "$data_dir" ]; then -#REMOVEME? data_dir=$(ynh_app_setting_get --app=$app --key=data_path) -#REMOVEME? ynh_app_setting_set --app=$app --key=data_dir --value=$data_dir - ynh_app_setting_delete --app=$app --key=data_path - ynh_app_setting_delete --app=$app --key=db_pwd - ynh_app_setting_delete --app=$app --key=admin_email +if [ -n "${data_path:-}" ]; then + ynh_app_setting_delete --app="$app" --key=data_path + ynh_app_setting_delete --app="$app" --key=db_pwd + ynh_app_setting_delete --app="$app" --key=admin_email 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 #================================================= +ynh_script_progression --message="Upgrading source files..." --weight=1 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." --weight=1 - - # Download, check integrity, uncompress and patch the source from app.src - ynh_setup_source --dest_dir="$install_dir" -fi +# Download, check integrity, uncompress and patch the source from app.src +ynh_setup_source --dest_dir="$install_dir" set_permissions -#================================================= -# UPGRADE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Upgrading dependencies..." --weight=1 - -#REMOVEME? ynh_install_app_dependencies $pkg_dependencies - -#================================================= -# NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 - -# Create a dedicated NGINX config -ynh_add_nginx_config #================================================= # SPECIFIC UPGRADE @@ -116,6 +53,7 @@ ynh_script_progression --message="Upgrading Python virtualenv..." --weight=2 set_up_virtualenv + #================================================= # PERFORM DATABASE MIGRATIONS #================================================= @@ -124,9 +62,12 @@ ynh_script_progression --message="Performing database migrations..." --weight=2 upgrade_db #================================================= -# SETUP SYSTEMD +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 + +# Create a dedicated NGINX config +ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config @@ -136,32 +77,17 @@ ynh_add_systemd_config --service="$app-beat" --template systemd-beat.service systemctl disable "$app-socket.service" --quiet mv "/etc/systemd/system/$app-socket.service" "/etc/systemd/system/$app.socket" systemctl daemon-reload --quiet - -#================================================= -# GENERIC FINALIZATION -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" +yunohost service add "$app" --description="Manage podcast subscriptions, and sync them between apps and devices" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting systemd services..." --weight=1 +ynh_script_progression --message="Starting $app's systemd service..." --weight=1 -ynh_systemd_action --service_name=$app.socket --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-celery --action="start" --log_path="/var/log/$app/$app.log" -ynh_systemd_action --service_name=$app-beat --action="start" --log_path="/var/log/$app/$app.log" - -#================================================= -# RELOAD NGINX -#================================================= -#REMOVEME? ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -#REMOVEME? ynh_systemd_action --service_name=nginx --action=reload +ynh_systemd_action --service_name="$app.socket" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-celery" --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name="$app-beat" --action="start" --log_path="/var/log/$app/$app.log" #================================================= # END OF SCRIPT