Skip to content

Instantly share code, notes, and snippets.

@Ansuel
Last active April 19, 2020 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ansuel/48f5d29f3e509c49f363c0dbf2db6528 to your computer and use it in GitHub Desktop.
Save Ansuel/48f5d29f3e509c49f363c0dbf2db6528 to your computer and use it in GitHub Desktop.
#!/bin/sh
overlay=$1
overlay_space=$(df $overlay | sed -n 2p | awk \{'{print $5}'\} | sed 's/%//')
if [ $overlay_space -gt 95 ]; then
echo "$overlay too big, skipping pivot"
exit 1
fi
#!/bin/sh
. /rom/usr/sbin/random_seed
mount_root() {
if [ -x /usr/sbin/mount_root-mod ]; then
/usr/sbin/mount_root-mod
else
echo "****************************************************"
echo "* NO mount_root-mod program found *"
echo "* can not mount the modroot filesystem *"
echo "****************************************************"
fi
}
do_mount_root() {
mount_root
[ -f /modupgrade.tgz ] && {
echo "- mod config restore -"
cd /
tar xzf /modupgrade.tgz
}
}
[ -d /modoverlay ] || do_mount_root
#!/bin/sh
upperdir=$1
overlay_bank=/overlay/bank_2
#copy_base_file
preserve_base_file() { # <source> <dest>
local source=$1
local dest=$2
mkdir -p $dest/etc/init.d/ $dest/etc/rc.d/ $dest/usr/bin/ $dest/lib/upgrade/ $dest/sbin/ $dest/lib
cp -a $source/lib/upgrade/platform.sh $dest/lib/upgrade/
cp -a $source/sbin/sysupgrade $dest/sbin/
cp -a $source/usr/bin/rtfd $dest/usr/bin/
cp -a $source/usr/bin/sysupgrade-safe $dest/usr/bin/
cp -a $source/etc/init.d/rootdevice $dest/etc/init.d/
cp -a $source/etc/rc.d/S94rootdevice $dest/etc/rc.d/
cp -a $source/usr/sbin/random_seed $dest/usr/sbin/
cp -a $source/usr/sbin/mount_root-mod $dest/usr/sbin/
cp -a $source/lib/mount_modroot $dest/lib/
}
[ ! -d $overlay_bank/www ] && return
mv -f $overlay_bank/* $upperdir/
# Copy needed files
preserve_base_file $upperdir $overlay_bank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment