about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjbu <pullmoll@t-online.de>2016-02-04 07:40:59 +0100
committerjbu <pullmoll@t-online.de>2016-02-04 08:07:54 +0100
commit678fabe87eb24ccaa548d42861188b948cb3e8a9 (patch)
treef760b3d2bfa234ec9270c5b5335837a0e77098f7
parent3b448665e92702331edf069afeae7afd7ee2479d (diff)
downloadhrmpf-678fabe87eb24ccaa548d42861188b948cb3e8a9.tar.gz
hrmpf-678fabe87eb24ccaa548d42861188b948cb3e8a9.tar.xz
hrmpf-678fabe87eb24ccaa548d42861188b948cb3e8a9.zip
installer.sh.in: add user account dialog
-rw-r--r--installer.sh.in57
1 files changed, 56 insertions, 1 deletions
diff --git a/installer.sh.in b/installer.sh.in
index a04f076..71818c1 100644
--- a/installer.sh.in
+++ b/installer.sh.in
@@ -32,6 +32,8 @@ KEYBOARD_DONE=
 LOCALE_DONE=
 TIMEZONE_DONE=
 ROOTPASSWORD_DONE=
+USERNAME_DONE=
+USERPASSWORD_DONE=
 BOOTLOADER_DONE=
 PARTITIONS_DONE=
 NETWORK_DONE=
@@ -421,6 +423,55 @@ set_rootpassword() {
     echo "root:$(get_option ROOTPASSWORD)" | chpasswd -R $TARGETDIR -c SHA512
 }
 
+menu_useraccount() {
+    local _firstpass= _secondpass= _desc=
+
+    while true; do
+        DIALOG --inputbox "Select primary user name:" ${INPUTSIZE} "void"
+        if [ $? -eq 0 ]; then
+            set_option USERNAME "$(cat $ANSWER)"
+            USERNAME_DONE=1
+            break
+        else
+            return
+        fi
+    done
+
+    while true; do
+        if [ -n "${_firstpass}" ]; then
+            _desc="Enter the password for '$(get_option USERNAME)' again (password won't be displayed)"
+        else
+            _desc="Enter the password for '$(get_option USERNAME)' (password won't be displayed)"
+        fi
+        DIALOG --passwordbox "${_desc}" ${MSGBOXSIZE}
+        if [ $? -eq 0 ]; then
+            if [ -z "${_firstpass}" ]; then
+                _firstpass="$(cat $ANSWER)"
+            else
+                _secondpass="$(cat $ANSWER)"
+            fi
+            if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
+                if [ "${_firstpass}" != "${_secondpass}" ]; then
+                    DIALOG --infobox "Passwords do not match! please reenter it again" 6 80
+                    unset _firstpass _secondpass
+                    sleep 2 && continue
+                fi
+                set_option USERPASSWORD "${_firstpass}"
+                USERPASSWORD_DONE=1
+                break
+            fi
+        else
+            return
+        fi
+    done
+}
+
+set_useraccount() {
+    useradd -R $TARGETDIR -m -G wheel,audio,video,floppy,cdrom,optical,kvm,xbuilder \
+         "$(get_option USERNAME)"
+    echo "$(get_option USERNAME):$(get_option USERPASSWORD)" | chpasswd -R $TARGETDIR -c SHA512
+}
+
 menu_bootloader() {
     while true; do
         DIALOG --title " Select the disk to install the bootloader" \
@@ -889,6 +940,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return
     set_timezone
     set_hostname
     set_rootpassword
+    set_useraccount
 
     # Copy /etc/skel files for root.
     cp $TARGETDIR/etc/skel/.[bix]* $TARGETDIR/root
@@ -973,6 +1025,7 @@ menu() {
         "Locale" "Set system locale" \
         "Timezone" "Set system time zone" \
         "RootPassword" "Set system root password" \
+        "UserAccount" "Set primary user name and password" \
         "BootLoader" "Set disk to install bootloader" \
         "Partition" "Partition disk(s)" \
         "Filesystems" "Configure filesystems and mount points" \
@@ -995,7 +1048,9 @@ menu() {
         "Hostname") menu_hostname && [ -n "$HOSTNAME_DONE" ] && DEFITEM="Locale";;
         "Locale") menu_locale && [ -n "$LOCALE_DONE" ] && DEFITEM="Timezone";;
         "Timezone") menu_timezone && [ -n "$TIMEZONE_DONE" ] && DEFITEM="RootPassword";;
-        "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="BootLoader";;
+        "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="UserAccount";;
+        "UserAccount") menu_useraccount && [ -n "$USERNAME_DONE" ] && [ -n "$USERPASSWORD_DONE" ] \
+		&& DEFITEM="BootLoader";;
         "BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";;
         "Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";;
         "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Install";;