Przeglądaj źródła

Improved user selection dialog during install

Bob Mottram 9 lat temu
rodzic
commit
b1178c2bc8
1 zmienionych plików z 30 dodań i 11 usunięć
  1. 30
    11
      src/freedombone-config

+ 30
- 11
src/freedombone-config Wyświetl plik

@@ -598,6 +598,34 @@ function interactive_select_language {
598 598
     update-locale LC_CTYPE=${DEFAULT_LANGUAGE}
599 599
 }
600 600
 
601
+function select_user {
602
+    SELECTED_USERNAME=
603
+
604
+    users_array=($(ls /home))
605
+
606
+    delete=(mirrors git)
607
+    for del in ${delete[@]}
608
+    do
609
+        users_array=(${users_array[@]/$del})
610
+    done
611
+
612
+    i=0
613
+    W=()
614
+    name=()
615
+    for u in ${users_array[@]}
616
+    do
617
+        i=$((i+1))
618
+        W+=($i "$u")
619
+        name+=("$u")
620
+    done
621
+
622
+    user_index=$(dialog --backtitle $"Freedombone Configuration" --title $"Select User" --menu $"Select one of the following:" 24 40 17 "${W[@]}" 3>&2 2>&1 1>&3)
623
+
624
+    if [ $? -eq 0 ]; then
625
+        SELECTED_USERNAME="${name[$((user_index-1))]}"
626
+    fi
627
+}
628
+
601 629
 function interactive_configuration {
602 630
     # create a temporary copy of the configuration file
603 631
     # which can be used to pre-populate selections
@@ -832,17 +860,8 @@ function interactive_configuration {
832 860
             if [[ $SYSTEM_TYPE == "$VARIANT_MESH" && $DEFAULT_DOMAIN_NAME && -d /home/$DEFAULT_DOMAIN_NAME ]]; then
833 861
                 MY_USERNAME=$DEFAULT_DOMAIN_NAME
834 862
             else
835
-                data=$(tempfile 2>/dev/null)
836
-                trap "rm -f $data" 0 1 2 5 15
837
-                dialog --title $"Select the user account to install as" \
838
-                       --backtitle $"Freedombone Configuration" \
839
-                       --dselect "/home/$(grep 'MY_USERNAME' temp.cfg | awk -F '=' '{print $2}')" 14 40 2> $data
840
-                sel=$?
841
-                case $sel in
842
-                    0) MY_USERNAME=$(cat $data | awk -F '/' '{print $3}');;
843
-                    1) exit 1;;
844
-                    255) exit 1;;
845
-                esac
863
+                select_user
864
+                MY_USERNAME=$SELECTED_USERNAME
846 865
             fi
847 866
         fi
848 867
     fi