installer: ditch repair/upgrade mode

Remove the (at least on my system) broken repair/upgrade mode from
the installer. At the same time improve the formatting/wording of
some screens. Should be a bit simpler now.
This commit is contained in:
Olli Salonen 2016-10-19 22:48:56 +03:00
parent d523e6c26c
commit 85b9dc63d7

View File

@ -112,71 +112,11 @@ create_device_list() {
done
}
create_partition_list() {
# get an overview of all partitions of a specified device
# usage: create_partition_list /dev/sda
# uses: get_partition
# provides: PARTITION_NUMBER, PARTITION_SIZE, PARTITION_FORMAT,
# PARTITION_LIST, PARTITIONS (get_partition)
PARTITION_NUMBER=""
PARTITION_SIZE=""
PARTITION_FORMAT=""
PARTITION_LIST=""
get_partition $1
for partition in $PARTITIONS; do
PARTITION_NUMBER=$(parted -s -m $1 print |grep -v ^/dev |grep -v BYT | cut -f1 -d ":")
PARTITION_SIZE=$(parted -s -m $1 print |grep -v ^/dev |grep -v BYT | cut -f4 -d ":")
PARTITION_FORMAT=$(parted -s -m $1 print |grep -v ^/dev |grep -v BYT | cut -f5 -d ":")
PARTITION_LIST=" $PARTITION_LIST \n Partition $1$PARTITION_NUMBER Size: $PARTITION_SIZE Format: $PARTITION_FORMAT"
done
}
do_install_mbr() {
# show menu
MSG_TITLE="(RE)INSTALL MBR"
MSG_MENU="Please select where to install MBR.\n\n Please select a device:"
MSG_CANCEL="Back"
create_device_list
whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
--title "$MSG_TITLE" --menu "$MSG_MENU" 20 50 5 \
$DEVICE_LIST 2> $TMPDIR/device_for_install
# now we must do everything
case $? in
0)
INSTALL_DEVICE=$(cat "$TMPDIR/device_for_install")
# installing mbr
prompt_gpt
if [ "$GPT" = "1" ]; then
cat /usr/share/syslinux/gptmbr.bin > $INSTALL_DEVICE
else
cat /usr/share/syslinux/mbr.bin > $INSTALL_DEVICE
fi
msg_install_ready "Master Boot Record installed on $INSTALL_DEVICE"
;;
1)
menu_main
;;
255)
do_poweroff
;;
esac
}
do_install_quick() {
# show menu
MSG_TITLE="QUICK INSTALL MENU"
MSG_MENU="\nUse the up/down arrows to select the correct device.\n\n Please select a device:"
MSG_MENU="\nUse the up/down arrows to select the device you wish to install to.\n\nPlease select a device:"
MSG_CANCEL="Back"
DIALOG_OPTIONS="--defaultno"
create_device_list
@ -206,7 +146,7 @@ do_install_quick() {
# check for confirmation (twice!)
MSG_TITLE="Confirmation before installing"
MSG_DETAIL="\nIf you continue the target disk will be wiped out:\n\n$INSTALL_DEVICE_FULL\n\n"
MSG_DETAIL="\nIf you continue the contents of the target disk will be wiped out:\n\n$INSTALL_DEVICE_FULL\n\n"
DIALOG_OPTIONS="--defaultno"
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" \
$DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0
@ -365,11 +305,11 @@ do_install_quick() {
msg_progress_install "100" "Remove $TMPDIR/part2"
rmdir $TMPDIR/part2 >> $LOGFILE 2>&1
fi
} | whiptail --gauge "Please wait while your system is being setup ..." 6 70 0
} | whiptail --gauge "Please wait while your system is being setup ..." 6 73 0
# install complete
MSG_TITLE="@DISTRONAME@ Install Complete"
MSG_DETAIL="You may now remove the install media and reboot\n"
MSG_DETAIL="You may now remove the install media and reboot.\n"
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_DETAIL" 7 52
menu_main
@ -383,137 +323,12 @@ do_install_quick() {
esac
}
do_install_custom() {
# show menu
MSG_TITLE="REPAIR/UPGRADE MENU"
MSG_MENU="\nUse the up/down arrows to select the correct partition where you want to overwrite KERNEL and SYSTEM files.\n\n Please select a partition:"
MSG_CANCEL="Back"
DIALOG_OPTIONS="--defaultno"
get_device_unmount
if [ "$DEVICES" = "" ]; then
msg_no_device
fi
PARTITION_LIST=""
for device in $DEVICES; do
get_partition $device
for partition in $PARTITIONS; do
LABEL=$(tune2fs -l $device$partition | awk 'BEGIN {FS=":"} /Filesystem volume name/ {gsub(/ /,"",$2); print $2}')
if [ "$LABEL" = "$DISKLABEL_SYSTEM" ]; then
DEVICE_MODEL=$(parted -s $device -m print | grep ^$device | cut -f7 -d ":" | sed "s/;//")
DEVICE_SIZE=$(parted -s $device -m print | grep ^$device | cut -f2 -d ":")
DEVICE_NAME=$(echo $DEVICE_MODEL ${DEVICE_SIZE} | sed 's/ /_/g')
PARTITION_LIST="$PARTITION_LIST $device$partition $DEVICE_NAME"
fi
done
done
if [ "$PARTITION_LIST" = "" ]; then
msg_no_device
fi
whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
$DIALOG_OPTIONS --title "$MSG_TITLE" --menu "$MSG_MENU" 20 50 5 \
$PARTITION_LIST 2> $TMPDIR/device_for_install
# now we must do everything
case $? in
0)
INSTALL_PARTITION=$(cat "$TMPDIR/device_for_install")
INSTALL_PARTITION_FULL=$(echo $PARTITION_LIST | sed "s|.*$INSTALL_PARTITION \([^ ]*\).*|$INSTALL_PARTITION \1|")
# check for confirmation (twice!)
MSG_TITLE="Confirmation before copying"
MSG_DETAIL="\nIf you continue the target partition will be\noverwritten with new KERNEL and SYSTEM files:\n\n$INSTALL_PARTITION_FULL\n\n"
DIALOG_OPTIONS="--defaultno"
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" \
$DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0
if [ $? -ne 0 ]; then
menu_main
fi
MSG_TITLE="Confirmation before copying"
MSG_DETAIL="\nThis is last chance to abort the copying!\n\nIf you continue the target partition will be\noverwritten with new KERNEL and SYSTEM files:\n\n$INSTALL_PARTITION_FULL\n\n\n"
DIALOG_OPTIONS="--defaultno"
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" \
$DIALOG_OPTIONS --yesno "$MSG_DETAIL" 0 0
if [ $? -ne 0 ]; then
menu_main
fi
{
# mount system partition
msg_progress_install "5" "creating $TMPDIR/part1"
mkdir -p $TMPDIR/part1 >> $LOGFILE 2>&1
msg_progress_install "10" "mounting $INSTALL_PARTITION to $TMPDIR/part1"
mount -t ext4 $INSTALL_PARTITION $TMPDIR/part1 >> $LOGFILE 2>&1
# check for enough target space
msg_progress_install "15" "checking for space on $INSTALL_PARTITION"
KERNEL_SIZE=$(stat -t /flash/KERNEL | awk '{print $2}')
SYSTEM_SIZE=$(stat -t /flash/SYSTEM | awk '{print $2}')
SRC_SIZE=$(( $KERNEL_SIZE + $SYSTEM_SIZE ))
DEST_SIZE=$(df $TMPDIR/part1 | awk '/[0-9]%/{print $4}')
DEST_SIZE=$(( $DEST_SIZE * 1024 ))
if [ -f $TMPDIR/part1/KERNEL ]; then
KERNEL_SIZE=$(stat -t $TMPDIR/part1/KERNEL | awk '{print $2}')
DEST_SIZE=$(( $DEST_SIZE + $KERNEL_SIZE ))
fi
if [ -f $TMPDIR/part1/SYSTEM ]; then
SYSTEM_SIZE=$(stat -t $TMPDIR/part1/SYSTEM | awk '{print $2}')
DEST_SIZE=$(( $DEST_SIZE + $SYSTEM_SIZE ))
fi
if [ $SRC_SIZE -ge $DEST_SIZE ]; then
umount $TMPDIR/part1 >> $LOGFILE 2>&1
rmdir $TMPDIR/part1 >> $LOGFILE 2>&1
msg_target_space
menu_main
fi
# install system files
msg_progress_install "20" "installing Kernel"
cp /flash/KERNEL $TMPDIR/part1 >> $LOGFILE 2>&1
msg_progress_install "40" "installing System"
cp /flash/SYSTEM $TMPDIR/part1 >> $LOGFILE 2>&1
sync
# umount system partition, remove mountpoint
msg_progress_install "95" "unmount $TMPDIR/part1"
umount $TMPDIR/part1 >> $LOGFILE 2>&1
msg_progress_install "100" "remove $TMPDIR/part1"
rmdir $TMPDIR/part1 >> $LOGFILE 2>&1
} | whiptail --gauge "Please wait while your system is being setup ..." 6 70 0
# install complete
MSG_TITLE="@DISTRONAME@ Install Complete"
MSG_DETAIL="\nYou may now remove the install media and reboot\n"
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_DETAIL" 6 52
menu_main
;;
1)
menu_main
;;
255)
do_poweroff
;;
esac
}
msg_no_device() {
# show a warning dialog if we dont find not mounted devices for install and return to main menu
MSG_TITLE="WARNING"
MSG_INFOBOX=" No devices were found. "
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 9 70
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 9 73
menu_main
}
@ -521,9 +336,9 @@ msg_no_device() {
msg_target_space() {
# show an error dialog for missing space
MSG_TITLE="TARGET SPACE"
MSG_INFOBOX="Not enough target space!\nCopying aborted.\n"
MSG_INFOBOX="Not enough target space!\nInstallation aborted.\n"
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 8 70
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_INFOBOX" 9 73
menu_main
}
@ -543,7 +358,7 @@ msg_install_ready() {
# show a dialog that we have installed
MSG_TITLE="INFORMATION"
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox " $1" 7 70
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox " $1" 7 73
menu_main
}
@ -582,27 +397,28 @@ prompt_backup_unpack() {
menu_main() {
# show the mainmenu
MSG_TITLE="MAIN MENU"
MSG_MENU="\nQuick Install: do a default installation on a specific device \
(this will delete ALL data on this device!) \
\nRepair / Upgrade: do repair / upgrade \
\nShow logfile: show and save the logfile \
\n \
\nPlease select:"
MSG_CANCEL="Reboot"
MSG_MENU="\nWelcome to @DISTRONAME@ installation tool! \
\n
This tool is used to copy @DISTRONAME@ from the installation media \
to your disk or other device. You'll be up and running in no time! \
Please note that the contents of the disk you choose will be wiped \
out during the installation. \
\n\nPlease select:"
MSG_CANCEL="Close"
whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
--title "$MSG_TITLE" --menu "$MSG_MENU" 20 70 5 \
1 "Quick Install of @DISTRONAME@" \
2 "Repair / Upgrade" \
3 "Show logfile" 2> $TMPDIR/mainmenu
--title "$MSG_TITLE" --menu "$MSG_MENU" 18 73 3 \
1 "Install @DISTRONAME@" \
2 "Show the log file" \
3 "Reboot" 2> $TMPDIR/mainmenu
case $? in
0)
ITEM_MAINMENU=$(cat "$TMPDIR/mainmenu")
case $ITEM_MAINMENU in
1) do_install_quick; break;;
2) do_install_custom; break;;
3) logfile_show; break;;
2) logfile_show; break;;
3) do_reboot;
esac
;;
1)
@ -615,7 +431,7 @@ menu_main() {
}
logfile_show() {
whiptail --textbox "$LOGFILE" 20 70 --scrolltext
whiptail --textbox "$LOGFILE" 20 73 --scrolltext
clear
menu_main
}
@ -649,7 +465,8 @@ rm -rf $TMPDIR
mkdir -p $TMPDIR
#create log file
touch "$LOGFILE"
echo "@DISTRONAME@ Installer - $OS_VERSION started at:" > $LOGFILE
date >> $LOGFILE
# generate the en_US.UTF-8 locale to enable line drawing
mkdir -p $TMPDIR/locale