remove 3.1 KB

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