remove 3.2 KB

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