summaryrefslogtreecommitdiffstats
path: root/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs
diff options
context:
space:
mode:
authorMilton Miller <miltonm@us.ibm.com>2016-02-05 13:04:29 -0600
committerMilton D. Miller II <miltonm@us.ibm.com>2016-02-09 11:07:52 -0600
commit225098264b82f9b6bbbe64856189d3df04949f04 (patch)
tree7e63341024d7cc1166b843d02f9dff211684cff5 /meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs
parentba65b7b2c82794127cb6015a5c0d72903dbe326e (diff)
downloadtalos-openbmc-225098264b82f9b6bbbe64856189d3df04949f04.tar.gz
talos-openbmc-225098264b82f9b6bbbe64856189d3df04949f04.zip
obmc-initfs: factor debug and takeover
Factor out sulogin and init takeover with a message. This is mostly a refactor and message update. It also makes the repair opportunity logic consistent in asking for a password during init and looping over the chroot verification. Signed-off-by: Milton Miller <miltonm@us.ibm.com>
Diffstat (limited to 'meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs')
-rw-r--r--meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh66
1 files changed, 49 insertions, 17 deletions
diff --git a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
index bc7138cf1..4c2a98a96 100644
--- a/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
+++ b/meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh
@@ -30,6 +30,34 @@ findmtd() {
echo $m
}
+debug_takeover() {
+ echo "$@"
+ test -n "$@" && echo Enter password to try to manually fix.
+ cat << HERE
+After fixing run exit to continue this script, or reboot -f to retry, or
+touch /takeover and exit to become PID 1 allowing editing of this script.
+HERE
+
+ while ! sulogin && ! test -f /takeover
+ do
+ echo getty failed, retrying
+ done
+
+ # Touch /takeover in the above getty to become pid 1
+ if test -e /takeover
+ then
+ cat << HERE
+
+Takeover of init requested. Executing /bin/sh as PID 1.
+When finished exec new init or cleanup and run reboot -f.
+
+Warning: No job control! Shell exit will panic the system!
+HERE
+ export PS1=init#\
+ exec /bin/sh
+ fi
+}
+
env=$(findmtd u-boot-env)
if test -n $env
then
@@ -52,21 +80,20 @@ init=/sbin/init
echo rofs = $rofs $rofst rwfs = $rwfs $rwfst
-if grep -w debug-init-sh /proc/cmdline ||
- ! mount $rwdev $rwdir -t $rwfst -o $rwopts
+if grep -w debug-init-sh /proc/cmdline
then
- echo Please mount the rw file system on $rwdir from this shell
- while ! sulogin && ! test -f /takeover
- do
- echo getty failed, retrying
- done
+ debug_takeover "Debug initial shell requested by command line."
fi
-# Touch /takeover in the above getty to become pid 1
-if test -e /takeover
+if ! mount $rwdev $rwdir -t $rwfst -o $rwopts
then
- export PS1=init#\
- exec /bin/sh
+ msg="$(cat)" << HERE
+
+Mounting read-write $rwdev filesystem failed. Please fix and run
+ mount $rwdev $rwdir -t $rwfs -o $rwopts
+to to continue, or do change nothing to run from RAM for this boot.
+HERE
+ debug_takeover "$msg"
fi
mount $rodev $rodir -t $rofst -o $roopts
@@ -77,12 +104,17 @@ mkdir -p $work
mount -t overlay -o lowerdir=$rodir,upperdir=$upper,workdir=$work cow /root
-if ! chroot /root /bin/sh -c "test -x '$init' -a -s '$init'"
-then
- echo "Unable to confirm /sbin/init is an executable non-empty file."
- echo "Change Root test failed! Invoking emergency shell."
- PS1=rescue#\ sulogin
-fi
+while ! chroot /root /bin/sh -c "test -x '$init' -a -s '$init'"
+do
+ msg="$(cat)" << HERE
+
+Unable to confirm /sbin/init is an executable non-empty file
+in merged file system mounted at /root.
+
+Change Root test failed! Invoking emergency shell.
+HERE
+ debug_takeover "$msg"
+done
for f in $fslist
do
OpenPOWER on IntegriCloud