From 1764cf79066962ff568cd1e8e0e418990a896aae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 15 Oct 2023 08:50:04 +0200 Subject: [PATCH] cleaning --- scripts/_common.sh | 2 ++ scripts/change_url | 6 ------ scripts/install | 23 +++++++---------------- scripts/remove | 15 --------------- scripts/restore | 40 ++++++---------------------------------- scripts/upgrade | 29 +++++++---------------------- 6 files changed, 22 insertions(+), 93 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 5bd136c..49e9b21 100755 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,8 @@ nodejs_version=20 n8n_version=1.9.3 +timezone="$(cat /etc/timezone)" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/change_url b/scripts/change_url index 97b2171..11fb0a6 100755 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,12 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - -timezone="$(cat /etc/timezone)" - #================================================= # STANDARD MODIFICATIONS #================================================= diff --git a/scripts/install b/scripts/install index 26eb3eb..50f091e 100755 --- a/scripts/install +++ b/scripts/install @@ -53,6 +53,13 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=4 # Create a dedicated NGINX config ynh_add_nginx_config + +env_path="$PATH" +# Create a dedicated systemd config +ynh_add_systemd_config + +yunohost service add $app --description="Workflow Automation Tool" --log="/var/log/$app/$app.log" + #================================================= # ADD A CONFIGURATION #================================================= @@ -63,22 +70,6 @@ ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" chmod 400 "$install_dir/.env" chown $app:$app "$install_dir/.env" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=4 - -env_path="$PATH" -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 - -yunohost service add $app --description="Workflow Automation Tool" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/remove b/scripts/remove index 584b312..7eaca87 100755 --- a/scripts/remove +++ b/scripts/remove @@ -22,27 +22,12 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Removing dependencies..." --weight=1 - # Remove metapackage and its dependencies ynh_remove_nodejs -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 - # Remove the dedicated NGINX config ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index f8559c0..4f494c5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -16,7 +16,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -27,27 +26,8 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1 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" -#================================================= -# REINSTALL DEPENDENCIES -#================================================= -#REMOVEME? ynh_script_progression --message="Reinstalling dependencies..." --weight=7 - -# Install Nodejs -ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version - -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RESTORE THE MYSQL DATABASE #================================================= @@ -56,20 +36,19 @@ ynh_script_progression --message="Restoring the MySQL database..." --weight=1 ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= -# INTEGRATE SERVICE IN YUNOHOST +# REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 -yunohost service add $app --description="Workflow Automation Tool" --log="/var/log/$app/$app.log" +# Install Nodejs +ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=8 +ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet +yunohost service add $app --description="Workflow Automation Tool" --log="/var/log/$app/$app.log" + #================================================= # START SYSTEMD SERVICE #================================================= @@ -77,13 +56,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=8 ynh_systemd_action --service_name=$app --action=restart --log_path=systemd --line_match="Editor is now accessible via:" -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX AND PHP-FPM -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=2 - ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 4ef0c13..4fa1295 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers # LOAD SETTINGS #================================================= -timezone="$(cat /etc/timezone)" +email=$(ynh_user_get_info --username=$admin --key=mail) #================================================= # CHECK VERSION @@ -72,13 +72,14 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=12 - ynh_install_nodejs --nodejs_version=$nodejs_version +env_path="$PATH" +# Create a dedicated systemd config +ynh_add_systemd_config + +yunohost service add $app --description="Workflow Automation Tool" --log="/var/log/$app/$app.log" + #================================================= # UPGRADE A CONFIGURATION FILE #================================================= @@ -89,22 +90,6 @@ ynh_add_config --template="../conf/.env" --destination="$install_dir/.env" chmod 400 "$install_dir/.env" chown $app:$app "$install_dir/.env" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=2 - -env_path="$PATH" -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=2 - -yunohost service add $app --description="Workflow Automation Tool" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #=================================================