restore 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. ynh_restore_file --origin_path="/var/lib/couchdb"
  7. # reinstall couchdb
  8. ynh_script_progression --message="Reinstalling couchdb..." --weight=40
  9. echo "\
  10. couchdb couchdb/mode select standalone
  11. couchdb couchdb/mode seen true
  12. couchdb couchdb/bindaddress string 127.0.0.1
  13. couchdb couchdb/bindaddress seen true
  14. couchdb couchdb/cookie string $couchdb_magic_cookie
  15. couchdb couchdb/adminpass password $password_couchdb_admin
  16. couchdb couchdb/adminpass seen true
  17. couchdb couchdb/adminpass_again password $password_couchdb_admin
  18. couchdb couchdb/adminpass_again seen true" | debconf-set-selections
  19. DEBIAN_FRONTEND=noninteractive # apt-get install -y --force-yes couchdb
  20. ynh_install_extra_app_dependencies \
  21. --repo="deb https://apache.jfrog.io/artifactory/couchdb-deb/ $(lsb_release -c -s) main" \
  22. --key="https://couchdb.apache.org/repo/keys.asc" \
  23. --package="couchdb"
  24. # stop couchdb
  25. systemctl stop couchdb
  26. # add couchdb configuration
  27. ynh_script_progression --message="Adding a configuration file..." --weight=2
  28. ynh_restore_file --origin_path="/opt/couchdb/etc/local.d/05-flohmarkt.ini"
  29. chown root:couchdb /opt/couchdb/etc/local.d/05-flohmarkt.ini
  30. chmod 640 /opt/couchdb/etc/local.d/05-flohmarkt.ini
  31. # start couchdb
  32. systemctl start couchdb
  33. systemctl status couchdb
  34. # RESTORE THE APP MAIN DIR
  35. ynh_script_progression --message="Restoring the app main directory..." --weight=10
  36. ynh_restore_file --origin_path="$install_dir"
  37. chmod -R 644 $install_dir
  38. chown -R root:$app $install_dir
  39. # RESTORE THE DATA DIRECTORY
  40. ynh_script_progression --message="Restoring the data directory..." --weight=1
  41. ynh_restore_file --origin_path="$data_dir" --not_mandatory
  42. mkdir -p $data_dir
  43. # RESTORE FAIL2BAN CONFIGURATION
  44. ynh_script_progression --message="Restoring the Fail2Ban configuration..." --weight=2
  45. ynh_restore_file --origin_path="/etc/fail2ban/jail.d/$app.conf"
  46. ynh_restore_file --origin_path="/etc/fail2ban/filter.d/$app.conf"
  47. ynh_systemd_action --action=restart --service_name=fail2ban
  48. # RESTORE THE NGINX CONFIGURATION
  49. ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1
  50. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
  51. # RESTORE THE LOGROTATE CONFIGURATION
  52. ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1
  53. ynh_restore_file --origin_path="/etc/logrotate.d/$app"
  54. # add some debugging to find #21
  55. ynh_exec_warn_less ls -lR /var/lib/couchdb /opt/couchdb/etc $install_dir /var/log/couchdb/couchdb.log \
  56. /var/log/$app/$app.log $data_dir /etc/nginx/conf.d/$domain.d/$app.conf
  57. ynh_exec_warn_less cat $install_dir/$app/flohmarkt.conf /opt/couchdb/etc/local.d/05-flohmarkt.ini
  58. ynh_exec_warn_less cat /var/log/couchdb/couchdb.log /var/log/$app/$app.log
  59. # INTEGRATE SERVICE IN YUNOHOST
  60. ynh_script_progression --message="Integrating service in YunoHost..." --weight=1
  61. ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
  62. yunohost service add $app --description="A decentral federated small advertisement platform" --log="/var/log/$app/$app.log"
  63. ynh_systemd_action --action=start --line_match="INFO: Application startup complete."
  64. # add some debugging to find #21
  65. ynh_exec_warn_less systemctl status flohmarkt
  66. ynh_exec_warn_less systemctl status couchdb
  67. # RELOAD NGINX
  68. ynh_script_progression --message="Reloading NGINX web server..." --weight=1
  69. ynh_systemd_action --service_name=nginx --action=reload
  70. # add some debugging to find #21
  71. ynh_exec_warn_less ps axuf
  72. ynh_exec_warn_less netstat -pnlt
  73. ynh_script_progression --message="Restoration completed for $app" --last