You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					93 lines
				
				2.6 KiB
			
		
		
			
		
	
	
					93 lines
				
				2.6 KiB
			| 
											2 years ago
										 | #!/bin/bash | ||
|  | # info: unsuspend web/dns/mail domain | ||
|  | # options: USER DOMAIN | ||
|  | # | ||
|  | # example: v-unsuspend-domain admin acme.com | ||
|  | # | ||
|  | # This function unsuspends web/dns/mail domain. | ||
|  | 
 | ||
|  | #----------------------------------------------------------# | ||
|  | #                Variables & Functions                     # | ||
|  | #----------------------------------------------------------# | ||
|  | 
 | ||
|  | # Argument definition | ||
|  | user=$1 | ||
|  | domain=$2 | ||
|  | restart="${3-yes}" | ||
|  | 
 | ||
|  | # Includes | ||
|  | # shellcheck source=/etc/hestiacp/hestia.conf | ||
|  | source /etc/hestiacp/hestia.conf | ||
|  | # shellcheck source=/usr/local/hestia/func/main.sh | ||
|  | source $HESTIA/func/main.sh | ||
|  | # load config file | ||
|  | source_conf "$HESTIA/conf/hestia.conf" | ||
|  | 
 | ||
|  | #----------------------------------------------------------# | ||
|  | #                    Verifications                         # | ||
|  | #----------------------------------------------------------# | ||
|  | 
 | ||
|  | check_args '2' "$#" 'USER DOMAIN' | ||
|  | is_format_valid 'user' 'domain' | ||
|  | is_object_valid 'user' 'USER' "$user" | ||
|  | 
 | ||
|  | # Perform verification if read-only mode is enabled | ||
|  | check_hestia_demo_mode | ||
|  | 
 | ||
|  | #----------------------------------------------------------# | ||
|  | #                       Action                             # | ||
|  | #----------------------------------------------------------# | ||
|  | 
 | ||
|  | # Working on Web domain | ||
|  | if [ -n "$WEB_SYSTEM" ]; then | ||
|  | 	str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf | grep "SUSPENDED='yes") | ||
|  | 	if [ -n "$str" ]; then | ||
|  | 		domain_found='yes' | ||
|  | 		$BIN/v-unsuspend-web-domain "$user" "$domain" 'no' | ||
|  | 		check_result $? "can't suspend web" > /dev/null | ||
|  | 	fi | ||
|  | fi | ||
|  | 
 | ||
|  | # Working on DNS domain | ||
|  | if [ -n "$DNS_SYSTEM" ]; then | ||
|  | 	str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf | grep "SUSPENDED='yes") | ||
|  | 	if [ -n "$str" ]; then | ||
|  | 		domain_found='yes' | ||
|  | 		$BIN/v-unsuspend-dns-domain "$user" "$domain" 'no' | ||
|  | 		check_result $? "can't suspend dns" > /dev/null | ||
|  | 	fi | ||
|  | fi | ||
|  | 
 | ||
|  | # Working on Mail domain | ||
|  | if [ -n "$MAIL_SYSTEM" ]; then | ||
|  | 	str=$(grep "DOMAIN='$domain'" $USER_DATA/mail.conf | grep "SUSPENDED='yes") | ||
|  | 	if [ -n "$str" ]; then | ||
|  | 		domain_found='yes' | ||
|  | 		$BIN/v-unsuspend-mail-domain "$user" "$domain" "no" | ||
|  | 		check_result $? "can't suspend mail" > /dev/null | ||
|  | 	fi | ||
|  | fi | ||
|  | 
 | ||
|  | # Checking domain search result | ||
|  | if [ -z "$domain_found" ]; then | ||
|  | 	echo "Error: domain $domain doesn't exist" | ||
|  | 	log_event "$E_NOTEXIST" "$ARGUMENTS" | ||
|  | 	exit $E_NOTEXIST | ||
|  | fi | ||
|  | 
 | ||
|  | # Restarting services | ||
|  | $BIN/v-restart-web "$restart" | ||
|  | check_result $? "can't restart web" > /dev/null | ||
|  | 
 | ||
|  | $BIN/v-restart-proxy "$restart" | ||
|  | check_result $? "can't restart proxy" > /dev/null | ||
|  | 
 | ||
|  | $BIN/v-restart-dns "$restart" | ||
|  | check_result $? "can't restart dns" > /dev/null | ||
|  | 
 | ||
|  | #----------------------------------------------------------# | ||
|  | #                       Hestia                             # | ||
|  | #----------------------------------------------------------# | ||
|  | 
 | ||
|  | exit |