blob: c38774cd7d51821f754582f81cb93898dda0d286 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/sh
# Set or seach for target disk
if [ $# -gt 1 ] ; then
echo "Usage: $0 [flash|hdd|flash-data|hdd-data]"
exit 1
fi
if [ $# -eq 1 ] ; then
if [ "$1" = "flash-data" ] ; then
targ=/share/flash/data
elif [ "$1" = "hdd-data" ] ; then
targ=/share/hdd/data
elif [ "$1" = "flash" ] ; then
targ=/share/flash/conf
elif [ "$1" = "hdd" ] ; then
targ=/share/hdd/conf
else
echo "Usage: $0 [flash|hdd|flash-data|hdd-data]"
exit 1
fi
elif [ -d /share/hdd/conf/lost+found ] ; then
targ=/share/hdd/conf
elif [ -d /share/flash/conf/lost+found ] ; then
targ=/share/flash/conf
else
echo "Cannot locate target disk"
exit 1
fi
# Check it's a real mount point
if grep $targ /proc/mounts >/dev/null 2>&1 ; then
echo "Target disk is $targ"
else
echo "Error: $targ is not a mounted disk"
exit 1
fi
# Start at the root directory
cd /
# Ensure /opt is there.
if [ ! -d $targ/opt ] ; then
echo "Creating new /opt directory on target disk."
mkdir -p $targ/opt
else
echo "Preserving existing /opt directory on target disk."
fi
if [ -d /opt -a ! -h /opt ] ; then
echo "Copying existing /opt directory from root disk to target disk."
tar cf - opt | ( cd $targ ; tar xf - )
mv /opt /opt.old
fi
echo "Linking /opt directory from target disk to root disk."
rm -f /opt ; ln -s $targ/opt /opt
# Ensure /usr/lib/ipkg is there.
if [ ! -d $targ/usr/lib/ipkg ] ; then
echo "Creating new /usr/lib/ipkg directory on target disk."
mkdir -p $targ/usr/lib/ipkg
fi
if [ ! -f $targ/usr/lib/ipkg/status -a -d /usr/lib/ipkg -a ! -h /usr/lib/ipkg ] ; then
echo "Copying existing /usr/lib/ipkg directory from root disk to target disk."
tar cf - usr/lib/ipkg | ( cd $targ ; tar xf - )
else
echo "Preserving existing ipkg database on target disk."
fi
if [ -d /usr/lib/ipkg -a ! -h /usr/lib/ipkg ] ; then
echo "Saving /usr/lib/ipkg directory on root disk in /usr/lib/ipkg.old"
rm -rf /usr/lib/ipkg.old
mv /usr/lib/ipkg /usr/lib/ipkg.old
fi
echo "Linking /usr/lib/ipkg directory from target disk to root disk."
rm -f /usr/lib/ipkg ; ln -s $targ/usr/lib/ipkg /usr/lib/ipkg
exit 0
|