v-delete-web-domain-allow-users 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. # info: disables other users create subdomains
  3. # options: USER DOMAIN
  4. # labels: web hestia
  5. #
  6. # example: v-delete-web-domain-allow-users admin admin.com
  7. #
  8. # Enable the rule check for Enforce subdomain ownership for a specific domain.
  9. # Enforce subdomain ownership setting in /edit/server/ set to no will always overwrite this behaviour
  10. # eg: admin adds admin.com
  11. # user can create user.admin.com
  12. #----------------------------------------------------------#
  13. # Variable&Function #
  14. #----------------------------------------------------------#
  15. # Argument definition
  16. user=$1
  17. domain=$2
  18. domain_idn=$2
  19. # Includes
  20. # shellcheck source=/usr/local/hestia/func/main.sh
  21. # shellcheck source=/usr/local/hestia/func/domain.sh
  22. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  23. source $HESTIA/func/main.sh
  24. source $HESTIA/func/domain.sh
  25. source $HESTIA/func/ip.sh
  26. source $HESTIA/conf/hestia.conf
  27. # Additional argument formatting
  28. format_domain
  29. #----------------------------------------------------------#
  30. # Verifications #
  31. #----------------------------------------------------------#
  32. check_args '2' "$#" 'USER DOMAIN'
  33. is_format_valid 'user' 'domain'
  34. is_object_valid 'user' 'USER' "$user"
  35. is_object_unsuspended 'user' 'USER' "$user"
  36. is_object_valid 'web' 'DOMAIN' "$domain"
  37. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  38. # Perform verification if read-only mode is enabled
  39. check_hestia_demo_mode
  40. #----------------------------------------------------------#
  41. # Action #
  42. #----------------------------------------------------------#
  43. # Load domain data
  44. parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
  45. #----------------------------------------------------------#
  46. # Hestia #
  47. #----------------------------------------------------------#
  48. if [ -z "$ALLOW_USERS" ]; then
  49. add_object_key "web" 'DOMAIN' "$domain" 'ALLOW_USERS' 'TIME'
  50. fi
  51. # Adding new alias
  52. update_object_value 'web' 'DOMAIN' "$domain" '$ALLOW_USERS' "no"
  53. log_history "Allow users create subdomain for $domain"
  54. log_event "$OK" "$ARGUMENTS"
  55. exit