Browse Source

Fixes bug where the same user gets added multiple times to the ip file.

cmstew 5 years ago
parent
commit
ad8a39d04c
2 changed files with 13 additions and 1 deletions
  1. 1 1
      func/ip.sh
  2. 12 0
      install/upgrade/versions/1.3.1.sh

+ 1 - 1
func/ip.sh

@@ -83,7 +83,7 @@ increase_ip_value() {
     if [ -z "$current_usr" ]; then
     if [ -z "$current_usr" ]; then
         new_usr="$USER"
         new_usr="$USER"
     else
     else
-        check_usr=$(echo -e "${current_usr//,/\n}" |grep -w $USER)
+        check_usr=$(echo -e "${current_usr//,/\\n}" | grep -w ^${USER}$)
         if [ -z "$check_usr" ]; then
         if [ -z "$check_usr" ]; then
             new_usr="$current_usr,$USER"
             new_usr="$current_usr,$USER"
         else
         else

+ 12 - 0
install/upgrade/versions/1.3.1.sh

@@ -5,3 +5,15 @@
 #######################################################################################
 #######################################################################################
 #######                      Place additional commands below.                   #######
 #######                      Place additional commands below.                   #######
 #######################################################################################
 #######################################################################################
+
+# Remove duplicate values in U_SYS_USERS variable for ips
+for ip in $(ls $HESTIA/data/ips/); do
+    current_usr=$(grep "U_SYS_USERS=" $HESTIA/data/ips/$ip |cut -f 2 -d \')
+    
+    new_usr=$(echo $current_usr | sed 's/,/\n/g' | sort | uniq | paste -sd,)
+
+    if [ ! -z $new_usr ]; then
+        sed -i "s/U_SYS_USERS='$current_usr'/U_SYS_USERS='$new_usr'/g" $HESTIA/data/ips/$ip
+    fi
+done
+