restore 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/bash
  2. source ../settings/scripts/_common.sh
  3. source /usr/share/yunohost/helpers
  4. # RESTORE THE APP MAIN DIR
  5. ynh_script_progression --message="Restoring the app main directory..." --weight=10
  6. ynh_restore_file --origin_path="$install_dir"
  7. # RESTORE THE DATA DIRECTORY
  8. ynh_script_progression --message="Restoring the data directory..." --weight=1
  9. ynh_restore_file --origin_path="$data_dir" --not_mandatory
  10. mkdir -p $data_dir
  11. # RESTORE FAIL2BAN CONFIGURATION
  12. ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2
  13. ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
  14. ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
  15. ynh_systemd_action --action=restart --service_name=fail2ban
  16. # RESTORE THE NGINX CONFIGURATION
  17. ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
  18. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  19. # REINSTALL COUCHDB
  20. ynh_script_progression --message="Reinstalling couchdb..." --weight=40
  21. echo "\
  22. couchdb couchdb/mode select standalone
  23. couchdb couchdb/mode seen true
  24. couchdb couchdb/bindaddress string 127.0.0.1
  25. couchdb couchdb/bindaddress seen true
  26. couchdb couchdb/cookie string $couchdb_magic_cookie
  27. couchdb couchdb/adminpass password $password_couchdb_admin
  28. couchdb couchdb/adminpass seen true
  29. couchdb couchdb/adminpass_again password $password_couchdb_admin
  30. couchdb couchdb/adminpass_again seen true" | debconf-set-selections
  31. DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
  32. ynh_install_extra_app_dependencies \
  33. --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
  34. --key="https://couchdb.apache.org/repo/keys.asc" \
  35. --package="couchdb"
  36. # stop couchdb
  37. systemctl stop couchdb
  38. # add couchdb configuration
  39. ynh_script_progression --message="Adding a configuration file..." --weight=2
  40. ynh_restore_file --origin_path="/opt/couchdb/etc/local.d/05-flohmarkt.ini"
  41. chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
  42. chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
  43. # restore couchdb directory
  44. ynh_script_progression --message="Restoring couchdb directory..." --weight=1
  45. ynh_restore_file --origin_path="/var/lib/couchdb"
  46. # start couchdb
  47. systemctl start couchdb
  48. systemctl status couchdb
  49. # RESTORE THE LOGROTATE CONFIGURATION
  50. ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
  51. ynh_restore_file --origin_path="/etc/logrotate.d/$app"
  52. # INTEGRATE SERVICE IN YUNOHOST
  53. ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
  54. yunohost service add $app --description="A decentral federated small advertisement platform" --log="/var/log/$app/$app.log"
  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