remove 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC STARTING
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source /usr/share/yunohost/helpers
  8. #=================================================
  9. # LOAD SETTINGS
  10. #=================================================
  11. app=$YNH_APP_INSTANCE_NAME
  12. domain=$(ynh_app_setting_get $app domain)
  13. port=$(ynh_app_setting_get $app port)
  14. db_name=$(ynh_app_setting_get $app db_name)
  15. #=================================================
  16. # STANDARD REMOVE
  17. #=================================================
  18. # STOP AND REMOVE SERVICE
  19. #=================================================
  20. # Remove the dedicated systemd config
  21. ynh_remove_systemd_config
  22. #=================================================
  23. # DISABLE SERVICE IN ADMIN PANEL
  24. #=================================================
  25. if sudo yunohost service status | grep -q $app
  26. then
  27. echo "Remove $app service"
  28. sudo yunohost service remove $app
  29. fi
  30. #=================================================
  31. # REMOVE DEPENDENCIES
  32. #=================================================
  33. # Remove fake package and its dependencies
  34. ynh_remove_app_dependencies
  35. #=================================================
  36. # REMOVE THE SQL BDD
  37. #=================================================
  38. # Remove a database if it exists, and the associated user
  39. ynh_mysql_remove_db $db_name $db_name
  40. #=================================================
  41. # REMOVE THE MAIN DIR OF THE APP
  42. #=================================================
  43. # Remove the app directory securely
  44. ynh_secure_remove "/var/www/$app"
  45. #=================================================
  46. # REMOVE THE NGINX CONFIGURATION
  47. #=================================================
  48. # Remove the dedicated nginx config
  49. ynh_remove_nginx_config
  50. #=================================================
  51. # REMOVE THE PHP-FPM CONFIGURATION
  52. #=================================================
  53. # Remove the dedicated php-fpm config
  54. ynh_remove_fpm_config
  55. #=================================================
  56. # REMOVE THE LOGROTATE CONFIG
  57. #=================================================
  58. # Remove the app's logrotate config.
  59. ynh_remove_logrotate
  60. #=================================================
  61. # CLOSE A PORT
  62. #=================================================
  63. if sudo yunohost firewall list | grep -q "\- $port$"
  64. then
  65. echo "Close port $port"
  66. QUIET sudo yunohost firewall disallow TCP $port
  67. fi
  68. #=================================================
  69. # SPECIFIC REMOVE
  70. #=================================================
  71. # REMOVE THE CRON FILE
  72. #=================================================
  73. # Remove a cron file
  74. ynh_secure_remove "/etc/cron.d/$app"
  75. # Remove a directory securely
  76. ynh_secure_remove "/etc/$app/"
  77. # Remove the log files
  78. ynh_secure_remove "/var/log/$app/"
  79. #=================================================
  80. # GENERIC FINALISATION
  81. #=================================================
  82. # REMOVE DEDICATED USER
  83. #=================================================
  84. # Delete a system user
  85. ynh_system_user_delete $app