restore 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. echo "\
  11. couchdb couchdb/mode select standalone
  12. couchdb couchdb/mode seen true
  13. couchdb couchdb/bindaddress string 127.0.0.1
  14. couchdb couchdb/bindaddress seen true
  15. couchdb couchdb/cookie string $couchdb_magic_cookie
  16. couchdb couchdb/adminpass password $password_couchdb_admin
  17. couchdb couchdb/adminpass seen true
  18. couchdb couchdb/adminpass_again password $password_couchdb_admin
  19. couchdb couchdb/adminpass_again seen true" | debconf-set-selections
  20. DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
  21. ynh_install_extra_app_dependencies \
  22. --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
  23. --key="https://couchdb.apache.org/repo/keys.asc" \
  24. --package="couchdb"
  25. # stop couchdb
  26. systemctl stop couchdb
  27. # add couchdb configuration
  28. ynh_script_progression --message="Adding a configuration file..." --weight=2
  29. ynh_restore_file --origin_path="/opt/couchdb/etc/local.d/05-flohmarkt.ini"
  30. chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
  31. chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
  32. # start couchdb
  33. systemctl start couchdb
  34. systemctl status couchdb
  35. # RESTORE THE APP MAIN DIR
  36. ynh_script_progression --message="Restoring the app main directory..." --weight=10
  37. ynh_restore_file --origin_path="$flohmarkt_install"
  38. # RESTORE THE DATA DIRECTORY
  39. ynh_script_progression --message="Restoring the data directory..." --weight=1
  40. ynh_restore_file --origin_path="$flohmarkt_data_dir=" --not_mandatory
  41. mkdir -p $data_dir
  42. # restore logfiles
  43. # independent of the question whether one wants the logfiles in a backup (as you can
  44. # see I decided I wanted them for the time being) it is important to create the log
  45. # directory and file so that the systemd.service can redirect STDOUT to the file.
  46. # If the logfile(or maybe just -directory?) is missing the service will not start
  47. # on a fresh install, because directory and/or file do not exist.
  48. ynh_script_progression --message="Restoring log directory and logfiles..." --weight=1
  49. ynh_restore_file --origin_path="$flohmarkt_log_dir" --not_mandatory
  50. mkdir -p -m755 "$flohmarkt_log_dir"
  51. touch "$flohmarkt_logfile"
  52. # logfile contains possibly the secret setup URL
  53. chmod 640 "$flohmarkt_logfile"
  54. # RESTORE FAIL2BAN CONFIGURATION
  55. ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2
  56. ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
  57. ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
  58. ynh_systemd_action --action=restart --service_name=fail2ban
  59. # RESTORE THE NGINX CONFIGURATION
  60. ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
  61. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  62. # RESTORE THE LOGROTATE CONFIGURATION
  63. ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
  64. ynh_restore_file --origin_path="/etc/logrotate.d/$app"
  65. # restore flohmarkt systemd service and integrate service into yunohost
  66. ynh_script_progression --message="Restoring flohmarkt.service and integrating service into YunoHost..." --weight=1
  67. ynh_restore_file --origin_path="/etc/systemd/system/$flohmarkt_filename.service"
  68. ynh_systemd_action --action=enable --service_name=$flohmarkt_filename
  69. yunohost service add $app --description="A decentral federated small advertisement platform" --log="$flohmarkt_logfile"
  70. flohmarkt_ynh_start_service
  71. # RELOAD NGINX
  72. ynh_script_progression --message="Reloading NGINX web server..." --weight=1
  73. ynh_systemd_action --service_name=nginx --action=reload
  74. ynh_script_progression --message="Restoration completed for $app" --last