From 7dd1bcbb318120ffedac7fc2fccee98dc4127b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 7 Jun 2024 14:08:01 +0200 Subject: [PATCH] cleaning --- scripts/change_url | 9 +-------- scripts/install | 16 ++-------------- scripts/remove | 22 ---------------------- scripts/restore | 32 -------------------------------- scripts/upgrade | 33 ++++++++++----------------------- 5 files changed, 13 insertions(+), 99 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 19f7c35..1f818bc 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,13 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# ACTIVATE MAINTENANCE MODE -#================================================= - -path=$old_path -domain=$old_domain - ynh_maintenance_mode_ON #================================================= @@ -25,7 +18,7 @@ ynh_maintenance_mode_ON #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/production.log" #================================================= # MODIFY URL IN NGINX CONF diff --git a/scripts/install b/scripts/install index 5cf82f5..206aa3a 100644 --- a/scripts/install +++ b/scripts/install @@ -54,7 +54,7 @@ ynh_add_nginx_config ynh_script_progression --message="Adding a configuration file..." --weight=2 workers="$(( $(nproc) * 2 ))" -ynh_add_config --template="../conf/lutim.conf.template" --destination="$install_dir/lutim.conf" +ynh_add_config --template="lutim.conf.template" --destination="$install_dir/lutim.conf" chmod 400 "$install_dir/lutim.conf" chown $app:$app "$install_dir/lutim.conf" @@ -63,7 +63,7 @@ chown $app:$app "$install_dir/lutim.conf" # SETUP CRON #================================================= -ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app" +ynh_add_config --template="cron_lutim" --destination="/etc/cron.d/$app" chmod +x $install_dir/script/lutim #================================================= @@ -100,21 +100,9 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=2 # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=2 - # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - yunohost service add $app --log="$install_dir/log/production.log" #================================================= diff --git a/scripts/remove b/scripts/remove index 4b643b6..d77069b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -22,37 +22,15 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=6 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - # Remove the app-specific logrotate config ynh_remove_logrotate -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." - # Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." - # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" diff --git a/scripts/restore b/scripts/restore index 9a38857..f63fc49 100644 --- a/scripts/restore +++ b/scripts/restore @@ -33,11 +33,6 @@ ynh_script_progression --message="Restoring the NGINX configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# RESTORE VARIOUS FILES -#================================================= -ynh_script_progression --message="Restoring various files..." - ynh_restore_file --origin_path="/etc/cron.d/$app" # Making log a symbolic link to /var/log @@ -45,42 +40,15 @@ mkdir -p /var/log/$app/ touch /var/log/$app/production.log chown $app -R /var/log/$app -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." - ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - 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 --log="$install_dir/log/production.log" -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=3 - ynh_systemd_action --action=restart --line_match="Manager.*started" --log_path="/var/log/$app/production.log" --timeout="120" -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -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 e114660..78d4b8f 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,12 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# CHECK VERSION -#================================================= - -upgrade_type=$(ynh_check_app_version_changed) - #================================================= # ACTIVATE MAINTENANCE MODE #================================================= @@ -72,14 +66,10 @@ fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= +ynh_script_progression --message="Upgrading source files..." -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading source files..." - - # 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" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -106,7 +96,7 @@ ynh_script_progression --message="Reconfiguring $app..." if [ $overwrite_settings -eq 1 ] then workers="$(( $(nproc) * 2 ))" - ynh_add_config --template="../conf/lutim.conf.template" --destination="$install_dir/lutim.conf" + ynh_add_config --template="lutim.conf.template" --destination="$install_dir/lutim.conf" chmod 400 "$install_dir/lutim.conf" chown $app:$app "$install_dir/lutim.conf" @@ -128,20 +118,17 @@ fi # SETUP CRON #================================================= -ynh_add_config --template="../conf/cron_lutim" --destination="/etc/cron.d/$app" +ynh_add_config --template="cron_lutim" --destination="/etc/cron.d/$app" #================================================= # UPDATE LUTIM WITH CARTON #================================================= +ynh_script_progression --message="Upgrading $app with Carton..." --weight=4 -if [ "$upgrade_type" == "UPGRADE_APP" ] -then - ynh_script_progression --message="Upgrading $app with Carton..." --weight=4 - pushd "$install_dir" - ynh_secure_remove --file="$install_dir/local" - carton install --without=mysql --without=htpasswd --without=test - popd -fi +pushd "$install_dir" + ynh_secure_remove --file="$install_dir/local" + carton install --without=mysql --without=htpasswd --without=test +popd #================================================= # SETUP SYSTEMD