diff --git a/scripts/backup b/scripts/backup index 4f6f509..9096902 100755 --- a/scripts/backup +++ b/scripts/backup @@ -11,6 +11,7 @@ ynh_backup --src_path="/etc/fail2ban/filter.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/opt/couchdb/etc/local.d/05-flohmarkt.ini" ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/var/log/$app" # for the following backups we'll want to stop flohmarkt and couchdb # to guarentee a consistant state diff --git a/scripts/install b/scripts/install index b9a971f..9198d61 100755 --- a/scripts/install +++ b/scripts/install @@ -114,6 +114,8 @@ ynh_add_systemd_config # integrate into yunohost ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 yunohost service add $app --description="A decentral federated small advertisement platform" --log="/var/log/$app/$app.log" +# logfile contains possibly the secret setup URL +chmod 640 "/var/log/$app/$app.log" # start service ynh_systemd_action --service_name=$app --action="start" diff --git a/scripts/remove b/scripts/remove index fafd669..9d71d4f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -46,6 +46,9 @@ ynh_secure_remove --file=/var/lib/couchdb # Remove the app-specific logrotate config ynh_remove_logrotate +# remove log directory +ynh_secure_remove --file="/var/log/$app/$app.log" + # Remove the dedicated NGINX config ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index a5b9f54..25c25be 100755 --- a/scripts/restore +++ b/scripts/restore @@ -43,14 +43,25 @@ systemctl status couchdb # RESTORE THE APP MAIN DIR ynh_script_progression --message="Restoring the app main directory..." --weight=10 ynh_restore_file --origin_path="$install_dir" -# chmod -R 644 $install_dir -# chown -R root:$app $install_dir # RESTORE THE DATA DIRECTORY ynh_script_progression --message="Restoring the data directory..." --weight=1 ynh_restore_file --origin_path="$data_dir" --not_mandatory mkdir -p $data_dir +# restore logfiles +# independent of the question whether one wants the logfiles in a backup (as you can +# see I decided I wanted them for the time being) it is important to create the log +# directory and file so that the systemd.service can redirect STDOUT to the file. +# If the logfile(or maybe just -directory?) is missing the service will not start +# on a fresh install, because directory and/or file do not exist. +ynh_script_progression --message="Restoring log directory and logfiles..." --weight=1 +ynh_restore_file --origin_path="/var/log/$app" --not_mandatory +mkdir -p -m755 "/var/log/$app" +touch "/var/log/$app/$app" +# logfile contains possibly the secret setup URL +chmod 640 "/var/log/$app/$app" + # RESTORE FAIL2BAN CONFIGURATION ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2 ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"