remove 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC STARTING
  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. #=================================================
  16. # STANDARD REMOVE
  17. #=================================================
  18. # DISABLE SERVICE IN ADMIN PANEL
  19. #=================================================
  20. if yunohost service status | grep -q pihole-FTL # Test l'existence du service dans Yunohost
  21. then
  22. ynh_print_info "Remove pihole-FTL service" >&2
  23. yunohost service remove pihole-FTL
  24. fi
  25. #=================================================
  26. # STOP THE SERVICE PIHOLE-FTL
  27. #=================================================
  28. ynh_systemd_action --action=stop --service_name=pihole-FTL
  29. ynh_exec_warn_less systemctl disable pihole-FTL
  30. rm -f "/etc/init.d/pihole-FTL" "/usr/bin/pihole-FTL" "/var/run/pihole-FTL.pid" "/var/run/pihole-FTL.port"
  31. #=================================================
  32. # REMOVE DEPENDENCIES
  33. #=================================================
  34. ynh_remove_app_dependencies
  35. #=================================================
  36. # REMOVE THE DIRECTORIES OF THE APP
  37. #=================================================
  38. ynh_secure_remove "/etc/pihole" # Suppression du dossier de stockage l'application
  39. ynh_secure_remove "/opt/pihole" # Suppression du dossier l'application
  40. ynh_secure_remove "/var/www/pihole" # Suppression de l'interface de l'application
  41. ynh_secure_remove "/etc/.pihole" # Suppression du clone local du dépôt
  42. #=================================================
  43. # REMOVE THE NGINX CONFIGURATION
  44. #=================================================
  45. ynh_remove_nginx_config # Suppression de la configuration nginx
  46. #=================================================
  47. # REMOVE THE PHP-FPM CONFIGURATION
  48. #=================================================
  49. ynh_remove_fpm_config # Suppression de la configuration du pool php-fpm
  50. #=================================================
  51. # CLOSE A PORT
  52. #=================================================
  53. if yunohost firewall list | grep -q "\- $port$"
  54. then
  55. ynh_print_info "Close port $port" >&2
  56. ynh_exec_quiet yunohost firewall disallow TCP $port
  57. fi
  58. if yunohost firewall list | grep -q "\- 67$"
  59. then
  60. ynh_print_info "Close port 67" >&2
  61. ynh_exec_quiet yunohost firewall disallow UDP 67
  62. fi
  63. #=================================================
  64. # SPECIFIC REMOVE
  65. #=================================================
  66. # REMOVE THE CRON FILE
  67. #=================================================
  68. ynh_secure_remove "/etc/cron.d/pihole"
  69. #=================================================
  70. # REMOVE OTHER FILES
  71. #=================================================
  72. # Suppression des log
  73. ynh_secure_remove "/var/log/pihole.log"
  74. ynh_secure_remove "/var/log/pihole-FTL.log"
  75. # Remove the main script
  76. ynh_secure_remove "/usr/local/bin/pihole"
  77. ynh_secure_remove "/etc/bash_completion.d/pihole"
  78. # Remove the sudoer file
  79. ynh_secure_remove "/etc/sudoers.d/pihole"
  80. #=================================================
  81. # REMOVE THE DNSMASQ CONFIG
  82. #=================================================
  83. ynh_systemd_action --action=stop --service_name=dnsmasq
  84. rm -f "/etc/dnsmasq.d/01-pihole.conf"
  85. rm -f "/etc/dnsmasq.d/02-pihole-dhcp.conf"
  86. rm -f "/etc/dnsmasq.d/03-pihole-wildcard.conf"
  87. rm -f "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
  88. ynh_replace_string "#pihole# " "" /etc/dnsmasq.conf
  89. #=================================================
  90. # CLEAN /etc/hosts
  91. #=================================================
  92. # Restaure les résolutions qui avaient été commentées par pihole
  93. sed -i "s/#Commented by pihole# //g" /etc/hosts
  94. # Et supprime les lignes ajoutées par pihole
  95. sed -i "/#Added by pihole#/d" /etc/hosts
  96. #=================================================
  97. # RESTART DNSMASQ
  98. #=================================================
  99. ynh_systemd_action --action=restart --service_name=dnsmasq
  100. #=================================================
  101. # REMOVE THE CONF_REGEN HOOK
  102. #=================================================
  103. ynh_secure_remove /usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app
  104. #=================================================
  105. # GENERIC FINALISATION
  106. #=================================================
  107. # REMOVE DEDICATED USER
  108. #=================================================
  109. ynh_system_user_delete $app