History

Merge pull request #83 from pullmoll/installer

installer.sh.in: fixes and improvements

Jürgen Buchmüller committed 10 years ago

Commit 758deda2 parents 50148f3 b820b281 file · +60 −23Browse files

Unified · Split

installer.sh.in+60−23
@@ -93,6 +93,13 @@ DIALOG() { · 92 unmodified lines
9393 return $?
9494 }
9595
96+INFOBOX() {
97+ # Note: dialog --infobox and --keep-tite don't work together
98+ dialog --colors --no-shadow --no-mouse \
99+ --backtitle "${BOLD}${WHITE}Void Linux installation -- http://www.voidlinux.eu/ (@@MKLIVE_VERSION@@)${RESET}" \
100+ --title "${TITLE}" --aspect 20 --infobox "$@"
101+}
102+
96103 DIE() {
97104 rval=$1
98105 [ -z "$rval" ] && rval=0
@@ -517,13 +524,13 @@ menu_locale() { · 418 unmodified lines
517524 local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')"
518525 local LOCALES ISO639 ISO3166
519526 local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1)
520−
521− echo "Scanning locales..."
527+ INFOBOX "Scanning locales ..." 4 60
522528 for f in ${_locales}; do
523529 eval $(echo $f | awk 'BEGIN { FS="." } \
524530 { FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }')
525531 echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE
526532 done
533+ clear
527534 # Sort by ISO-639 language names
528535 LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g')
529536 rm -f $TMPFILE
@@ -596,10 +603,10 @@ menu_rootpassword() { · 66 unmodified lines
596603 local _firstpass _secondpass _desc
597604
598605 while true; do
599− if [ -n "${_firstpass}" ]; then
600− _desc="Enter the root password again"
601− else
606+ if [ -z "${_firstpass}" ]; then
602607 _desc="Enter the root password"
608+ else
609+ _desc="$_desc again"
603610 fi
604611 DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
605612 if [ $? -eq 0 ]; then
@@ -610,9 +617,9 @@ menu_rootpassword() { · 4 unmodified lines
610617 fi
611618 if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
612619 if [ "${_firstpass}" != "${_secondpass}" ]; then
613− DIALOG --infobox "Passwords do not match! Please enter again." 6 80
620+ INFOBOX "Passwords do not match! Please enter again." 6 60
614621 unset _firstpass _secondpass
615− sleep 2 && continue
622+ sleep 2 && clear && continue
616623 fi
617624 set_option ROOTPASSWORD "${_firstpass}"
618625 ROOTPASSWORD_DONE=1
@@ -631,9 +638,12 @@ set_rootpassword() { · 12 unmodified lines
631638 menu_useraccount() {
632639 local _firstpass _secondpass _desc
633640 local _groups _status _group _checklist
641+ local _preset
634642
635643 while true; do
636− DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "void"
644+ _preset=$(get_option USERLOGIN)
645+ [ -z "$_preset" ] && _preset="void"
646+ DIALOG --inputbox "Enter a primary login name:" ${INPUTSIZE} "$_preset"
637647 if [ $? -eq 0 ]; then
638648 set_option USERLOGIN "$(cat $ANSWER)"
639649 USERLOGIN_DONE=1
@@ -644,8 +654,10 @@ menu_useraccount() { · 4 unmodified lines
644654 done
645655
646656 while true; do
657+ _preset=$(get_option USERNAME)
658+ [ -z "$_preset" ] && _preset="Void User"
647659 DIALOG --inputbox "Enter a user name for login '$(get_option USERLOGIN)' :" \
648− ${INPUTSIZE} "$(get_option USERLOGIN)"
660+ ${INPUTSIZE} "$_preset"
649661 if [ $? -eq 0 ]; then
650662 set_option USERNAME "$(cat $ANSWER)"
651663 USERNAME_DONE=1
@@ -656,10 +668,10 @@ menu_useraccount() { · 4 unmodified lines
656668 done
657669
658670 while true; do
659− if [ -n "${_firstpass}" ]; then
660− _desc="Enter the password for login '$(get_option USERLOGIN)' again"
661− else
671+ if [ -z "${_firstpass}" ]; then
662672 _desc="Enter the password for login '$(get_option USERLOGIN)'"
673+ else
674+ _desc="$_desc again"
663675 fi
664676 DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
665677 if [ $? -eq 0 ]; then
@@ -670,9 +682,9 @@ menu_useraccount() { · 4 unmodified lines
670682 fi
671683 if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
672684 if [ "${_firstpass}" != "${_secondpass}" ]; then
673− DIALOG --infobox "Passwords do not match! Please enter again." 6 80
685+ INFOBOX "Passwords do not match! Please enter again." 6 60
674686 unset _firstpass _secondpass
675− sleep 2 && continue
687+ sleep 2 && clear && continue
676688 fi
677689 set_option USERPASSWORD "${_firstpass}"
678690 USERPASSWORD_DONE=1
@@ -1003,7 +1015,8 @@ failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE} · 324 unmodified lines
10031015 vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;;
10041016 xfs) MKFS="mkfs.xfs -f"; modprobe xfs >$LOG 2>&1;;
10051017 esac
1006− DIALOG --infobox "Creating filesystem $fstype on $dev for $mntpt ..." 8 60
1018+ TITLE="Check $LOG for details ..."
1019+ INFOBOX "Creating filesystem $fstype on $dev for $mntpt ..." 8 60
10071020 echo "Running $MKFS $dev..." >$LOG
10081021 $MKFS $dev >$LOG 2>&1; rv=$?
10091022 if [ $rv -ne 0 ]; then
@@ -1087,13 +1100,38 @@ umount_filesystems() { · 77 unmodified lines
10871100 umount $TARGETDIR >$LOG 2>&1
10881101 }
10891102
1103+log_and_count() {
1104+ local progress whole tenth
1105+ while read line; do
1106+ echo "$line" >$LOG
1107+ copy_count=$((copy_count + 1))
1108+ progress=$((1000 * copy_count / copy_total))
1109+ if [ "$progress" != "$copy_progress" ]; then
1110+ whole=$((progress / 10))
1111+ tenth=$((progress % 10))
1112+ printf "Progress: %d.%d%% (%d of %d files)\n" $whole $tenth $copy_count $copy_total
1113+ copy_progress=$progress
1114+ fi
1115+ done
1116+}
1117+
10901118 copy_rootfs() {
1091− DIALOG --title "Check $LOG for details" \
1092− --infobox "Copying live image to target rootfs, please wait ..." 4 60
1093− LANG=C cp -axvnu / $TARGETDIR >$LOG 2>&1
1119+ local tar_in="--create --one-file-system"
1120+ local tar_out="--extract --preserve-permissions"
1121+ TITLE="Check $LOG for details ..."
1122+ INFOBOX "Counting files, please be patient ..." 4 60
1123+ copy_total=$(tar ${tar_in} -v -f /dev/null / 2>/dev/null | wc -l)
1124+ export copy_total copy_count=0 copy_progress=
1125+ clear
1126+ tar ${tar_in} -f - / 2>/dev/null | \
1127+ tar ${tar_out} -v -f - -C $TARGETDIR | \
1128+ log_and_count | \
1129+ DIALOG --title "${TITLE}" \
1130+ --progressbox "Copying live image to target rootfs." 5 60
10941131 if [ $? -ne 0 ]; then
10951132 DIE 1
10961133 fi
1134+ unset copy_total copy_count copy_percent
10971135 }
10981136
10991137 install_packages() {
@@ -1171,14 +1209,13 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return · 71 unmodified lines
11711209 echo "Removing $USERNAME live user from targetdir ..." >$LOG
11721210 chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1
11731211 sed -i -e "/$USERNAME ALL=.*/d" $TARGETDIR/etc/sudoers
1174− DIALOG --title "Check $LOG for details" \
1175− --infobox "Rebuilding initramfs for target ..." 4 60
1212+ TITLE="Check $LOG for details ..."
1213+ INFOBOX "Rebuilding initramfs for target ..." 4 60
11761214 echo "Rebuilding initramfs for target ..." >$LOG
11771215 # mount required fs
11781216 mount_filesystems
11791217 chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1
1180− DIALOG --title "Check $LOG for details" \
1181− --infobox "Removing temporary packages from target ..." 4 60
1218+ INFOBOX "Removing temporary packages from target ..." 4 60
11821219 echo "Removing temporary packages from target ..." >$LOG
11831220 xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&1
11841221 rmdir $TARGETDIR/mnt/target
@@ -1189,7 +1226,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return · 4 unmodified lines
11891226 install_packages
11901227 fi
11911228
1192− DIALOG --infobox "Applying installer settings..." 4 60
1229+ INFOBOX "Applying installer settings..." 4 60
11931230
11941231 # copy target fstab.
11951232 install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab

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