v_delete_web_domain_ssl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #!/bin/bash
  2. # info: delete web domain ssl support
  3. # options: user domain
  4. #
  5. # The function disable https support and deletes SSL certificates.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. domain=$(idn -t --quiet -u "$2" )
  12. domain_idn=$(idn -t --quiet -a "$domain")
  13. # Importing variables
  14. source $VESTA/conf/vars.conf
  15. source $V_CONF/vesta.conf
  16. source $V_FUNC/shared.func
  17. source $V_FUNC/domain.func
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. # Checking arg number
  22. check_args '2' "$#" 'user domain'
  23. # Checking argument format
  24. format_validation 'user' 'domain'
  25. # Checking web system is enabled
  26. is_system_enabled 'web'
  27. # Checking user
  28. is_user_valid
  29. # Checking user is active
  30. is_user_suspended
  31. # Checking domain exist
  32. is_web_domain_valid
  33. # Checking domain is not suspened
  34. is_domain_suspended 'web'
  35. # Checking ssl is added
  36. is_web_domain_value_exist '$SSL'
  37. #----------------------------------------------------------#
  38. # Action #
  39. #----------------------------------------------------------#
  40. # Parsing domain values
  41. get_web_domain_values
  42. conf="$V_HOME/$user/conf/shttpd.conf"
  43. tpl_file="$V_WEBTPL/apache_$TPL.stpl"
  44. # Deleting domain
  45. del_web_config
  46. # Checking nginx
  47. if [ ! -z "$NGINX" ]; then
  48. tpl_file="$V_WEBTPL/ngingx_vhost_$NGINX.stpl"
  49. conf="$V_HOME/$user/conf/snginx.conf"
  50. del_web_config
  51. fi
  52. # Deleting old certificate
  53. tmpdir=$(mktemp -p $V_HOME/$user/web/$domain/private -d)
  54. rm -f $V_HOME/$user/conf/ssl.$domain.*
  55. mv $V_USERS/$user/ssl/$domain.* $tmpdir
  56. chown -R $user:$user $tmpdir
  57. #----------------------------------------------------------#
  58. # Vesta #
  59. #----------------------------------------------------------#
  60. # Deleting ssl in config
  61. update_web_domain_value '$SSL' 'no'
  62. # Checking last ssl domain
  63. ssl_dom=$(grep "SSL='yes'" $V_USERS/$user/web.conf)
  64. main_conf='/etc/httpd/conf.d/vesta.conf'
  65. conf="$V_HOME/$user/conf/shttpd.conf"
  66. if [ -z "$ssl_dom" ]; then
  67. sed -i "/Include ${conf////\/}/d" $main_conf
  68. rm -f $conf
  69. fi
  70. # Checking last nginx domain
  71. conf='/etc/nginx/conf.d/vesta_users.conf'
  72. last_nginx=$(grep -v "NGINX=''" $V_USERS/$user/web.conf)
  73. last_snginx=$(echo "$last_nginx" | grep "SSL='yes'")
  74. if [ -z "$last_snginx" ]; then
  75. if [ -z "$last_nginx" ]; then
  76. sed -i "/$user\/conf\/snginx.conf/d" $conf
  77. rm -f $V_HOME/$user/conf/snginx.conf
  78. fi
  79. # Decreasing domain value
  80. decrease_user_value "$user" '$U_WEB_SSL'
  81. # Adding task to the vesta pipe
  82. restart_schedule 'web'
  83. # Logging
  84. log_history "$V_EVENT" "v_add_web_domain_ssl $user $domain $tmpdir $SSL_HOME"
  85. log_event 'system' "$V_EVENT"
  86. exit