v-add-domain 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #!/bin/bash
  2. # info: add web/dns/mail domain
  3. # options: USER DOMAIN [IP] [RESTART]
  4. #
  5. # The function adds web/dns/mail domain to a server.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. user=$1
  11. domain=$2
  12. ip=$3
  13. restart="${4-yes}"
  14. # Includes
  15. source $VESTA/func/main.sh
  16. source $VESTA/func/ip.sh
  17. source $VESTA/conf/vesta.conf
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '2' "$#" 'USER DOMAIN [IP] [RESTART]'
  22. is_format_valid 'user' 'domain'
  23. if [ ! -z "$ip" ] ; then
  24. is_format_valid 'ip'
  25. fi
  26. is_object_valid 'user' 'USER' "$user"
  27. is_object_unsuspended 'user' 'USER' "$user"
  28. #----------------------------------------------------------#
  29. # Action #
  30. #----------------------------------------------------------#
  31. # Get ip if it wasn't defined
  32. if [ -z "$ip" ]; then
  33. get_user_ip
  34. if [ -z "$ip" ]; then
  35. check_result $E_NOTEXIST "no avaiable IP address"
  36. fi
  37. fi
  38. # Working on web domain
  39. if [ ! -z "$WEB_SYSTEM" ]; then
  40. $BIN/v-add-web-domain $user $domain $ip 'no'
  41. check_result $? "can't add web domain" >/dev/null
  42. fi
  43. # Working on DNS domain
  44. if [ ! -z "$DNS_SYSTEM" ]; then
  45. $BIN/v-add-dns-domain $user $domain $ip "" "" "" "" "" '' '' '' 'no'
  46. check_result $? "can't add dns domain" >/dev/null
  47. fi
  48. # Working on mail domain
  49. if [ ! -z "$MAIL_SYSTEM" ]; then
  50. $BIN/v-add-mail-domain $user $domain
  51. check_result $? "can't add mail domain" >/dev/null
  52. fi
  53. # Restarting services
  54. if [ "$restart" != 'no' ]; then
  55. $BIN/v-restart-web
  56. check_result $? "can't restart web" > /dev/null
  57. if [ ! -z "$PROXY_SYSTEM" ]; then
  58. $BIN/v-restart-proxy
  59. check_result $? "can't restart proxy" > /dev/null
  60. fi
  61. $BIN/v-restart-dns
  62. check_result $? "can't restart dns" > /dev/null
  63. fi
  64. #----------------------------------------------------------#
  65. # Vesta #
  66. #----------------------------------------------------------#
  67. exit