v-change-user-template 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # info: change user default template
  3. # options: USER TYPE TEMPLATE
  4. #
  5. # The function changes default user web template.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. type=$(echo "$2" | tr '[:lower:]' '[:upper:]')
  12. template=$3
  13. # Includes
  14. source $VESTA/func/main.sh
  15. source $VESTA/func/domain.sh
  16. source $VESTA/conf/vesta.conf
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. check_args '3' "$#" 'USER TYPE TEMPLATE'
  21. is_format_valid 'user' 'template'
  22. is_object_valid 'user' 'USER' "$user"
  23. is_object_unsuspended 'user' 'USER' "$user"
  24. #----------------------------------------------------------#
  25. # Action #
  26. #----------------------------------------------------------#
  27. case $type in
  28. WEB) is_web_template_valid $template;
  29. update_user_value "$user" '$WEB_TEMPLATE' "$template";;
  30. PROXY) is_proxy_template_valid $template;
  31. update_user_value "$user" '$PROXY_TEMPLATE' "$template";;
  32. DNS) is_dns_template_valid $template;
  33. update_user_value "$user" '$DNS_TEMPLATE' "$template";;
  34. *) check_args '1' '0' 'USER TYPE TEMPLATE'
  35. esac
  36. #----------------------------------------------------------#
  37. # Vesta #
  38. #----------------------------------------------------------#
  39. # Logging
  40. log_history "changed $type template to $template"
  41. log_event "$OK" "$ARGUMENTS"
  42. exit