History

Merge pull request #59 from pullmoll/master

installer.sh.in: add user account dialog

Juan RP committed 10 years ago

Commit c5bade22 parents 719ae8a 678fabe1 file · +57 −2Browse files

Unified · Split

installer.sh.in+57−2
@@ -32,6 +32,8 @@ KEYBOARD_DONE= · 31 unmodified lines
3232 LOCALE_DONE=
3333 TIMEZONE_DONE=
3434 ROOTPASSWORD_DONE=
35+USERNAME_DONE=
36+USERPASSWORD_DONE=
3537 BOOTLOADER_DONE=
3638 PARTITIONS_DONE=
3739 NETWORK_DONE=
@@ -421,6 +423,55 @@ set_rootpassword() { · 383 unmodified lines
421423 echo "root:$(get_option ROOTPASSWORD)" | chpasswd -R $TARGETDIR -c SHA512
422424 }
423425
426+menu_useraccount() {
427+ local _firstpass= _secondpass= _desc=
428+
429+ while true; do
430+ DIALOG --inputbox "Select primary user name:" ${INPUTSIZE} "void"
431+ if [ $? -eq 0 ]; then
432+ set_option USERNAME "$(cat $ANSWER)"
433+ USERNAME_DONE=1
434+ break
435+ else
436+ return
437+ fi
438+ done
439+
440+ while true; do
441+ if [ -n "${_firstpass}" ]; then
442+ _desc="Enter the password for '$(get_option USERNAME)' again (password won't be displayed)"
443+ else
444+ _desc="Enter the password for '$(get_option USERNAME)' (password won't be displayed)"
445+ fi
446+ DIALOG --passwordbox "${_desc}" ${MSGBOXSIZE}
447+ if [ $? -eq 0 ]; then
448+ if [ -z "${_firstpass}" ]; then
449+ _firstpass="$(cat $ANSWER)"
450+ else
451+ _secondpass="$(cat $ANSWER)"
452+ fi
453+ if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
454+ if [ "${_firstpass}" != "${_secondpass}" ]; then
455+ DIALOG --infobox "Passwords do not match! please reenter it again" 6 80
456+ unset _firstpass _secondpass
457+ sleep 2 && continue
458+ fi
459+ set_option USERPASSWORD "${_firstpass}"
460+ USERPASSWORD_DONE=1
461+ break
462+ fi
463+ else
464+ return
465+ fi
466+ done
467+}
468+
469+set_useraccount() {
470+ useradd -R $TARGETDIR -m -G wheel,audio,video,floppy,cdrom,optical,kvm,xbuilder \
471+ "$(get_option USERNAME)"
472+ echo "$(get_option USERNAME):$(get_option USERPASSWORD)" | chpasswd -R $TARGETDIR -c SHA512
473+}
474+
424475 menu_bootloader() {
425476 while true; do
426477 DIALOG --title " Select the disk to install the bootloader" \
@@ -476,7 +527,7 @@ configure_wifi() { · 49 unmodified lines
476527
477528 DIALOG --form "Wireless configuration for ${dev}\n(encryption type: wep or wpa)" 0 0 0 \
478529 "SSID:" 1 1 "" 1 16 30 0 \
479− "Encryption:" 2 1 "" 2 16 3 0 \
530+ "Encryption:" 2 1 "" 2 16 4 3 \
480531 "Password:" 3 1 "" 3 16 50 0 || return 1
481532 set -- $(cat $ANSWER)
482533 ssid="$1"; enc="$2"; pass="$3";
@@ -889,6 +940,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return · 406 unmodified lines
889940 set_timezone
890941 set_hostname
891942 set_rootpassword
943+ set_useraccount
892944
893945 # Copy /etc/skel files for root.
894946 cp $TARGETDIR/etc/skel/.[bix]* $TARGETDIR/root
@@ -973,6 +1025,7 @@ menu() { · 78 unmodified lines
9731025 "Locale" "Set system locale" \
9741026 "Timezone" "Set system time zone" \
9751027 "RootPassword" "Set system root password" \
1028+ "UserAccount" "Set primary user name and password" \
9761029 "BootLoader" "Set disk to install bootloader" \
9771030 "Partition" "Partition disk(s)" \
9781031 "Filesystems" "Configure filesystems and mount points" \
@@ -995,7 +1048,9 @@ menu() { · 16 unmodified lines
9951048 "Hostname") menu_hostname && [ -n "$HOSTNAME_DONE" ] && DEFITEM="Locale";;
9961049 "Locale") menu_locale && [ -n "$LOCALE_DONE" ] && DEFITEM="Timezone";;
9971050 "Timezone") menu_timezone && [ -n "$TIMEZONE_DONE" ] && DEFITEM="RootPassword";;
998− "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="BootLoader";;
1051+ "RootPassword") menu_rootpassword && [ -n "$ROOTPASSWORD_DONE" ] && DEFITEM="UserAccount";;
1052+ "UserAccount") menu_useraccount && [ -n "$USERNAME_DONE" ] && [ -n "$USERPASSWORD_DONE" ] \
1053+ && DEFITEM="BootLoader";;
9991054 "BootLoader") menu_bootloader && [ -n "$BOOTLOADER_DONE" ] && DEFITEM="Partition";;
10001055 "Partition") menu_partitions && [ -n "$PARTITIONS_DONE" ] && DEFITEM="Filesystems";;
10011056 "Filesystems") menu_filesystems && [ -n "$FILESYSTEMS_DONE" ] && DEFITEM="Install";;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t