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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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
  7. #
  8. # Disallow other users to create a new subdomain.
  9. # eg: admin adds admin.com
  10. # user can't create user.admin.com
  11. #----------------------------------------------------------#
  12. # Variable&Function #
  13. #----------------------------------------------------------#
  14. # Argument definition
  15. user=$1
  16. domain=$2
  17. domain_idn=$2
  18. # Includes
  19. # shellcheck source=/usr/local/hestia/func/main.sh
  20. # shellcheck source=/usr/local/hestia/func/domain.sh
  21. # shellcheck source=/usr/local/hestia/conf/hestia.conf
  22. source $HESTIA/func/main.sh
  23. source $HESTIA/func/domain.sh
  24. source $HESTIA/func/ip.sh
  25. source $HESTIA/conf/hestia.conf
  26. # Additional argument formatting
  27. format_domain
  28. #----------------------------------------------------------#
  29. # Verifications #
  30. #----------------------------------------------------------#
  31. check_args '2' "$#" 'USER DOMAIN'
  32. is_format_valid 'user' 'domain'
  33. is_object_valid 'user' 'USER' "$user"
  34. is_object_unsuspended 'user' 'USER' "$user"
  35. is_object_valid 'web' 'DOMAIN' "$domain"
  36. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  37. # Perform verification if read-only mode is enabled
  38. check_hestia_demo_mode
  39. #----------------------------------------------------------#
  40. # Action #
  41. #----------------------------------------------------------#
  42. # Load domain data
  43. parse_object_kv_list $(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
  44. #----------------------------------------------------------#
  45. # Hestia #
  46. #----------------------------------------------------------#
  47. if [ -z "$ALLOW_USERS" ]; then
  48. add_object_key "web" 'DOMAIN' "$domain" 'ALLOW_USERS' 'TIME'
  49. fi
  50. # Adding new alias
  51. update_object_value 'web' 'DOMAIN' "$domain" '$ALLOW_USERS' "no"
  52. log_history "Allow users create subdomain for $domain"
  53. log_event "$OK" "$ARGUMENTS"
  54. exit