restore 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. source ../settings/scripts/_common.sh
  3. source /usr/share/yunohost/helpers
  4. # restore couchdb directory
  5. ynh_script_progression --message="Restoring couchdb directory..." --weight=1
  6. # argh, need this for a single database
  7. ynh_restore_file --origin_path="/var/lib/couchdb"
  8. # reinstall couchdb
  9. ynh_script_progression --message="Reinstalling couchdb..." --weight=40
  10. flohmarkt_ynh_up_inst_couchdb
  11. flohmarkt_ynh_stop_couchdb
  12. # add couchdb configuration
  13. ynh_script_progression --message="Adding a configuration file..." --weight=2
  14. ynh_restore_file --origin_path="/opt/couchdb/etc/local.d/05-flohmarkt.ini"
  15. chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
  16. chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
  17. # start couchdb
  18. flohmarkt_ynh_start_couchdb
  19. # RESTORE THE APP MAIN DIR
  20. ynh_script_progression --message="Restoring the app main directory..." --weight=10
  21. ynh_restore_file --origin_path="$flohmarkt_install"
  22. # RESTORE THE DATA DIRECTORY
  23. ynh_script_progression --message="Restoring the data directory..." --weight=1
  24. ynh_restore_file --origin_path="$flohmarkt_data_dir=" --not_mandatory
  25. mkdir -p $data_dir
  26. # restore logfiles
  27. # independent of the question whether one wants the logfiles in a backup (as you can
  28. # see I decided I wanted them for the time being) it is important to create the log
  29. # directory and file so that the systemd.service can redirect STDOUT to the file.
  30. # If the logfile(or maybe just -directory?) is missing the service will not start
  31. # on a fresh install, because directory and/or file do not exist.
  32. ynh_script_progression --message="Restoring log directory and logfiles..." --weight=1
  33. ynh_restore_file --origin_path="$flohmarkt_log_dir" --not_mandatory
  34. mkdir -p -m755 "$flohmarkt_log_dir"
  35. touch "$flohmarkt_logfile"
  36. # logfile contains possibly the secret setup URL
  37. chmod 640 "$flohmarkt_logfile"
  38. # RESTORE FAIL2BAN CONFIGURATION
  39. ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2
  40. ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
  41. ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
  42. ynh_systemd_action --action=restart --service_name=fail2ban
  43. # RESTORE THE NGINX CONFIGURATION
  44. ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
  45. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  46. # RESTORE THE LOGROTATE CONFIGURATION
  47. ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
  48. ynh_restore_file --origin_path="/etc/logrotate.d/$app"
  49. # restore flohmarkt systemd service and integrate service into yunohost
  50. ynh_script_progression --message="Restoring flohmarkt.service and integrating service into YunoHost..." --weight=1
  51. ynh_restore_file --origin_path="/etc/systemd/system/$flohmarkt_filename.service"
  52. ynh_systemd_action --action=enable --service_name=$flohmarkt_filename
  53. yunohost service add $app --description="A decentral federated small advertisement platform" --log="$flohmarkt_logfile"
  54. flohmarkt_ynh_start_service
  55. # RELOAD NGINX
  56. ynh_script_progression --message="Reloading NGINX web server..." --weight=1
  57. ynh_systemd_action --service_name=nginx --action=reload
  58. ynh_script_progression --message="Restoration completed for $app" --last