v_del_web_domain_ssl 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/bash
  2. # info: deliting web domain ssl
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. user="$1"
  8. domain=$(idn -t --quiet -u "$2" )
  9. domain_idn=$(idn -t --quiet -a "$domain")
  10. # Importing variables
  11. source $VESTA/conf/vars.conf
  12. source $V_FUNC/shared_func.sh
  13. source $V_FUNC/domain_func.sh
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking arg number
  18. check_args '2' "$#" 'user domain'
  19. # Checking argument format
  20. format_validation 'user' 'domain'
  21. # Checking web system is enabled
  22. is_system_enabled 'web'
  23. # Checking user
  24. is_user_valid
  25. # Checking user is active
  26. is_user_suspended
  27. # Checking domain exist
  28. is_web_domain_valid
  29. # Checking domain is not suspened
  30. is_domain_suspended 'web_domains'
  31. # Checking ssl is added
  32. is_web_domain_value_exist '$SSL'
  33. #----------------------------------------------------------#
  34. # Action #
  35. #----------------------------------------------------------#
  36. # Get template name
  37. tpl_name=$(get_web_domain_value '$TPL')
  38. tpl_file="$V_WEBTPL/apache_$tpl_name.stpl"
  39. conf="$V_HOME/$user/conf/shttpd.conf"
  40. # Deleting domain
  41. httpd_del_config
  42. #----------------------------------------------------------#
  43. # Vesta #
  44. #----------------------------------------------------------#
  45. # Get old values
  46. cert=$(get_web_domain_value '$SSL_CERT' )
  47. tpl_option=$(get_web_domain_value '$SSL_HOME' )
  48. # Deleting ssl in config
  49. update_web_domain_value '$SSL' 'no'
  50. update_web_domain_value '$SSL_HOME' ''
  51. update_web_domain_value '$SSL_CERT' ''
  52. # Checking last ssl domain
  53. ssl_dom=$(grep "SSL='yes'" $V_USERS/$user/web_domains.conf | wc -l)
  54. main_conf='/etc/httpd/conf.d/vesta.conf'
  55. conf="$V_HOME/$user/conf/shttpd.conf"
  56. if [ "$ssl_dom" -eq '0' ]; then
  57. sed -i "/Include ${conf////\/}/d" $main_conf
  58. rm -f $conf
  59. fi
  60. # Decreasing domain value
  61. decrease_user_value "$user" '$U_WEB_SSL'
  62. # Checking cert parents
  63. conf="$V_USERS/$user/web_domains.conf"
  64. field='$DOMAIN'
  65. search_string="SSL_CERT='$cert'"
  66. cert_parents=$(dom_clear_search)
  67. if [ -z "$cert_parents" ]; then
  68. rm -f $V_HOME/$user/conf/$cert.crt $V_HOME/$user/conf/$cert.key
  69. fi
  70. # Adding task to the vesta pipe
  71. restart_schedule 'web'
  72. # Logging
  73. log_history "$V_EVENT" "v_add_web_domain_ssl $user $domain $cert $tpl_option"
  74. log_event 'system' "$V_EVENT"
  75. exit $OK