remove 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #=================================================
  17. # STANDARD REMOVE
  18. #=================================================
  19. # STOP AND REMOVE SERVICE
  20. #=================================================
  21. # Remove the dedicated systemd config
  22. ynh_remove_systemd_config
  23. #=================================================
  24. # REMOVE SERVICE FROM ADMIN PANEL
  25. #=================================================
  26. if sudo yunohost service status | grep -q $app
  27. then
  28. echo "Remove $app service"
  29. sudo yunohost service remove $app
  30. fi
  31. #=================================================
  32. # REMOVE DEPENDENCIES
  33. #=================================================
  34. # Remove metapackage and its dependencies
  35. ynh_remove_app_dependencies
  36. #=================================================
  37. # REMOVE THE MYSQL DATABASE
  38. #=================================================
  39. # Remove a database if it exists, along with the associated user
  40. ynh_mysql_remove_db $db_name $db_name
  41. #=================================================
  42. # REMOVE APP MAIN DIR
  43. #=================================================
  44. # Remove the app directory securely
  45. ynh_secure_remove "/var/www/$app"
  46. #=================================================
  47. # REMOVE NGINX CONFIGURATION
  48. #=================================================
  49. # Remove the dedicated nginx config
  50. ynh_remove_nginx_config
  51. #=================================================
  52. # REMOVE PHP-FPM CONFIGURATION
  53. #=================================================
  54. # Remove the dedicated php-fpm config
  55. ynh_remove_fpm_config
  56. #=================================================
  57. # REMOVE LOGROTATE CONFIGURATION
  58. #=================================================
  59. # Remove the app-specific logrotate config
  60. ynh_remove_logrotate
  61. #=================================================
  62. # CLOSE A PORT
  63. #=================================================
  64. if sudo yunohost firewall list | grep -q "\- $port$"
  65. then
  66. echo "Close port $port"
  67. QUIET sudo yunohost firewall disallow TCP $port
  68. fi
  69. #=================================================
  70. # SPECIFIC REMOVE
  71. #=================================================
  72. # REMOVE THE CRON FILE
  73. #=================================================
  74. # Remove a cron file
  75. ynh_secure_remove "/etc/cron.d/$app"
  76. # Remove a directory securely
  77. ynh_secure_remove "/etc/$app/"
  78. # Remove the log files
  79. ynh_secure_remove "/var/log/$app/"
  80. #=================================================
  81. # GENERIC FINALIZATION
  82. #=================================================
  83. # REMOVE DEDICATED USER
  84. #=================================================
  85. # Delete a system user
  86. ynh_system_user_delete $app