v-delete-web-domain-fast-cgi-cache 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # info: remove fast cgi nginx support
  3. # options: USER DOMAIN [RESTART]
  4. # labels: hestia web
  5. #
  6. # example: v-delete-web-domain-fast-cgi-cache user domain.tld
  7. #
  8. # The function removes fast cgi cache.
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Argument definition
  13. user=$1
  14. domain=$(idn -t --quiet -a "$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 fast cgi configs
  35. if [ -f $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf ]; then
  36. rm -f $HOMEDIR/$user/conf/web/$domain/$WEB_SYSTEM.fastcgi_cache.conf
  37. fi
  38. # Delete cache folder on disabling
  39. if [ -d /var/cache/nginx/php-fpm/$domain ]; then
  40. rm -rf /var/cache/nginx/php-fpm/$domain
  41. fi
  42. #----------------------------------------------------------#
  43. # Hestia #
  44. #----------------------------------------------------------#
  45. if [ -z "$FASTCGI_CACHE" ]; then
  46. add_object_key "web" 'DOMAIN' "$domain" 'FASTCGI_CACHE' 'ALIAS'
  47. fi
  48. # Set FASTCGI flag to disabled
  49. update_object_value 'web' 'DOMAIN' "$domain" '$FASTCGI_CACHE' ''
  50. # Restart services if requested
  51. if [ ! -z "$restart" ]; then
  52. $BIN/v-restart-web
  53. check_result $? "Web restart failed" >/dev/null
  54. fi
  55. # Logging
  56. log_history "disabled fast cgi support for $domain"
  57. log_event "$OK" "$ARGUMENTS"
  58. exit