remove 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. # LOAD SETTINGS
  11. #=================================================
  12. app=$YNH_APP_INSTANCE_NAME
  13. domain=$(ynh_app_setting_get $app domain)
  14. port=$(ynh_app_setting_get $app port)
  15. db_name=$(ynh_app_setting_get $app db_name)
  16. db_user=$db_name
  17. final_path=$(ynh_app_setting_get $app final_path)
  18. #=================================================
  19. # STANDARD REMOVE
  20. #=================================================
  21. # STOP AND REMOVE SERVICE
  22. #=================================================
  23. # Remove the dedicated systemd config
  24. ynh_remove_systemd_config
  25. yunohost service remove snmpd
  26. #=================================================
  27. # REMOVE SERVICE FROM ADMIN PANEL
  28. #=================================================
  29. # Remove a service from the admin panel, added by `yunohost service add`
  30. if yunohost service status | grep -q $app
  31. then
  32. echo "Remove $app service"
  33. yunohost service remove $app
  34. fi
  35. #=================================================
  36. # REMOVE PHP-FPM CONFIGURATION
  37. #=================================================
  38. # Remove the dedicated php-fpm config
  39. ynh_remove_fpm_config
  40. systemctl reload php7.0-fpm
  41. #=================================================
  42. # REMOVE DEPENDENCIES
  43. #=================================================
  44. # Remove metapackage and its dependencies
  45. #ynh_remove_app_dependencies
  46. timeout 5 systemctl stop zabbix-server || killall zabbix_server
  47. systemctl disable zabbix-server
  48. killall zabbix_server
  49. timeout 5 systemctl stop zabbix-agent || killall zabbix_agentd
  50. systemctl disable zabbix-agent
  51. ynh_package_autopurge --allow-change-held-packages zabbix-server-mysql zabbix-frontend-php zabbix-release zabbix-ynh-deps zabbix-agent
  52. #remove symlink
  53. rm /var/www/zabbix
  54. #=================================================
  55. # REMOVE THE MYSQL DATABASE
  56. #=================================================
  57. # Remove a database if it exists, along with the associated user
  58. ynh_mysql_remove_db $db_user $db_name
  59. #=================================================
  60. # REMOVE NGINX CONFIGURATION
  61. #=================================================
  62. # Remove the dedicated nginx config
  63. ynh_remove_nginx_config
  64. #=================================================
  65. # RELOAD NGINX
  66. #=================================================
  67. systemctl reload nginx
  68. #=================================================
  69. # REMOVE LOGROTATE CONFIGURATION
  70. #=================================================
  71. # Remove the app-specific logrotate config
  72. ynh_remove_logrotate
  73. #=================================================
  74. # CLOSE A PORT
  75. #=================================================
  76. if yunohost firewall list | grep -q "\- $port$"
  77. then
  78. echo "Close port $port" >&2
  79. yunohost firewall disallow TCP $port 2>&1
  80. fi
  81. #=================================================
  82. # SPECIFIC REMOVE
  83. #=================================================
  84. # REMOVE THE CRON FILE
  85. #=================================================
  86. # Remove a directory securely
  87. ynh_secure_remove "/etc/zabbix"
  88. # Remove the log files
  89. ynh_secure_remove "/var/log/zabbix"
  90. # Remove the pid/socket files
  91. ynh_secure_remove "/run/zabbix"
  92. # Remove the sudoers file
  93. ynh_secure_remove "/etc/sudoers.d/zabbix"
  94. #=================================================
  95. # GENERIC FINALIZATION
  96. #=================================================
  97. # REMOVE DEDICATED USER
  98. #=================================================
  99. # Delete a system user
  100. ynh_system_user_delete zabbix