remove 3.2 KB

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