Просмотр исходного кода

IPV6: Add/Change Web Domain. Small bug clearance

Cases with empty IP addresses

Shell scripts and functions
asmcc 3 лет назад
Родитель
Сommit
ac4aa427a2
2 измененных файлов с 8 добавлено и 9 удалено
  1. 4 5
      bin/v-add-web-domain
  2. 4 4
      func/domain.sh

+ 4 - 5
bin/v-add-web-domain

@@ -88,11 +88,10 @@ if [ -n "$ipv6" ]; then
 fi
 
 if [ -z "$ip" -a -z "$ipv6" ]; then
-	get_user_ipv6
-fi
-
-if [ -z "$ipv6" ]; then
-	get_user_ip
+	get_user_ipv6	#	get first available user ipv6 address as fallback, if none ip address was defined
+	if [ -z "$ipv6" ]; then
+		get_user_ip	#	get first available user ipv4 address as fallback, if none ipv6 user address available
+	fi
 fi
 
 # Perform verification if read-only mode is enabled

+ 4 - 4
func/domain.sh

@@ -399,16 +399,16 @@ get_web_config_lines() {
 
 # Replace web config
 replace_web_config() {
-	if [ -z "$old" ]; then
-		prepare_web_domain_values #	old parameter is empty. search and replace not possible
-		add_web_config "$@"
+	if [ -z "$old" -o -z "$new" ]; then
+		prepare_web_domain_values #	if one of both parameters is empty, prepare values for the web domain
+		add_web_config "$@"	# web configs must be new generated from the templates
 	else
 		conf="$HOMEDIR/$user/conf/web/$domain/$1.conf"
 		if [[ "$2" =~ stpl$ ]]; then
 			conf="$HOMEDIR/$user/conf/web/$domain/$1.ssl.conf"
 		fi
 		if [ -e "$conf" ]; then
-			sed -i "s|$old|$new|g" $conf
+			sed -i "s|$old|$new|g" $conf # simple search and replace only possible, if both (old and new) parameters are defined
 		fi
 	fi
 }