From 0a5473fb1c85d7e3f63166d6007aab8c71d406b1 Mon Sep 17 00:00:00 2001 From: Krakinou Date: Sat, 2 May 2020 15:01:20 +0200 Subject: [PATCH] update systemd start and stop --- .project | 17 +++++++++++++++++ scripts/backup | 5 +++-- scripts/change_url | 4 ++-- scripts/install | 3 +-- scripts/restore | 8 ++++++-- scripts/upgrade | 18 +++++++++++------- 6 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 .project diff --git a/.project b/.project new file mode 100644 index 0000000..0675d93 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + calibre_ynh + + + + + + org.python.pydev.PyDevBuilder + + + + + + org.python.pydev.pythonNature + + diff --git a/scripts/backup b/scripts/backup index bfd842f..e82f3c4 100755 --- a/scripts/backup +++ b/scripts/backup @@ -25,6 +25,7 @@ app=$YNH_APP_INSTANCE_NAME final_path=$(ynh_app_setting_get $app final_path) path_url=$(ynh_app_setting_get $app path) domain=$(ynh_app_setting_get $app domain) +port=$(ynh_app_setting_get $app port) #Get settings from database in case it has been changed in the app calibre_dir=$(sqlite3 $final_path/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1") @@ -90,8 +91,8 @@ ynh_backup --src_path="$calibre_dir" --is_big #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=5 -ynh_systemd_action --service_name=$app --action="start" -t 20 -sleep 2s +ynh_systemd_action --service_name=$app --action="start" -l "server on :$port" -t 20 + #================================================= # END OF SCRIPT diff --git a/scripts/change_url b/scripts/change_url index d813374..2702e74 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -119,8 +119,8 @@ fi #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name=$app --action="start" -t 20 -sleep 2s +ynh_systemd_action --service_name=$app --action="start" -l "server on :$port" -t 20 + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/install b/scripts/install index 735547d..dfafb9a 100755 --- a/scripts/install +++ b/scripts/install @@ -233,8 +233,7 @@ fi #================================================= ynh_script_progression --message="Reload nginx and start $app..." --weight=5 ynh_systemd_action --service_name=nginx --action=reload -ynh_systemd_action --service_name=$app --action=start -t 20 -sleep 2s +ynh_systemd_action --service_name=$app --action=start -l "server on :$port" -t 20 #================================================= # END OF SCRIPT diff --git a/scripts/restore b/scripts/restore index 46b2922..8cb9130 100755 --- a/scripts/restore +++ b/scripts/restore @@ -109,6 +109,11 @@ yunohost service add $app --description "Browse eBook in the web" --log "/var/lo ynh_restore_file --origin_path="/etc/logrotate.d/$app" +#================================================= +# RESTORE THE LOG FILE DIRECTORY +#================================================= +mkdir -p /var/log/$app +chown -R $app:$app /var/log/$app #================================================= # RESTORE THE DATA DIRECTORY @@ -160,8 +165,7 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name=$app --action="start" -t 20 -sleep 2s +ynh_systemd_action --service_name=$app --action="start" -l "server on :$port" -t 20 #================================================= # END OF SCRIPT diff --git a/scripts/upgrade b/scripts/upgrade index d49abd9..d2b04b3 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -93,10 +93,10 @@ if version_gt "0.6.6" $current_upstream_app_version && [ $current_upstream_packa pip install --no-cache-dir --upgrade --target $final_path/vendor -r $final_path/requirements.txt chown -R $app: $final_path #set database settings as per conf file : restart server so that app.db is regenerated - ynh_systemd_action + ynh_systemd_action --service_name=$app --action="start" -line_match="server on " --log_path=$final_path/calibre-web.log -t 20 #sleep required on low spec like raspberryPi sleep 5s - ynh_systemd_action -a stop + ynh_systemd_action --service_name=$app --action="stop" current_upstream_app_version="0.6.6" #remove unwanted entry in settings db fi @@ -164,10 +164,14 @@ ynh_script_progression --message="Update database..." --weight=1 ynh_backup_if_checksum_is_different "$final_path/app.db" #set database settings as per conf file : restart server so that app.db is regenerated, then add new ldap & log settings -ynh_systemd_action +if [ $current_upstream_app_version == '0.6.6' ] ; then + ynh_systemd_action --service_name=$app --action="start" -line_match="server on " --log_path=$final_path/calibre-web.log -t 20 +else + ynh_systemd_action --service_name=$app --action="start" -line_match="server on :$port" -t 20 +fi #sleep required on low spec like raspberryPi -sleep 5s -ynh_systemd_action -a stop +sleep 2s +ynh_systemd_action --service_name=$app --action="stop" conf="\"UPDATE settings SET $(. <(echo -E echo $(<../conf/init_calibre_db_settings))), $(. <(echo -E echo $(<../conf/init_calibre_db_ldap_settings))) WHERE ID=1\"" eval sqlite3 $final_path/app.db "$conf" @@ -232,8 +236,8 @@ ynh_systemd_action --service_name=nginx --action=reload #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=2 -ynh_systemd_action --service_name=$app --action="start" -t 20 -sleep 2s +ynh_systemd_action --service_name=$app --action="start" -l "server on :$port" -t 20 + #================================================= # END OF SCRIPT #=================================================