Forráskód Böngészése

take care of logfile and -dir

backup, remove, restore
Chris Vogel 1 éve
szülő
commit
e405d5dc6d
4 módosított fájl, 19 hozzáadás és 2 törlés
  1. 1 0
      scripts/backup
  2. 2 0
      scripts/install
  3. 3 0
      scripts/remove
  4. 13 2
      scripts/restore

+ 1 - 0
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

+ 2 - 0
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"
 

+ 3 - 0
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
 

+ 13 - 2
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"