]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/nslu2-binary-only/unslung-rootfs/unsling
OE tree imported from monotone branch org.openembedded.oz354fam083 at revision 8b12e3...
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / nslu2-binary-only / unslung-rootfs / unsling
1 #!/bin/sh
2
3 usage="Usage: $0 disk1|disk2"
4
5 # Set target disk
6
7 if [ $# -gt 1 ] ; then
8     echo $usage
9     exit 1
10 fi
11
12 if [ $# -eq 1 ] ; then
13     if [ "$1" = "disk1" ] ; then
14         targ=/share/hdd/data
15         flag=.sda1root
16     elif [ "$1" = "disk2" ] ; then
17         targ=/share/flash/data
18         flag=.sdb1root
19     elif [ "$1" = "hdd-data" ] ; then
20         targ=/share/hdd/data
21         flag=.sda1root
22     elif [ "$1" = "hdd-conf" ] ; then
23         targ=/share/hdd/conf
24         flag=.sda2root
25     elif [ "$1" = "flash-data" ] ; then
26         targ=/share/flash/data
27         flag=.sdb1root
28     elif [ "$1" = "flash-conf" ] ; then
29         targ=/share/flash/conf
30         flag=.sdb2root
31     else
32         echo $usage
33         exit 1
34     fi
35 else
36     echo $usage
37     exit 1
38 fi
39
40 # Check it's a real mount point
41
42 if grep $targ /proc/mounts >/dev/null 2>&1 ; then
43     echo "Target disk is $targ"
44 else
45     echo "Error: $targ is not a mounted disk"
46     exit 1
47 fi
48
49 # Start at the root directory
50
51 cd /
52
53 # Save the existing ipkg database.
54
55 rm -rf $targ/usr/lib/ipkg.old
56 if [ -f $targ/usr/lib/ipkg/status ] ; then
57         mv $targ/usr/lib/ipkg $targ/usr/lib/ipkg.old
58 fi
59
60 # Copy the complete rootfs to the target.
61
62 echo "Copying the complete rootfs from / to $targ."
63 /usr/bin/find / -print0 -mount | /usr/bin/cpio -p -0 -d -m -u $targ
64 rm -rf $targ/dev ; mv $targ/dev.state $targ/dev
65 rm -rf $targ/var ; mv $targ/var.state $targ/var
66
67 # Copy over the existing ipkg database.
68
69 if [ -f $targ/usr/lib/ipkg.old/status ] ; then
70         echo "Preserving existing ipkg database on target disk."
71         ( cd $targ/usr/lib/ipkg.old ; tar cf - . ) | ( cd $targ/usr/lib/ipkg ; tar xf - )
72 fi
73
74 echo "Linking /usr/bin/ipkg executable on target disk."
75 rm -f $targ/usr/bin/ipkg ; ln -s /usr/bin/ipkg-cl $targ/usr/bin/ipkg
76
77 # Create the boot flag file.
78
79 rm -f /.sd??root $targ/.sd??root
80
81 echo "Creating /$flag to direct switchbox to boot from $targ."
82 echo > /$flag
83 echo > $targ/$flag
84
85 exit 0