#!/bin/sh
-usage="Usage: $0 [flash|hdd|flash-data|hdd-data|jffs2-flash|jffs2-hdd|jffs2-flash-data|jffs2-hdd-data]"
+usage="Usage: $0 [hdd-data|flash-data|hdd-conf|flash-conf|jffs2-hdd-data|jffs2-flash-data|jffs2-hdd-conf|jffs2-flash-conf]"
-# Set or seach for target disk
+# Set target disk
if [ $# -gt 1 ] ; then
echo $usage
if [ "$1" = "flash-data" ] ; then
targ=/share/flash/data
copy=true
+ flag=.sdb1root
elif [ "$1" = "hdd-data" ] ; then
targ=/share/hdd/data
copy=true
- elif [ "$1" = "flash" ] ; then
+ flag=.sda1root
+ elif [ "$1" = "flash-conf" ] ; then
targ=/share/flash/conf
copy=true
- elif [ "$1" = "hdd" ] ; then
+ flag=.sdb2root
+ elif [ "$1" = "hdd-conf" ] ; then
targ=/share/hdd/conf
copy=true
+ flag=.sda2root
elif [ "$1" = "jffs2-flash-data" ] ; then
targ=/share/flash/data
copy=
elif [ "$1" = "jffs2-hdd-data" ] ; then
targ=/share/hdd/data
copy=
- elif [ "$1" = "jffs2-flash" ] ; then
+ elif [ "$1" = "jffs2-flash-conf" ] ; then
targ=/share/flash/conf
copy=
- elif [ "$1" = "jffs2-hdd" ] ; then
+ elif [ "$1" = "jffs2-hdd-conf" ] ; then
targ=/share/hdd/conf
copy=
else
# Copy the complete rootfs to the target.
+ echo "Copying the complete rootfs from / to $targ."
/usr/bin/find / -print0 -mount | /usr/bin/cpio -p -0 -d -m -u $targ
rm -rf $targ/dev ; mv $targ/dev.state $targ/dev
rm -rf $targ/var ; mv $targ/var.state $targ/var
- rm -f /.sda1root /.sda2root /.sdb1root /.sdb2root
- rm -f $targ/.sda1root $targ/.sda2root $targ/.sdb1root $targ/.sdb2root
-
- if [ "$targ" = "/share/hdd/data" ] ; then
- echo > /.sda1root
- echo > $targ/.sda1root
- elif [ "$targ" = "/share/hdd/conf" ] ; then
- echo > /.sda2root
- echo > $targ/.sda2root
- elif [ "$targ" = "/share/flash/data" ] ; then
- echo > /.sdb1root
- echo > $targ/.sdb1root
- elif [ "$targ" = "/share/flash/conf" ] ; then
- echo > /.sdb2root
- echo > $targ/.sdb2root
- fi
+ rm -f /.sd??root $targ/.sd??root
+
+ echo "Creating /$flag to direct switchbox to boot from $targ."
+ echo > /$flag
+ echo > $targ/$flag
fi