summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilton Miller <miltonm@us.ibm.com>2016-02-23 21:48:48 -0600
committerMilton D. Miller II <miltonm@us.ibm.com>2016-02-24 12:02:47 -0600
commitec0ba3c1ddd26ccd7bfee27b2b900f7c73401ad9 (patch)
treef113b148714dc90bb4fde9d820c456c42e45d021
parente442584ae86e6e9e1c488c191ebbb3e1bbca24dd (diff)
downloadtalos-openbmc-ec0ba3c1ddd26ccd7bfee27b2b900f7c73401ad9.tar.gz
talos-openbmc-ec0ba3c1ddd26ccd7bfee27b2b900f7c73401ad9.zip
initfs: Add flash clear and update during init
Add code to clear the rwfs (preserving files from the whitelist) during init, by a command line option. Also allow it to be triggered by the file system not being a jffs2. A console user can download images to /run/initramfs/ at the debug-init-sh prompt for manual update. Also add code but do not enable detecting images loaded into initramfs / for future update options. If enabled a custom initrd with update images can be bulit (it would not fit in flash and need to be netbooted). Signed-off-by: Milton Miller <miltonm@us.ibm.com>
-rw-r--r--meta-phosphor/common/recipes-phosphor/obmc-phosphor-initfs/files/obmc-init.sh54
1 files changed, 53 insertions, 1 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 f2fe938a8..12c5a2f1b 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
@@ -85,13 +85,21 @@ rwfs=$(findmtd rwfs)
rodev=/dev/mtdblock${rofs#mtd}
rwdev=/dev/mtdblock${rwfs#mtd}
+# Set to y for yes, anything else for no.
+force_rwfst_jffs2=y
+flash_images_before_init=n
+
rofst=squashfs
rwfst=$(probe_fs_type $rwdev)
roopts=ro
rwopts=rw
+image=/run/initramfs/image-
+trigger=${image}rwfs
+
init=/sbin/init
-fsck=/sbin/fsck.$rwfst
+fsckbase=/sbin/fsck.
+fsck=$fsckbase$rwfst
fsckopts=-a
echo rofs = $rofs $rofst rwfs = $rwfs $rwfst
@@ -101,6 +109,50 @@ then
debug_takeover "Debug initial shell requested by command line."
fi
+# If there are images in root move them to run/initramfs/ now.
+imagebasename=${image##*/}
+if test -n "${imagebasename}" -a "x$flash_images_before_init" = xy &&
+ ls /${imagebasename}* > /dev/null 2>&1
+then
+ echo "Pending flash updates found."
+ mv /${imagebasename}* ${image%$imagebasename}
+fi
+
+if grep -w clean-rwfs-filesystem /proc/cmdline
+then
+ echo "Cleaning of read-write overlay filesystem requested."
+ touch $trigger
+fi
+
+if test "x$force_rwfst_jffs2" = xy -a $rwfst != jffs2 -a ! -f $trigger
+then
+ echo "Converting read-write overlay filesystem to jffs2 forced."
+ touch $trigger
+fi
+
+if ls $image* > /dev/null 2>&1
+then
+ if ! test -x /update
+ then
+ debug_takeover "Flash update requested but /update missing!"
+ elif test -f $trigger -a ! -s $trigger
+ then
+ echo "Saving selected files from read-write overlay filesystem."
+ /update && rm -f $image*
+ echo "Clearing read-write overlay filesystem."
+ flash_eraseall /dev/$rwfs
+ echo "Restoring saved files to read-write overlay filesystem."
+ touch $trigger
+ /update
+ rm -rf /save $trigger
+ else
+ /update && rm -f $image*
+ fi
+
+ rwfst=$(probe_fs_type $rwdev)
+ fsck=$fsckbase$rwfst
+fi
+
mount $rodev $rodir -t $rofst -o $roopts
if test -x $rodir$fsck
OpenPOWER on IntegriCloud