remove 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. #=================================================
  3. # IMPORT GENERIC HELPERS
  4. #=================================================
  5. source _common.sh
  6. source /usr/share/yunohost/helpers
  7. #=================================================
  8. # REMOVE SYSTEM CONFIGURATIONS
  9. #=================================================
  10. ynh_script_progression --message="Removing system configurations related to $app..." --weight=1
  11. # Remove the dedicated systemd config
  12. ynh_systemd_action --service_name="$app-server" --action="stop" --log_path="/var/log/$app/${app}_server.log"
  13. ynh_systemd_action --service_name="$app-agent" --action="stop" --log_path="/var/log/$app/${app}_agent.log"
  14. systemctl disable zabbix-server --quiet
  15. systemctl disable zabbix-agent --quiet
  16. ynh_exec_warn_less killall zabbix_server
  17. ynh_exec_warn_less killall zabbix_agentd
  18. yunohost service remove snmpd
  19. yunohost service remove zabbix-server
  20. yunohost service remove zabbix-agent
  21. # Remove the dedicated NGINX config
  22. ynh_remove_nginx_config
  23. # Remove the dedicated PHP-FPM config
  24. ynh_remove_fpm_config
  25. #=================================================
  26. # REMOVE DEPENDENCIES
  27. #=================================================
  28. ynh_script_progression --message="Removing $app's configuration..."
  29. # Remove config file detection
  30. delete_initZabbixConf
  31. ynh_secure_remove --file="/usr/share/$app"
  32. #=================================================
  33. # REMOVE VARIOUS FILES
  34. #=================================================
  35. ynh_script_progression --message="Removing various files..."
  36. # Remove a directory securely
  37. ynh_secure_remove --file="/etc/$app"
  38. # Remove the log files
  39. ynh_secure_remove --file="/var/log/$app"
  40. ynh_secure_remove --file="/run/$app"
  41. ynh_secure_remove --file="/etc/sudoers.d/$app"
  42. # FIXME: useless?
  43. # REMOVE NONFREE PART PATCH IF NEEDED (snmp-mibs-downloader (non-free) installed in version 1)
  44. nonfreepackagelist=$(dpkg-query -W -f='${Section}\t${Package}\n' | grep ^non-free)
  45. if [ "$(echo $nonfreepackagelist | wc -l)" -eq 1 ] && [ "$(echo $nonfreepackagelist | grep -c "snmp-mibs-downloader")" -eq 1 ]; then
  46. ynh_print_info --message="Removing snmp-mibs-downloader (non-free package)"
  47. cp /var/lib/dpkg/status{,.$(date "+%m%d%y")}
  48. ynh_replace_string --match_string=" snmp-mibs-downloader," --replace_string="" --target_file=/var/lib/dpkg/status
  49. DEBIAN_FRONTEND=noninteractive apt purge snmp-mibs-downloader -y
  50. if [ -f /etc/apt/sources.list.d/non-free.list ]; then
  51. ynh_secure_remove --file="/etc/apt/sources.list.d/non-free.list"
  52. fi
  53. fi
  54. #=================================================
  55. # END OF SCRIPT
  56. #=================================================
  57. ynh_script_progression --message="Removal of $app completed"