remove 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/bin/bash
  2. # Wifi Hotspot app for YunoHost
  3. # Copyright (C) 2015 Julien Vaubourg <julien@vaubourg.com>
  4. # Contribute at https://github.com/labriqueinternet/hotspot_ynh
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU Affero General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU Affero General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU Affero General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. #=================================================
  19. # GENERIC START
  20. #=================================================
  21. # IMPORT GENERIC HELPERS
  22. #=================================================
  23. source _common.sh
  24. source /usr/share/yunohost/helpers
  25. #=================================================
  26. # LOAD SETTINGS
  27. #=================================================
  28. ynh_script_progression --message="Loading installation settings..."
  29. app=$YNH_APP_INSTANCE_NAME
  30. firmware_nonfree=$(ynh_app_setting_get --app=$app --key=firmware_nonfree)
  31. service_name=$(ynh_app_setting_get --app=$app --key=service_name)
  32. #=================================================
  33. # STANDARD REMOVE
  34. #=================================================
  35. # REMOVE SERVICE INTEGRATION IN YUNOHOST
  36. #=================================================
  37. # Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
  38. if yunohost service status $service_name >/dev/null 2>&1
  39. then
  40. ynh_script_progression --message="Removing $app service"
  41. yunohost service stop $service_name
  42. yunohost service remove $service_name
  43. fi
  44. #=================================================
  45. # STOP AND REMOVE SERVICE
  46. #=================================================
  47. ynh_script_progression --message="Stopping and removing the systemd service..."
  48. # Remove the dedicated systemd config
  49. ynh_remove_systemd_config --service=$service_name
  50. #=================================================
  51. # REMOVE DEPENDENCIES
  52. #=================================================
  53. ynh_script_progression --message="Removing dependencies..."
  54. # Remove metapackage and its dependencies
  55. ynh_remove_app_dependencies
  56. #=================================================
  57. # REMOVE APP MAIN DIR
  58. #=================================================
  59. ynh_script_progression --message="Removing app main directory..."
  60. # Remove the app directory securely
  61. ynh_secure_remove --file="/usr/local/bin/$service_name"
  62. ynh_secure_remove --file="/usr/local/bin/iw_multissid"
  63. ynh_secure_remove --file="/usr/local/bin/iw_devices"
  64. ynh_secure_remove --file="/usr/local/bin/iw_ssids"
  65. ynh_secure_remove --file="/usr/local/bin/ipv6_expanded"
  66. ynh_secure_remove --file="/usr/local/bin/ipv6_compressed"
  67. ynh_secure_remove --file="/etc/sudoers.d/${app}_ynh"
  68. for FILE in $(ls /tmp/.ynh-hotspot-* 2>/dev/null)
  69. do
  70. ynh_secure_remove --file="$FILE"
  71. done
  72. # Remove confs
  73. ynh_secure_remove --file="/etc/dnsmasq.dhcpd/dhcpdv6.conf.tpl"
  74. ynh_secure_remove --file="/etc/dnsmasq.dhcpd/dhcpdv4.conf.tpl"
  75. for FILE in $(ls /etc/hostapd/hostapd.conf{.tpl?,} 2>/dev/null)
  76. do
  77. ynh_secure_remove --file="$FILE"
  78. done
  79. #=================================================
  80. # CLOSE A PORT
  81. #=================================================
  82. if yunohost firewall list | grep -q "\- 547$"
  83. then
  84. ynh_script_progression --message="Closing port 547"
  85. ynh_exec_warn_less yunohost firewall disallow TCP 547
  86. fi
  87. if yunohost firewall list | grep -q "\- 67$"
  88. then
  89. ynh_script_progression --message="Closing port 67"
  90. ynh_exec_warn_less yunohost firewall disallow TCP 67
  91. fi
  92. #=================================================
  93. # REMOVE LEGACY INTERFACES
  94. #=================================================
  95. if [ -d /etc/nginx/conf.d/*.d/$app.conf ]; then
  96. ynh_secure_remove /etc/nginx/conf.d/*.d/$app.conf
  97. fi
  98. if [ -d /etc/php/*/fpm/pool.d/$app.conf ]; then
  99. ynh_secure_remove /etc/php/*/fpm/pool.d/$app.conf
  100. fi
  101. if [ -d /var/www/$app ]; then
  102. ynh_secure_remove /var/www/$app
  103. fi
  104. #=================================================
  105. # GENERIC FINALIZATION
  106. #=================================================
  107. # REMOVE DEDICATED USER
  108. #=================================================
  109. ynh_script_progression --message="Removing the dedicated system user..."
  110. # Delete a system user
  111. ynh_system_user_delete --username=$app
  112. #=================================================
  113. # END OF SCRIPT
  114. #=================================================
  115. ynh_script_progression --message="Removal of $app completed"