remove 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #=================================================
  26. # REMOVE SERVICE FROM ADMIN PANEL
  27. #=================================================
  28. # Remove a service from the admin panel, added by `yunohost service add`
  29. if yunohost service status | grep -q $app
  30. then
  31. echo "Remove $app service"
  32. yunohost service remove $app
  33. fi
  34. #=================================================
  35. # REMOVE DEPENDENCIES
  36. #=================================================
  37. # Remove metapackage and its dependencies
  38. #ynh_remove_app_dependencies
  39. timeout 5 systemctl stop zabbix-server
  40. systemctl disable zabbix-server
  41. killall zabbix_server
  42. rm -fr /etc/zabbix
  43. rm -fr /var/www/zabbix
  44. ynh_package_remove zabbix-release zabbix-server-mysql zabbix-frontend-php --allow-change-held-packages
  45. #=================================================
  46. # REMOVE THE MYSQL DATABASE
  47. #=================================================
  48. # Remove a database if it exists, along with the associated user
  49. ynh_mysql_remove_db $db_user $db_name
  50. #=================================================
  51. # REMOVE APP MAIN DIR
  52. #=================================================
  53. # Remove the app directory securely
  54. #ynh_secure_remove "$final_path"
  55. #=================================================
  56. # REMOVE NGINX CONFIGURATION
  57. #=================================================
  58. # Remove the dedicated nginx config
  59. ynh_remove_nginx_config
  60. #=================================================
  61. # REMOVE PHP-FPM CONFIGURATION
  62. #=================================================
  63. # Remove the dedicated php-fpm config
  64. ynh_remove_fpm_config
  65. #=================================================
  66. # REMOVE LOGROTATE CONFIGURATION
  67. #=================================================
  68. # Remove the app-specific logrotate config
  69. ynh_remove_logrotate
  70. #=================================================
  71. # CLOSE A PORT
  72. #=================================================
  73. if yunohost firewall list | grep -q "\- $port$"
  74. then
  75. echo "Close port $port" >&2
  76. yunohost firewall disallow TCP $port 2>&1
  77. fi
  78. #=================================================
  79. # SPECIFIC REMOVE
  80. #=================================================
  81. # REMOVE THE CRON FILE
  82. #=================================================
  83. # Remove a directory securely
  84. ynh_secure_remove "/etc/zabbix"
  85. # Remove the log files
  86. ynh_secure_remove "/var/log/zabbix"
  87. # Remove the pid/socket files
  88. ynh_secure_remove "/run/zabbix"
  89. #=================================================
  90. # GENERIC FINALIZATION
  91. #=================================================
  92. # REMOVE DEDICATED USER
  93. #=================================================
  94. # Delete a system user
  95. ynh_system_user_delete zabbix