installer.sh.in: fixes and improvements
Unified · Split
| @@ -93,6 +93,13 @@ DIALOG() { · 92 unmodified lines | |||
| 93 | return $? | 93 | return $? |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 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 | |||
| 96 | DIE() { | 103 | DIE() { |
| 97 | rval=$1 | 104 | rval=$1 |
| 98 | [ -z "$rval" ] && rval=0 | 105 | [ -z "$rval" ] && rval=0 |
| @@ -517,13 +524,13 @@ menu_locale() { · 418 unmodified lines | |||
| 517 | local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')" | 524 | local _locales="$(grep -E '\.UTF-8' /etc/default/libc-locales|awk '{print $1}'|sed -e 's/^#//')" |
| 518 | local LOCALES ISO639 ISO3166 | 525 | local LOCALES ISO639 ISO3166 |
| 519 | local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1) | 526 | local TMPFILE=$(mktemp -t vinstall-XXXXXXXX || exit 1) |
| 520 | 527 | INFOBOX "Scanning locales ..." 4 60 | |
| 521 | echo "Scanning locales..." | ||
| 522 | for f in ${_locales}; do | 528 | for f in ${_locales}; do |
| 523 | eval $(echo $f | awk 'BEGIN { FS="." } \ | 529 | eval $(echo $f | awk 'BEGIN { FS="." } \ |
| 524 | { FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }') | 530 | { FS="_"; split($1, a); printf "ISO639=%s ISO3166=%s\n", a[1], a[2] }') |
| 525 | echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE | 531 | echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE |
| 526 | done | 532 | done |
| 533 | clear | ||
| 527 | # Sort by ISO-639 language names | 534 | # Sort by ISO-639 language names |
| 528 | LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g') | 535 | LOCALES=$(sort -t '|' -k 2 < $TMPFILE | xargs | sed -e's/| /|/g') |
| 529 | rm -f $TMPFILE | 536 | rm -f $TMPFILE |
| @@ -596,10 +603,10 @@ menu_rootpassword() { · 66 unmodified lines | |||
| 596 | local _firstpass _secondpass _desc | 603 | local _firstpass _secondpass _desc |
| 597 | 604 | ||
| 598 | while true; do | 605 | while true; do |
| 599 | if [ -n "${_firstpass}" ]; then | 606 | if [ -z "${_firstpass}" ]; then |
| 600 | _desc="Enter the root password again" | ||
| 601 | else | ||
| 602 | _desc="Enter the root password" | 607 | _desc="Enter the root password" |
| 608 | else | ||
| 609 | _desc="$_desc again" | ||
| 603 | fi | 610 | fi |
| 604 | DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE} | 611 | DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE} |
| 605 | if [ $? -eq 0 ]; then | 612 | if [ $? -eq 0 ]; then |
| @@ -610,9 +617,9 @@ menu_rootpassword() { · 4 unmodified lines | |||
| 610 | fi | 617 | fi |
| 611 | if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then | 618 | if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then |
| 612 | if [ "${_firstpass}" != "${_secondpass}" ]; then | 619 | 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 |
| 614 | unset _firstpass _secondpass | 621 | unset _firstpass _secondpass |
| 615 | sleep 2 && continue | 622 | sleep 2 && clear && continue |
| 616 | fi | 623 | fi |
| 617 | set_option ROOTPASSWORD "${_firstpass}" | 624 | set_option ROOTPASSWORD "${_firstpass}" |
| 618 | ROOTPASSWORD_DONE=1 | 625 | ROOTPASSWORD_DONE=1 |
| @@ -631,9 +638,12 @@ set_rootpassword() { · 12 unmodified lines | |||
| 631 | menu_useraccount() { | 638 | menu_useraccount() { |
| 632 | local _firstpass _secondpass _desc | 639 | local _firstpass _secondpass _desc |
| 633 | local _groups _status _group _checklist | 640 | local _groups _status _group _checklist |
| 641 | local _preset | ||
| 634 | 642 | ||
| 635 | while true; do | 643 | 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" | ||
| 637 | if [ $? -eq 0 ]; then | 647 | if [ $? -eq 0 ]; then |
| 638 | set_option USERLOGIN "$(cat $ANSWER)" | 648 | set_option USERLOGIN "$(cat $ANSWER)" |
| 639 | USERLOGIN_DONE=1 | 649 | USERLOGIN_DONE=1 |
| @@ -644,8 +654,10 @@ menu_useraccount() { · 4 unmodified lines | |||
| 644 | done | 654 | done |
| 645 | 655 | ||
| 646 | while true; do | 656 | while true; do |
| 657 | _preset=$(get_option USERNAME) | ||
| 658 | [ -z "$_preset" ] && _preset="Void User" | ||
| 647 | DIALOG --inputbox "Enter a user name for login '$(get_option USERLOGIN)' :" \ | 659 | DIALOG --inputbox "Enter a user name for login '$(get_option USERLOGIN)' :" \ |
| 648 | ${INPUTSIZE} "$(get_option USERLOGIN)" | 660 | ${INPUTSIZE} "$_preset" |
| 649 | if [ $? -eq 0 ]; then | 661 | if [ $? -eq 0 ]; then |
| 650 | set_option USERNAME "$(cat $ANSWER)" | 662 | set_option USERNAME "$(cat $ANSWER)" |
| 651 | USERNAME_DONE=1 | 663 | USERNAME_DONE=1 |
| @@ -656,10 +668,10 @@ menu_useraccount() { · 4 unmodified lines | |||
| 656 | done | 668 | done |
| 657 | 669 | ||
| 658 | while true; do | 670 | while true; do |
| 659 | if [ -n "${_firstpass}" ]; then | 671 | if [ -z "${_firstpass}" ]; then |
| 660 | _desc="Enter the password for login '$(get_option USERLOGIN)' again" | ||
| 661 | else | ||
| 662 | _desc="Enter the password for login '$(get_option USERLOGIN)'" | 672 | _desc="Enter the password for login '$(get_option USERLOGIN)'" |
| 673 | else | ||
| 674 | _desc="$_desc again" | ||
| 663 | fi | 675 | fi |
| 664 | DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE} | 676 | DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE} |
| 665 | if [ $? -eq 0 ]; then | 677 | if [ $? -eq 0 ]; then |
| @@ -670,9 +682,9 @@ menu_useraccount() { · 4 unmodified lines | |||
| 670 | fi | 682 | fi |
| 671 | if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then | 683 | if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then |
| 672 | if [ "${_firstpass}" != "${_secondpass}" ]; then | 684 | 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 |
| 674 | unset _firstpass _secondpass | 686 | unset _firstpass _secondpass |
| 675 | sleep 2 && continue | 687 | sleep 2 && clear && continue |
| 676 | fi | 688 | fi |
| 677 | set_option USERPASSWORD "${_firstpass}" | 689 | set_option USERPASSWORD "${_firstpass}" |
| 678 | USERPASSWORD_DONE=1 | 690 | USERPASSWORD_DONE=1 |
| @@ -1003,7 +1015,8 @@ failed to activate swap on $dev!\ncheck $LOG for errors." ${MSGBOXSIZE} · 324 unmodified lines | |||
| 1003 | vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;; | 1015 | vfat) MKFS="mkfs.vfat -F32"; modprobe vfat >$LOG 2>&1;; |
| 1004 | xfs) MKFS="mkfs.xfs -f"; modprobe xfs >$LOG 2>&1;; | 1016 | xfs) MKFS="mkfs.xfs -f"; modprobe xfs >$LOG 2>&1;; |
| 1005 | esac | 1017 | 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 | ||
| 1007 | echo "Running $MKFS $dev..." >$LOG | 1020 | echo "Running $MKFS $dev..." >$LOG |
| 1008 | $MKFS $dev >$LOG 2>&1; rv=$? | 1021 | $MKFS $dev >$LOG 2>&1; rv=$? |
| 1009 | if [ $rv -ne 0 ]; then | 1022 | if [ $rv -ne 0 ]; then |
| @@ -1087,13 +1100,38 @@ umount_filesystems() { · 77 unmodified lines | |||
| 1087 | umount $TARGETDIR >$LOG 2>&1 | 1100 | umount $TARGETDIR >$LOG 2>&1 |
| 1088 | } | 1101 | } |
| 1089 | 1102 | ||
| 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 | |||
| 1090 | copy_rootfs() { | 1118 | copy_rootfs() { |
| 1091 | DIALOG --title "Check $LOG for details" \ | 1119 | local tar_in="--create --one-file-system" |
| 1092 | --infobox "Copying live image to target rootfs, please wait ..." 4 60 | 1120 | local tar_out="--extract --preserve-permissions" |
| 1093 | LANG=C cp -axvnu / $TARGETDIR >$LOG 2>&1 | 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 | ||
| 1094 | if [ $? -ne 0 ]; then | 1131 | if [ $? -ne 0 ]; then |
| 1095 | DIE 1 | 1132 | DIE 1 |
| 1096 | fi | 1133 | fi |
| 1134 | unset copy_total copy_count copy_percent | ||
| 1097 | } | 1135 | } |
| 1098 | 1136 | ||
| 1099 | install_packages() { | 1137 | install_packages() { |
| @@ -1171,14 +1209,13 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return · 71 unmodified lines | |||
| 1171 | echo "Removing $USERNAME live user from targetdir ..." >$LOG | 1209 | echo "Removing $USERNAME live user from targetdir ..." >$LOG |
| 1172 | chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1 | 1210 | chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1 |
| 1173 | sed -i -e "/$USERNAME ALL=.*/d" $TARGETDIR/etc/sudoers | 1211 | sed -i -e "/$USERNAME ALL=.*/d" $TARGETDIR/etc/sudoers |
| 1174 | DIALOG --title "Check $LOG for details" \ | 1212 | TITLE="Check $LOG for details ..." |
| 1175 | --infobox "Rebuilding initramfs for target ..." 4 60 | 1213 | INFOBOX "Rebuilding initramfs for target ..." 4 60 |
| 1176 | echo "Rebuilding initramfs for target ..." >$LOG | 1214 | echo "Rebuilding initramfs for target ..." >$LOG |
| 1177 | # mount required fs | 1215 | # mount required fs |
| 1178 | mount_filesystems | 1216 | mount_filesystems |
| 1179 | chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1 | 1217 | chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&1 |
| 1180 | DIALOG --title "Check $LOG for details" \ | 1218 | INFOBOX "Removing temporary packages from target ..." 4 60 |
| 1181 | --infobox "Removing temporary packages from target ..." 4 60 | ||
| 1182 | echo "Removing temporary packages from target ..." >$LOG | 1219 | echo "Removing temporary packages from target ..." >$LOG |
| 1183 | xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&1 | 1220 | xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&1 |
| 1184 | rmdir $TARGETDIR/mnt/target | 1221 | rmdir $TARGETDIR/mnt/target |
| @@ -1189,7 +1226,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return · 4 unmodified lines | |||
| 1189 | install_packages | 1226 | install_packages |
| 1190 | fi | 1227 | fi |
| 1191 | 1228 | ||
| 1192 | DIALOG --infobox "Applying installer settings..." 4 60 | 1229 | INFOBOX "Applying installer settings..." 4 60 |
| 1193 | 1230 | ||
| 1194 | # copy target fstab. | 1231 | # copy target fstab. |
| 1195 | install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab | 1232 | install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab |