installer: add option to save installation log in /flash/logs; include extra system info

This commit is contained in:
MilhouseVH 2018-05-16 03:47:18 +01:00
parent d2ab6680a7
commit ab60ac71fc

View File

@ -56,6 +56,36 @@ dbglg() {
echo "" >> $LOGFILE echo "" >> $LOGFILE
} }
log_system_status() {
echo "# cat /proc/mounts"
cat /proc/mounts
echo
echo "# df"
df
echo
echo "# df -h"
df -h
echo
echo "# parted -s -m -l"
parted -s -m -l
echo
echo "# blkid"
blkid
echo
echo "# UEFI (if directory exists)"
ls -la /sys/firmware/efi
echo
echo "# Disk sizes (bytes)"
grep . /sys/block/*/size
echo
}
get_device_unmount() { get_device_unmount() {
# get all unmounted devices # get all unmounted devices
# usage: get_devices_unmount # usage: get_devices_unmount
@ -221,6 +251,7 @@ do_install_quick() {
UUID_SYSTEM="$(blkid --output udev ${INSTALL_DEVICE}${PART1} | grep ^ID_FS_UUID= | cut -d= -f2)" UUID_SYSTEM="$(blkid --output udev ${INSTALL_DEVICE}${PART1} | grep ^ID_FS_UUID= | cut -d= -f2)"
UUID_STORAGE="$(blkid --output udev ${INSTALL_DEVICE}${PART2} | grep ^ID_FS_UUID= | cut -d= -f2)" UUID_STORAGE="$(blkid --output udev ${INSTALL_DEVICE}${PART2} | grep ^ID_FS_UUID= | cut -d= -f2)"
echo "" >> $LOGFILE
echo "UUID_SYSTEM : ${UUID_SYSTEM}" >> $LOGFILE echo "UUID_SYSTEM : ${UUID_SYSTEM}" >> $LOGFILE
echo "UUID_STORAGE: ${UUID_STORAGE}" >> $LOGFILE echo "UUID_STORAGE: ${UUID_STORAGE}" >> $LOGFILE
@ -329,6 +360,7 @@ prompt_gpt() {
GPT="0" GPT="0"
UEFI="0" UEFI="0"
# Get size in GB. # Get size in GB.
# 2^41 bytes is the DOS limit (2199023255552 bytes, 2.2TB). Use GUID Partition Table.>= 2200GB
INSTALL_DEVICE_SIZE=$(($(cat /sys/block/${INSTALL_DEVICE#/dev/}/size)*512/1000/1000/1000)) INSTALL_DEVICE_SIZE=$(($(cat /sys/block/${INSTALL_DEVICE#/dev/}/size)*512/1000/1000/1000))
if [ "$INSTALL_DEVICE_SIZE" -ge 2200 ] 2>/dev/null; then if [ "$INSTALL_DEVICE_SIZE" -ge 2200 ] 2>/dev/null; then
GPT="1" GPT="1"
@ -369,10 +401,11 @@ out during the installation. \
MSG_CANCEL="Close" MSG_CANCEL="Close"
whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \ whiptail --backtitle "$BACKTITLE" --cancel-button "$MSG_CANCEL" \
--title "$MSG_TITLE" --menu "$MSG_MENU" 18 73 3 \ --title "$MSG_TITLE" --menu "$MSG_MENU" 18 73 4 \
1 "Install @DISTRONAME@" \ 1 "Install @DISTRONAME@" \
2 "View installation log" \ 2 "View installation log" \
3 "Reboot" 2> $TMPDIR/mainmenu 3 "Save installation log" \
4 "Reboot" 2> $TMPDIR/mainmenu
case $? in case $? in
0) 0)
@ -380,7 +413,8 @@ out during the installation. \
case $ITEM_MAINMENU in case $ITEM_MAINMENU in
1) do_install_quick;; 1) do_install_quick;;
2) logfile_show;; 2) logfile_show;;
3) do_reboot;; 3) logfile_save;;
4) do_reboot;;
esac esac
;; ;;
1) 1)
@ -396,6 +430,20 @@ logfile_show() {
whiptail --textbox "$LOGFILE" 20 73 --scrolltext --backtitle "$BACKTITLE" whiptail --textbox "$LOGFILE" 20 73 --scrolltext --backtitle "$BACKTITLE"
} }
logfile_save() {
mount -o remount,rw /flash
mkdir -p $(dirname $LOGBACKUP)
cp $LOGFILE $LOGBACKUP
sync
mount -o remount,ro /flash
MSG_TITLE="@DISTRONAME@ Log Saved"
MSG_DETAIL="Log location: ${LOGBACKUP}\n"
whiptail --backtitle "$BACKTITLE" --title "$MSG_TITLE" --msgbox "$MSG_DETAIL" 7 52
}
do_reboot() { do_reboot() {
# reboot on request # reboot on request
clear clear
@ -416,6 +464,7 @@ BACKTITLE="@DISTRONAME@ Installer - $OS_VERSION"
TMPDIR="/tmp/installer" TMPDIR="/tmp/installer"
LOGFILE="$TMPDIR/install.log" LOGFILE="$TMPDIR/install.log"
LOGBACKUP="/flash/logs/$(date +%Y%m%d%H%M%S).log"
export COLORTERM="1" export COLORTERM="1"
export NEWT_COLORS="$WHIPTAIL_COLORS" export NEWT_COLORS="$WHIPTAIL_COLORS"
@ -428,6 +477,9 @@ mkdir -p $TMPDIR
echo "@DISTRONAME@ Installer - $OS_VERSION started at:" > $LOGFILE echo "@DISTRONAME@ Installer - $OS_VERSION started at:" > $LOGFILE
date >> $LOGFILE date >> $LOGFILE
dbglg "System status"
log_system_status >> $LOGFILE 2>&1
# generate the en_US.UTF-8 locale to enable line drawing # generate the en_US.UTF-8 locale to enable line drawing
mkdir -p $TMPDIR/locale mkdir -p $TMPDIR/locale
localedef -i en_US -f UTF-8 $TMPDIR/locale/en_US.UTF-8 localedef -i en_US -f UTF-8 $TMPDIR/locale/en_US.UTF-8