remove 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source _common.sh
  8. source /usr/share/yunohost/helpers
  9. #=================================================
  10. # STANDARD REMOVE
  11. #=================================================
  12. # REMOVE SERVICE INTEGRATION IN YUNOHOST
  13. #=================================================
  14. ynh_script_progression --message="Removing system configurations related to $app..." --weight=5
  15. # Stop flohmarkt service
  16. ynh_script_progression --message="Stopping $app..." --weight=2
  17. yunohost service stop $flohmarkt_filename
  18. # Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
  19. if ynh_exec_warn_less yunohost service status $flohmarkt_filename >/dev/null
  20. then
  21. ynh_script_progression --message="Removing $app service integration..." --weight=2
  22. ynh_remove_systemd_config --service=$flohmarkt_filename
  23. fi
  24. # https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/12
  25. ynh_script_progression --message="Removing database and database user..." --weight=2
  26. # remove DB
  27. curl -s -X DELETE 'http://127.0.0.1:5984/flohmarkt' --user "admin:${password_couchdb_admin}"
  28. # remove DB user for this instance:
  29. # get rev for the user and then delete user/rev
  30. curl -s -X DELETE "http://127.0.0.1:5984/_users/org.couchdb.user%3A${app}?rev=$( curl -sX GET "http://127.0.0.1:5984/_users/org.couchdb.user%3A${app}" --user "admin:${password_couchdb_admin}" | jq -r ._rev)" --user "admin:${password_couchdb_admin}"
  31. # Remove the app-specific logrotate config
  32. ynh_remove_logrotate
  33. # remove logfiles directory
  34. # https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/29
  35. # can only remove a subdir or one file
  36. ynh_secure_remove --file="${flohmarkt_log_dir}"
  37. # Remove the dedicated NGINX config
  38. ynh_remove_nginx_config
  39. # Remove the dedicated Fail2Ban config
  40. ynh_remove_fail2ban_config
  41. # Remove home
  42. # https://codeberg.org/flohmarkt/flohmarkt_ynh/issues/29
  43. ynh_script_progression --message="Removing data directory..." --weight=2
  44. ynh_secure_remove --file=$data_dir
  45. # remove systemd service
  46. ynh_script_progression --message="Removing data directory..." --weight=2
  47. ynh_remove_systemd_config
  48. # remove symlinks
  49. ynh_secure_remove "$flohmarkt_sym_install"
  50. ynh_secure_remove "$flohmarkt_sym_data_dir"
  51. #=================================================
  52. # END OF SCRIPT
  53. #=================================================
  54. ynh_script_progression --message="Removal of $app completed" --last
  55. # debug
  56. ps -axf