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

Replace bin/v-list-sys-users by bin/v-list-users (#3930)

* v-list-sys-users replace by v-list-users

* Replace v-list-sys-users by v-list-users. Part 2

* v-list-users with new list option

* Remove raw_list option

Not used every where

* Add notice and use v-list-users list instead

---------

Co-authored-by: asmcc <root@7-www.tk>
Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
asmcc 2 лет назад
Родитель
Сommit
77e69939ca

+ 1 - 1
bin/v-add-remote-dns-host

@@ -104,7 +104,7 @@ cluster_cmd v-add-cron-restart-job
 check_result $? "$HOST connection failed" "$E_CONNECT"
 
 # Loop trough domains to generate new serial
-for dns_user in $($BIN/v-list-sys-users plain); do
+for dns_user in $("$BIN/v-list-users" list); do
 	for dns_domain in $($BIN/v-list-dns-domains $dns_user plain | cut -f1); do
 		$BIN/v-rebuild-dns-domain $dns_user $dns_domain "no" "yes"
 	done

+ 1 - 1
bin/v-add-sys-ip

@@ -211,7 +211,7 @@ syshealth_adapt_nginx_resolver
 increase_user_value "$user" '$IP_OWNED'
 if [ "$user" = $ROOT_USER ]; then
 	if [ "$ip_status" = 'shared' ]; then
-		for hestia_user in $($BIN/v-list-sys-users plain); do
+		for hestia_user in $("$BIN/v-list-users" list); do
 			increase_user_value "$hestia_user" '$IP_AVAIL'
 		done
 	else

+ 2 - 2
bin/v-add-sys-quota

@@ -90,8 +90,8 @@ else
 fi
 
 # Rebuilding user quota
-for user in $($BIN/v-list-sys-users plain); do
-	$BIN/v-update-user-quota "$user"
+for user in $("$BIN/v-list-users" list); do
+	"$BIN/v-update-user-quota" "$user"
 done
 
 #----------------------------------------------------------#

+ 1 - 1
bin/v-backup-users

@@ -31,7 +31,7 @@ mysqlrepair --all-databases --check --auto-repair > /dev/null 2>&1
 if [ -z "$BACKUP_SYSTEM" ]; then
 	exit
 fi
-for user in $($BIN/v-list-sys-users plain); do
+for user in $("$BIN/v-list-users" list); do
 	check_suspend=$(grep "SUSPENDED='no'" $HESTIA/data/users/$user/user.conf)
 	log=$HESTIA/log/backup.log
 	if [ ! -f "$HESTIA/data/users/$user/user.conf" ]; then

+ 6 - 6
bin/v-change-sys-ip-nat

@@ -57,7 +57,7 @@ fi
 
 # Updating WEB configs
 if [ -n "$old" ] && [ -n "$WEB_SYSTEM" ]; then
-	for user in $($BIN/v-list-sys-users plain); do
+	for user in $("$BIN/v-list-users" list); do
 		sed -i "s/$old/$new/" $HESTIA/data/users/$user/web.conf
 		$BIN/v-rebuild-web-domains "$user" no
 	done
@@ -66,7 +66,7 @@ fi
 
 # Updating DNS configs
 if [ -n "$old" ] && [ -n "$DNS_SYSTEM" ]; then
-	for user in $($BIN/v-list-sys-users plain); do
+	for user in $("$BIN/v-list-users" list); do
 		sed -i "s/$old/$new/" "$HESTIA/data/users/$user/dns.conf"
 		if ls $HESTIA/data/users/$user/dns/*.conf > /dev/null 2>&1; then
 			sed -i "s/$old/$new/" $HESTIA/data/users/$user/dns/*.conf
@@ -95,10 +95,10 @@ if [ -n "$old" ] && [ -n "$FTP_SYSTEM" ]; then
 		fi
 	fi
 	if [ "$FTP_SYSTEM" = 'proftpd' ]; then
-        	ext_ip_conf="/etc/$FTP_SYSTEM/conf.d/external_ip.conf"
-        	content="MasqueradeAddress ${nat_ip}"
-        	echo "$content" > "$ext_ip_conf"
-    	fi
+		ext_ip_conf="/etc/$FTP_SYSTEM/conf.d/external_ip.conf"
+		content="MasqueradeAddress ${nat_ip}"
+		echo "$content" > "$ext_ip_conf"
+	fi
 	$BIN/v-restart-ftp "$restart"
 fi
 

+ 2 - 2
bin/v-change-sys-ip-owner

@@ -51,7 +51,7 @@ if [ "$ip_owner" != "$user" ]; then
 	decrease_user_value "$ip_owner" '$IP_OWNED'
 	if [ "$ip_owner" = "$ROOT_USER" ]; then
 		if [ "$ip_status" = 'shared' ]; then
-			for hestia_user in $($BIN/v-list-sys-users plain); do
+			for hestia_user in $("$BIN/v-list-users" list); do
 				decrease_user_value "$hestia_user" '$IP_AVAIL'
 			done
 		else
@@ -65,7 +65,7 @@ if [ "$ip_owner" != "$user" ]; then
 	increase_user_value "$user" '$IP_OWNED'
 	if [ "$user" = "$ROOT_USER" ]; then
 		if [ "$ip_status" = 'shared' ]; then
-			for hestia_user in $($BIN/v-list-sys-users plain); do
+			for hestia_user in $("$BIN/v-list-users" list); do
 				increase_user_value "$hestia_user" '$IP_AVAIL'
 			done
 		else

+ 1 - 1
bin/v-change-sys-language

@@ -62,7 +62,7 @@ fi
 
 # Update language for all existing users if specified
 if [ "$update_users" = "yes" ]; then
-	for user in $($BIN/v-list-sys-users plain); do
+	for user in $("$BIN/v-list-users" list); do
 		$BIN/v-change-user-language "$user" "$language"
 	done
 fi

+ 1 - 1
bin/v-change-sys-php

@@ -47,7 +47,7 @@ php_fpm="/etc/init.d/php$version-fpm"
 rm -f /etc/php/*/fpm/pool.d/www.conf
 cp -f $HESTIA/install/deb/php-fpm/www.conf /etc/php/$version/fpm/pool.d/www.conf
 
-for user in $($BIN/v-list-sys-users plain); do
+for user in $("$BIN/v-list-users" list); do
 	$BIN/v-rebuild-web-domains "$user" 'no' > /dev/null 2>&1
 	$BIN/v-rebuild-mail-domains "$user" 'no' > /dev/null 2>&1
 done

+ 2 - 2
bin/v-change-sys-webmail

@@ -35,7 +35,7 @@ check_hestia_demo_mode
 #----------------------------------------------------------#
 
 # Delete old webmail configuration
-for user in $($BIN/v-list-sys-users plain); do
+for user in $("$BIN/v-list-users" list); do
 	for domain in $($BIN/v-list-mail-domains "$user" plain | cut -f 1); do
 		$BIN/v-delete-mail-domain-webmail "$user" "$domain"
 	done
@@ -45,7 +45,7 @@ done
 $BIN/v-change-sys-config-value 'WEBMAIL_ALIAS' $NEW_ALIAS
 
 # Add new webmail configuration
-for user in $($BIN/v-list-sys-users plain); do
+for user in $("$BIN/v-list-users" list); do
 	for domain in $($BIN/v-list-mail-domains "$user" plain | cut -f 1); do
 		$BIN/v-add-mail-domain-webmail "$user" "$domain"
 	done

+ 1 - 1
bin/v-delete-sys-ip

@@ -139,7 +139,7 @@ fi
 
 if [ "$OWNER" = "$ROOT_USER" ]; then
 	if [ "$STATUS" = 'shared' ]; then
-		for hestia_user in $($BIN/v-list-sys-users plain); do
+		for hestia_user in $("$BIN/v-list-users" list); do
 			decrease_user_value "$hestia_user" '$IP_AVAIL'
 		done
 	else

+ 5 - 5
bin/v-list-sys-users

@@ -24,7 +24,7 @@ source_conf "$HESTIA/conf/hestia.conf"
 
 # JSON list function
 json_list() {
-	objects=$(grep @ /etc/passwd | wc -l)
+	objects=$("$BIN/v-list-users" 'list' | wc -w)
 	i=1
 	echo '['
 	while read user; do
@@ -34,7 +34,7 @@ json_list() {
 			echo -e "\t\"$user\""
 		fi
 		((++i))
-	done < <(grep @ /etc/passwd | cut -f 1 -d :)
+	done < <("$BIN/v-list-users" 'list')
 	echo "]"
 }
 
@@ -44,14 +44,14 @@ shell_list() {
 	echo "----"
 	while read user; do
 		echo "$user"
-	done < <(grep @ /etc/passwd | cut -f 1 -d :)
+	done < <("$BIN/v-list-users" 'list')
 }
 
 # PLAIN list function
 plain_list() {
 	while read user; do
 		echo "$user"
-	done < <(grep @ /etc/passwd | cut -f 1 -d :)
+	done < <("$BIN/v-list-users" 'list')
 }
 
 # CSV list function
@@ -59,7 +59,7 @@ csv_list() {
 	echo "USER"
 	while read user; do
 		echo "$user"
-	done < <(grep @ /etc/passwd | cut -f 1 -d :)
+	done < <("$BIN/v-list-users" 'list')
 }
 
 #----------------------------------------------------------#

+ 6 - 5
bin/v-list-users

@@ -14,7 +14,7 @@
 # shellcheck source=/etc/hestiacp/hestia.conf
 source /etc/hestiacp/hestia.conf
 # shellcheck source=/usr/local/hestia/func/main.sh
-source $HESTIA/func/main.sh
+source "$HESTIA/func/main.sh"
 # load config file
 source_conf "$HESTIA/conf/hestia.conf"
 
@@ -165,14 +165,14 @@ csv_list() {
 	done < <(grep '@' /etc/passwd | cut -f1 -d:)
 }
 
-# Raw list function
-raw_list() {
+# USER ONLY list function
+only_user_list() {
 	while read USER; do
 		if [ ! -f "$HESTIA/data/users/$USER/user.conf" ]; then
 			continue
 		fi
-		echo $HESTIA/data/users/$USER/user.conf
-		cat $HESTIA/data/users/$USER/user.conf
+		source_conf "$HESTIA/data/users/$USER/user.conf"
+		echo "$USER"
 	done < <(grep '@' /etc/passwd | cut -f1 -d:)
 }
 
@@ -186,6 +186,7 @@ case $format in
 	plain) plain_list ;;
 	csv) csv_list ;;
 	shell) shell_list | column -t ;;
