From ff1d963eac789243a51bc31d20ebed0feeebddc0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 2 May 2019 20:44:22 +0200 Subject: [PATCH] Adding ynh_systemd_action --- scripts/backup | 14 ++++++++++++++ scripts/change_url | 14 ++++++++++++++ scripts/install | 16 ++++++++++++++++ scripts/restore | 7 +++++++ scripts/upgrade | 14 ++++++++++++++ 5 files changed, 65 insertions(+) diff --git a/scripts/backup b/scripts/backup index 25bfc9a..0af842e 100755 --- a/scripts/backup +++ b/scripts/backup @@ -34,6 +34,13 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= # STANDARD BACKUP STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + #================================================= # BACKUP THE APP MAIN DIR #================================================= @@ -92,6 +99,13 @@ ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/cron.d/$app" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/change_url b/scripts/change_url index 1b12f70..d252bc2 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -51,6 +51,13 @@ fi #================================================= # STANDARD MODIFICATIONS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + #================================================= # MODIFY URL IN NGINX CONF #================================================= @@ -88,6 +95,13 @@ fi #================================================= # GENERIC FINALISATION +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/install b/scripts/install index 22d2000..5ac588a 100755 --- a/scripts/install +++ b/scripts/install @@ -297,6 +297,22 @@ yunohost service add $app --log "/var/log/$app/$app.log" # if using yunohost version 3.2 or more in the 'manifest.json', a description can be added #yunohost service add $app --description "$app daemon for XXX" --log "/var/log/$app/$app.log" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +### `ynh_systemd_action` is used to start a systemd service for an app. +### Only needed if you have configure a systemd service +### If you're not using these lines: +### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script +### - As well as the section "START SYSTEMD SERVICE" in the restore script +### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script +### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script + +# Start a systemd service +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + #================================================= # SETUP FAIL2BAN #================================================= diff --git a/scripts/restore b/scripts/restore index 0a0a24f..dd27696 100755 --- a/scripts/restore +++ b/scripts/restore @@ -121,6 +121,13 @@ systemctl enable $app.service yunohost service add $app --log "/var/log/$app/$app.log" +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + #================================================= # RESTORE THE CRON FILE #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b4380df..01781e8 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,6 +90,13 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # STANDARD UPGRADE STEPS +#================================================= +# STOP SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -190,6 +197,13 @@ then ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" fi +#================================================= +# START SYSTEMD SERVICE +#================================================= +ynh_script_progression --message="Starting a systemd service..." --time --weight=1 + +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + #================================================= # RELOAD NGINX #=================================================