[28338] in Source-Commits
scripts commit: Add debugging support to installer
daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Thu Jul 10 10:08:25 2014
Date: Thu, 10 Jul 2014 10:08:19 -0400
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201407101408.s6AE8Jvu009287@drugstore.mit.edu>
To: source-commits@MIT.EDU
https://github.com/mit-athena/scripts/commit/8e6e7389edaec380fb38d51936cee741806569d4
commit 8e6e7389edaec380fb38d51936cee741806569d4
Author: Jonathan Reed <jdreed@mit.edu>
Date: Wed Jun 4 13:29:23 2014 -0400
Add debugging support to installer
Add better debugging support to the installer. Prompt
the user in stage1, and then in stage2, check the arguments
passed, and create a flag file if debugging is enabled. The flag
file is checked by the postinstall script, and can be used elsewhere.
installer/pxe/stage1/debathena/installer.sh | 24 +++++++++++++++++-------
installer/pxe/trusty/debathena/installer.sh | 11 ++++++++++-
installer/pxe/trusty/debathena/postinstall.sh | 20 +++++++++++++++++++-
3 files changed, 46 insertions(+), 9 deletions(-)
diff --git a/installer/pxe/stage1/debathena/installer.sh b/installer/pxe/stage1/debathena/installer.sh
index 8d763e8..ca785df 100644
--- a/installer/pxe/stage1/debathena/installer.sh
+++ b/installer/pxe/stage1/debathena/installer.sh
@@ -173,6 +173,7 @@ if [ -f "/debathena/version" ]; then
debug "SVN: " "$(cat /debathena/version)"
fi
+debugmode=""
debug "Mirror $mirrorsite Type $installertype Arch $arch"
echo "Welcome to Athena, Stage 1 Installer"
@@ -181,7 +182,9 @@ echo
while [ -z "$pxetype" ] ; do
echo
echo "Will install ${ccc}$distro${nnn} ($arch) using $installertype installer"
- echo "from $mirrorsite using $partitioning partitioning"
+ echo -n "from $mirrorsite using $partitioning partitioning"
+ [ -n "$debugmode" ] && echo -n " with debugging."
+ echo
echo
echo "Choose one:"
echo
@@ -199,11 +202,9 @@ while [ -z "$pxetype" ] ; do
echo " 4: /bin/sh (for rescue purposes)"
echo
echo " Advanced users only:"
- echo " m: Select a different mirror. "
- echo " b: Toggle between beta and production installer. "
- echo " d: Change the distro (version)."
- echo " a: Change architecture."
- echo " p: Toggle between manual and auto partitioning. "
+ echo " m: Select a different mirror. d: Change the distro (version)."
+ echo " a: Change architecture. z: Toggle debug mode."
+ echo " b: Toggle beta installer p: Toggle manual partitioning."
echo
echo -n "Choose: "
read r
@@ -276,6 +277,15 @@ while [ -z "$pxetype" ] ; do
fi
unset oldarch
;;
+ z|Z)
+ if [ -n "$debugmode" ]; then
+ echo "Turning debug mode off."
+ debugmode=""
+ else
+ echo "Turning debug mode on."
+ debugmode="da/dbg=1"
+ fi
+ ;;
*)
echo "Choose one of the above, please.";;
esac
@@ -426,7 +436,7 @@ fi
kargs="$knetinfo $kbdcode $acpi locale=en_US interface=auto \
url=http://18.9.60.73/installer/$distro/debathena.preseed \
da/pxe=$pxetype da/i=$installertype da/m=$mirrorsite \
-da/part=$partitioning $extra_kargs --"
+da/part=$partitioning $debugmode $extra_kargs --"
echo "Continuing in five seconds..."
if [ "$test" = "test" ]; then
diff --git a/installer/pxe/trusty/debathena/installer.sh b/installer/pxe/trusty/debathena/installer.sh
index 53c559a..364d746 100644
--- a/installer/pxe/trusty/debathena/installer.sh
+++ b/installer/pxe/trusty/debathena/installer.sh
@@ -36,6 +36,7 @@ installertype=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/i= | sed -e 's/.*=//'
mirrorsite=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/m= | sed -e 's/.*=//'`
partitioning=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/part= | sed -e 's/.*=//'`
nodhcp=`sed -e 's/ /\n/g' < /proc/cmdline | grep netcfg/disable_dhcp= | sed -e 's/.*=//'`
+debugmode=`sed -e 's/ /\n/g' < /proc/cmdline | grep da/dbg= | sed -e 's/.*=//'`
echo "Picked up values from command line:
@@ -163,7 +164,15 @@ EOF
echo "$pxetype" > pxe-install-flag
echo "Initial Debathena installer complete; exiting preconfig to start main install."
-if [ "$pxetype" != "cluster" ] || [ "$installertype" = "beta" ]; then
+if [ "$pxetype" != "cluster" ]; then
+ echo "Hit return to continue."
+ read r
+fi
+if [ "$debugmode" = "1" ]; then
+ echo "Installer debugging enabled. The install will pause at"
+ echo "various breakpoints. You can end debugging at any time"
+ echo "by removing the /debathena/debug file."
+ touch /debathena/debug
echo "Hit return to continue."
read r
fi
diff --git a/installer/pxe/trusty/debathena/postinstall.sh b/installer/pxe/trusty/debathena/postinstall.sh
index 8952e9f..ae9aace 100644
--- a/installer/pxe/trusty/debathena/postinstall.sh
+++ b/installer/pxe/trusty/debathena/postinstall.sh
@@ -3,6 +3,16 @@
# This is only invoked when the relevant preseed entry is passed in
# during the preinstall questioning. (Thus, not for vanilla installs.)
+breakpoint() {
+ # Yes, we want to test the file existence each time, so that
+ # it's possible to continue automatically by removing the file
+ if [ -f /debathena/debug ]; then
+ echo "breakpoint: $@" > /dev/tty5
+ echo "(press enter to resume)" > /dev/tty5
+ read dummy < /dev/tty5
+ fi
+}
+
cp /debathena/preseed /target/root/debathena.preseed
cp /debathena/install-debathena.sh /target/root
if test -f /debathena/pxe-install-flag ; then
@@ -11,13 +21,17 @@ fi
. /lib/chroot-setup.sh
+chvt 5
+
+breakpoint "in postinstall.sh, before setting up the chroot."
+
chroot /target dpkg-divert --rename --add /usr/sbin/policy-rc.d
if ! chroot_setup; then
logger -t postinstall.sh -- "Target system not usable. Can't install Debathena."
exit 1
fi
-chvt 5
+breakpoint "in postinstall.sh, before running install-debathena.sh"
# Something like this approach was once said to fail due to lingering
# processes keeping the pipeline open and the script hung. According to
@@ -38,7 +52,11 @@ fi
sleep 5
+breakpoint "in postinstall.sh, after install-debathena.sh"
+
chroot_cleanup
chroot /target dpkg-divert --rename --remove /usr/sbin/policy-rc.d
+breakpoint "at the end of postinstall.sh"
+
chvt 1