+	list) only_user_list ;;
 esac
 
 #----------------------------------------------------------#

+ 1 - 1
bin/v-rebuild-users

@@ -37,7 +37,7 @@ check_hestia_demo_mode
 #----------------------------------------------------------#
 
 # Rebuild loop
-for user in $($BIN/v-list-sys-users plain); do
+for user in $("$BIN/v-list-users" list); do
 	$BIN/v-rebuild-user "$user" "$restart"
 done
 

+ 1 - 1
bin/v-search-object

@@ -93,7 +93,7 @@ OLD_IFS=$IFS
 IFS=$'\n'
 
 # User loop
-for user in $($BIN/v-list-sys-users plain); do
+for user in $("$BIN/v-list-users" list); do
 	# Search query
 	search=$(grep "$object" \
 		$HESTIA/data/users/$user/web.conf \

+ 1 - 1
bin/v-update-letsencrypt-ssl

@@ -37,7 +37,7 @@ if [ "$LE_STAGING" = "yes" ]; then
 fi
 
 # Checking user certificates
-for user in $($BIN/v-list-sys-users plain); do
+for user in $("$BIN/v-list-users" list); do
 	USER_DATA=$HESTIA/data/users/$user
 
 	for domain in $(search_objects 'web' 'LETSENCRYPT' 'yes' 'DOMAIN'); do

+ 1 - 1
bin/v-update-mail-templates

@@ -32,7 +32,7 @@ cp -rf $HESTIA_INSTALL_DIR/templates/mail $HESTIA/data/templates/
 # Rebuild mail domains if mail services are enabled
 if [ -z "$skip" ]; then
 	if [ -n "$MAIL_SYSTEM" ]; then
-		for user in $($BIN/v-list-sys-users plain); do
+		for user in $("$BIN/v-list-users" list); do
 			$BIN/v-rebuild-mail-domains "$user" no
 		done
 	fi

+ 3 - 3
bin/v-update-sys-ip

@@ -99,7 +99,7 @@ if [ -n "$old_ip" ]; then
 			sed -i "s/$old_ip/$new_ip/g" $new_ip.conf
 		fi
 
-		for user in $($BIN/v-list-sys-users plain); do
+		for user in $("$BIN/v-list-users" list); do
 			sed -i "s/$old_ip/$new_ip/g" $HESTIA/data/users/$user/web.conf
 			$BIN/v-rebuild-web-domains "$user" no
 		done
@@ -118,7 +118,7 @@ if [ -n "$old_ip" ]; then
 
 	# Updating MAIL
 	if [ -n "$IMAP_SYSTEM" ]; then
-		for user in $($BIN/v-list-sys-users plain); do
+		for user in $("$BIN/v-list-users" list); do
 			$BIN/v-rebuild-mail-domains "$user" no
 		done
 		$BIN/v-restart-mail
@@ -126,7 +126,7 @@ if [ -n "$old_ip" ]; then
 
 	# Updating DNS
 	if [ -n "$DNS_SYSTEM" ]; then
-		for user in $($BIN/v-list-sys-users plain); do
+		for user in $("$BIN/v-list-users" list); do
 			sed -i "s/$old_ip/$new_ip/g" $HESTIA/data/users/$user/dns.conf
 			sed -i "s/$old_ip/$new_ip/g" $HESTIA/data/users/$user/dns/*.conf
 			$BIN/v-rebuild-dns-domains "$user" no

+ 2 - 2
bin/v-update-user-counters

@@ -37,7 +37,7 @@ fi
 
 # Creating user_list
 if [ -z "$user" ]; then
-	user_list=$($BIN/v-list-sys-users plain)
+	user_list="$("$BIN/v-list-users" list)"
 else
 	user_list="$user"
 fi
@@ -85,7 +85,7 @@ for user in $user_list; do
 	if [ "$user" = "$ROOT_USER" ]; then
 		spnd=$(grep "SUSPENDED='yes'" $HESTIA/data/users/*/user.conf | wc -l)
 		SUSPENDED_USERS=$spnd
