v-delete-fastcgi-cache 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. # info: Remove FastCGI nginx support
  3. # options: USER DOMAIN [RESTART]
  4. # labels: hestia web
  5. #
  6. # example: v-delete-fastcgi-cache user domain.tld
  7. #
  8. # The function enables FastCGI cache for nginx
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Argument definition
  13. user=$1
  14. domain=$2
  15. restart=$3
  16. # Includes
  17. source $HESTIA/func/main.sh
  18. source $HESTIA/conf/hestia.conf
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '2' "$#" 'USER DOMAIN'
  23. is_format_valid 'user' 'domain'
  24. is_object_valid 'user' 'USER' "$user"
  25. is_object_valid 'web' 'DOMAIN' "$domain"
  26. is_object_valid 'web' 'DOMAIN' "$domain" "$FASTCGI_CACHE"
  27. # Perform verification if read-only mode is enabled
  28. check_hestia_demo_mode
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Load domain data
  33. parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
  34. # Remove FastCGI cache configuration
  35. if [ -f $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf ]; then
  36. rm -rf $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf
  37. fi
  38. conf='/etc/nginx/conf.d/fastcgi_cache_pool.conf'
  39. if [ -f "$conf" ]; then
  40. sed -i "/fastcgi_cache $domain;/d" $conf
  41. if [ ! -s "$conf" ]; then
  42. rm -rf $conf
  43. fi
  44. fi
  45. # Delete FastCGI cache folder
  46. if [ -d /var/cache/nginx/micro/$domain ]; then
  47. rm -rf /var/cache/nginx/micro/$domain
  48. fi
  49. #----------------------------------------------------------#
  50. # Hestia #
  51. #----------------------------------------------------------#
  52. if [ -z "$FASTCGI_CACHE" ]; then
  53. add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
  54. fi
  55. # Set FASTCGI flag to disabled
  56. update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' ''
  57. # Restart web server
  58. if [ ! -z "$restart" ]; then
  59. $BIN/v-restart-web
  60. check_result $? "Web server restart failed" > /dev/null
  61. fi
  62. # Logging
  63. log_history "Disabled FastCGI cache for $domain"
  64. log_event "$OK" "$ARGUMENTS"
  65. exit