1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/flohmarkt_ynh.git synced 2024-09-03 18:36:30 +02:00

take care of logfile and -dir

backup, remove, restore
This commit is contained in:
Chris Vogel 2024-04-25 09:48:43 +02:00
parent fc7ac9e85e
commit e405d5dc6d
4 changed files with 19 additions and 2 deletions

View file

@ -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

View file

@ -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"

View file

@ -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

View file

@ -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"