-		U_USERS=$($BIN/v-list-sys-users plain | wc -l)
+		U_USERS=$("$BIN/v-list-users" list | wc -l)
 	fi
 
 	ips=$(ls $HESTIA/data/ips)

+ 2 - 2
bin/v-update-user-package

@@ -33,10 +33,10 @@ is_package_valid
 #                       Action                             #
 #----------------------------------------------------------#
 
-for user in $($BIN/v-list-sys-users plain); do
+for user in $("$BIN/v-list-users" list); do
 	check_package=$(grep "PACKAGE='$package'" $USER_DATA/$user/user.conf)
 	if [ -n "$check_package" ]; then
-		$BIN/v-change-user-package "$user" "$package" 'yes'
+		"$BIN/v-change-user-package" "$user" "$package" 'yes'
 	fi
 done
 

+ 1 - 1
bin/v-update-user-stats

@@ -43,7 +43,7 @@ fi
 
 # Creating user_list
 if [ -z "$user" ]; then
-	user_list=$($BIN/v-list-sys-users plain)
+	user_list=$("$BIN/v-list-users" list)
 	update_overall_stats='yes'
 else
 	user_list="$user"

+ 1 - 1
bin/v-update-web-templates

@@ -64,7 +64,7 @@ fi
 
 # Rebuilding web domains
 if [ -z "$skip" ]; then
-	for user in $($BIN/v-list-sys-users plain); do
+	for user in $("$BIN/v-list-users" list); do
 		$BIN/v-rebuild-web-domains "$user" "no"
 	done
 fi

+ 1 - 1
func/upgrade.sh

@@ -755,7 +755,7 @@ upgrade_rebuild_users() {
 		else
 			echo "[ * ] Rebuilding user accounts and domains, this may take a few minutes..."
 		fi
-		for user in $($BIN/v-list-sys-users plain); do
+		for user in $("$BIN/v-list-users" list); do
 			export restart="no"
 			if [ "$DEBUG_MODE" = "true" ]; then
 				echo "      - $user:"