From 87f035a8b3308e2b7ab43d8f8a1a4464698bc5ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 18 Feb 2023 19:16:44 +0100 Subject: [PATCH] fix --- scripts/install | 46 +++++++++++++++------------------------------- scripts/remove | 28 ++++------------------------ scripts/restore | 34 +++++++--------------------------- scripts/upgrade | 48 ++++++++++++------------------------------------ 4 files changed, 38 insertions(+), 118 deletions(-) diff --git a/scripts/install b/scripts/install index 4546177..6a9bce4 100644 --- a/scripts/install +++ b/scripts/install @@ -83,6 +83,21 @@ pushd "$install_dir" ynh_exec_warn_less crystal build $install_dir/src/invidious.cr --release popd +#================================================= +# SYSTEM CONFIGURATION +#================================================= +ynh_script_progression --message="Adding system configurations related to $app ..." --weight=10 + +ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app" +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" + +ynh_use_logrotate + +ynh_add_systemd_config + +yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" + #================================================= # MODIFY A CONFIG FILE #================================================= @@ -93,37 +108,6 @@ ynh_add_config --template="../conf/config.yml" --destination="$install_dir/confi chmod 600 "$install_dir/config/config.yml" chown $app:$app "$install_dir/config/config.yml" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -ynh_add_systemd_config - -#================================================= -# SETUP CRON -#================================================= -ynh_script_progression --message="Setuping a cron..." --weight=1 - -ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app" -chown root: "/etc/cron.d/$app" -chmod 644 "/etc/cron.d/$app" - -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 - -# Use logrotate to manage application logfile(s) -ynh_use_logrotate - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/remove b/scripts/remove index 3a024a1..95cc5e2 100644 --- a/scripts/remove +++ b/scripts/remove @@ -23,41 +23,21 @@ then fi #================================================= -# STOP AND REMOVE SERVICE +# REMOVE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 +ynh_script_progression --message="Removing system configurations related to $app..." --weight=10 + +dpkg --remove crystal # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -dpkg --remove crystal - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5 - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing the cron file..." --weight=1 - # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index bf2041f..d97cae5 100644 --- a/scripts/restore +++ b/scripts/restore @@ -21,7 +21,7 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring Invidious main directory..." --weight=4 +ynh_script_progression --message="Restoring the app main directory..." --weight=4 ynh_restore_file --origin_path="$install_dir" @@ -46,49 +46,29 @@ ynh_script_progression --message="Restoring the PostgreSQL database..." --weight ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= -# RESTORE SYSTEMD +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=5 +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# RESTORE VARIOUS FILES -#================================================= -ynh_script_progression --message="Restoring various files..." --weight=1 - ynh_restore_file --origin_path="/etc/cron.d/$app" chown root: "/etc/cron.d/$app" chmod 644 "/etc/cron.d/$app" -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 - ynh_restore_file --origin_path="/etc/logrotate.d/$app" -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -ynh_systemd_action --service_name=$app --action=start --log_path=systemd - #================================================= # GENERIC FINALIZATION #================================================= -# RELOAD NGINX +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE #================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 + +ynh_systemd_action --service_name=$app --action=start --log_path=systemd ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 68cf6f2..69f358a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -87,13 +87,23 @@ chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" #================================================= -# NGINX CONFIGURATION +# REAPPLY SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 +ynh_script_progression --message="Upgrading system configurations related to $app..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config +ynh_add_systemd_config + +ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app" +chown root: "/etc/cron.d/$app" +chmod 644 "/etc/cron.d/$app" + +ynh_use_logrotate --non-append + +yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" + #================================================= # MODIFY A CONFIG FILE #================================================= @@ -102,40 +112,6 @@ ynh_script_progression --message="Modifying a config file..." ynh_add_config --template="../conf/config.yml" --destination="$install_dir/config/config.yml" chmod 600 $install_dir/config/config.yml -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=2 - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# SETUP CRON -#================================================= -ynh_script_progression --message="Setuping a cron..." --weight=1 - -ynh_add_config --template="../conf/cron_invidious" --destination="/etc/cron.d/$app" -chown root: "/etc/cron.d/$app" -chmod 644 "/etc/cron.d/$app" - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 - -# Use logrotate to manage app-specific logfile(s) -ynh_use_logrotate --non-append - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 - -yunohost service add $app --description="Invidious is an alternative front-end to YouTube" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #=================================================