| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- #!/bin/bash
- # info: change web domain template
- # options: USER DOMAIN TEMPLATE [RESTART]
- #
- # The function changes template of the web configuration file. The content
- # of webdomain directories remains untouched.
- #----------------------------------------------------------#
- # Variable&Function #
- #----------------------------------------------------------#
- # Argument definition
- user=$1
- domain=$(idn -t --quiet -u "$2" )
- domain_idn=$(idn -t --quiet -a "$domain")
- template=$3
- restart=$4
- # Includes
- source $VESTA/func/main.sh
- source $VESTA/func/domain.sh
- source $VESTA/func/ip.sh
- source $VESTA/conf/vesta.conf
- #----------------------------------------------------------#
- # Verifications #
- #----------------------------------------------------------#
- check_args '3' "$#" 'USER DOMAIN TEMPLATE [RESTART]'
- is_format_valid 'user' 'domain' 'template'
- is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
- is_object_valid 'user' 'USER' "$user"
- is_object_unsuspended 'user' 'USER' "$user"
- is_object_valid 'web' 'DOMAIN' "$domain"
- is_object_unsuspended 'web' 'DOMAIN' "$domain"
- is_web_template_valid
- #----------------------------------------------------------#
- # Action #
- #----------------------------------------------------------#
- # Parsing domain values
- get_domain_values 'web'
- ip=$(get_real_ip $IP)
- # Deleting domain
- del_web_config "$WEB_SYSTEM" "$TPL.tpl"
- if [ "$SSL" = 'yes' ]; then
- del_web_config "$WEB_SYSTEM" "$TPL.stpl"
- fi
- # Defining variables for new vhost config
- TPL=$template
- prepare_web_domain_values
- add_web_config "$WEB_SYSTEM" "$TPL.tpl"
- if [ "$SSL" = 'yes' ]; then
- add_web_config "$WEB_SYSTEM" "$TPL.stpl"
- fi
- #----------------------------------------------------------#
- # Vesta #
- #----------------------------------------------------------#
- # Changing tpl in config
- update_object_value 'web' 'DOMAIN' "$domain" '$TPL' "$template"
- # Restarting web
- if [ "$restart" != 'no' ]; then
- $BIN/v-restart-web
- check_result $? "Web restart failed" >/dev/null
- fi
- # Logging
- log_history "changed web domain template for $domain to $template" '' 'admin'
- log_event "$OK" "$ARGUMENTS"
- exit
|