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
93 return $?93 return $?
94}94}
95 95
96INFOBOX() {
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
96DIE() {103DIE() {
97 rval=$1104 rval=$1
98 [ -z "$rval" ] && rval=0105 [ -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 ISO3166525 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}; do528 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))|" >> $TMPFILE531 echo "$f|$(iso639_language $ISO639) ($(iso3166_country $ISO3166))|" >> $TMPFILE
526 done532 done
533 clear
527 # Sort by ISO-639 language names534 # 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 $TMPFILE536 rm -f $TMPFILE
@@ -596,10 +603,10 @@ menu_rootpassword() { · 66 unmodified lines
596 local _firstpass _secondpass _desc603 local _firstpass _secondpass _desc
597 604
598 while true; do605 while true; do
599 if [ -n "${_firstpass}" ]; then606 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 fi610 fi
604 DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}611 DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
605 if [ $? -eq 0 ]; then612 if [ $? -eq 0 ]; then
@@ -610,9 +617,9 @@ menu_rootpassword() { · 4 unmodified lines
610 fi617 fi
611 if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then618 if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
612 if [ "${_firstpass}" != "${_secondpass}" ]; then619 if [ "${_firstpass}" != "${_secondpass}" ]; then
613 DIALOG --infobox "Passwords do not match! Please enter again." 6 80620 INFOBOX "Passwords do not match! Please enter again." 6 60
614 unset _firstpass _secondpass621 unset _firstpass _secondpass
615 sleep 2 && continue622 sleep 2 && clear && continue
616 fi623 fi
617 set_option ROOTPASSWORD "${_firstpass}"624 set_option ROOTPASSWORD "${_firstpass}"
618 ROOTPASSWORD_DONE=1625 ROOTPASSWORD_DONE=1
@@ -631,9 +638,12 @@ set_rootpassword() { · 12 unmodified lines
631menu_useraccount() {638menu_useraccount() {
632 local _firstpass _secondpass _desc639 local _firstpass _secondpass _desc
633 local _groups _status _group _checklist640 local _groups _status _group _checklist
641 local _preset
634 642
635 while true; do643 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 ]; then647 if [ $? -eq 0 ]; then
638 set_option USERLOGIN "$(cat $ANSWER)"648 set_option USERLOGIN "$(cat $ANSWER)"
639 USERLOGIN_DONE=1649 USERLOGIN_DONE=1
@@ -644,8 +654,10 @@ menu_useraccount() { · 4 unmodified lines
644 done654 done
645 655
646 while true; do656 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 ]; then661 if [ $? -eq 0 ]; then
650 set_option USERNAME "$(cat $ANSWER)"662 set_option USERNAME "$(cat $ANSWER)"
651 USERNAME_DONE=1663 USERNAME_DONE=1
@@ -656,10 +668,10 @@ menu_useraccount() { · 4 unmodified lines
656 done668 done
657 669
658 while true; do670 while true; do
659 if [ -n "${_firstpass}" ]; then671 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 fi675 fi
664 DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}676 DIALOG --insecure --passwordbox "${_desc}" ${INPUTSIZE}
665 if [ $? -eq 0 ]; then677 if [ $? -eq 0 ]; then
@@ -670,9 +682,9 @@ menu_useraccount() { · 4 unmodified lines
670 fi682 fi
671 if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then683 if [ -n "${_firstpass}" -a -n "${_secondpass}" ]; then
672 if [ "${_firstpass}" != "${_secondpass}" ]; then684 if [ "${_firstpass}" != "${_secondpass}" ]; then
673 DIALOG --infobox "Passwords do not match! Please enter again." 6 80685 INFOBOX "Passwords do not match! Please enter again." 6 60
674 unset _firstpass _secondpass686 unset _firstpass _secondpass
675 sleep 2 && continue687 sleep 2 && clear && continue
676 fi688 fi
677 set_option USERPASSWORD "${_firstpass}"689 set_option USERPASSWORD "${_firstpass}"
678 USERPASSWORD_DONE=1690 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 esac1017 esac
1006 DIALOG --infobox "Creating filesystem $fstype on $dev for $mntpt ..." 8 601018 TITLE="Check $LOG for details ..."
1019 INFOBOX "Creating filesystem $fstype on $dev for $mntpt ..." 8 60
1007 echo "Running $MKFS $dev..." >$LOG1020 echo "Running $MKFS $dev..." >$LOG
1008 $MKFS $dev >$LOG 2>&1; rv=$?1021 $MKFS $dev >$LOG 2>&1; rv=$?
1009 if [ $rv -ne 0 ]; then1022 if [ $rv -ne 0 ]; then
@@ -1087,13 +1100,38 @@ umount_filesystems() { · 77 unmodified lines
1087 umount $TARGETDIR >$LOG 2>&11100 umount $TARGETDIR >$LOG 2>&1
1088}1101}
1089 1102
1103log_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
1090copy_rootfs() {1118copy_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 601120 local tar_out="--extract --preserve-permissions"
1093 LANG=C cp -axvnu / $TARGETDIR >$LOG 2>&11121 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 ]; then1131 if [ $? -ne 0 ]; then
1095 DIE 11132 DIE 1
1096 fi1133 fi
1134 unset copy_total copy_count copy_percent
1097}1135}
1098 1136
1099install_packages() {1137install_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 ..." >$LOG1209 echo "Removing $USERNAME live user from targetdir ..." >$LOG
1172 chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&11210 chroot $TARGETDIR userdel -r $USERNAME >$LOG 2>&1
1173 sed -i -e "/$USERNAME ALL=.*/d" $TARGETDIR/etc/sudoers1211 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 601213 INFOBOX "Rebuilding initramfs for target ..." 4 60
1176 echo "Rebuilding initramfs for target ..." >$LOG1214 echo "Rebuilding initramfs for target ..." >$LOG
1177 # mount required fs1215 # mount required fs
1178 mount_filesystems1216 mount_filesystems
1179 chroot $TARGETDIR dracut --no-hostonly --add-drivers "ahci" --force >>$LOG 2>&11217 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 ..." >$LOG1219 echo "Removing temporary packages from target ..." >$LOG
1183 xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&11220 xbps-remove -r $TARGETDIR -Ry dialog >>$LOG 2>&1
1184 rmdir $TARGETDIR/mnt/target1221 rmdir $TARGETDIR/mnt/target
@@ -1189,7 +1226,7 @@ ${BOLD}Do you want to continue?${RESET}" 20 80 || return · 4 unmodified lines
1189 install_packages1226 install_packages
1190 fi1227 fi
1191 1228
1192 DIALOG --infobox "Applying installer settings..." 4 601229 INFOBOX "Applying installer settings..." 4 60
1193 1230
1194 # copy target fstab.1231 # copy target fstab.
1195 install -Dm644 $TARGET_FSTAB $TARGETDIR/etc/fstab1232 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