blob: c83881a3330b33fa695add2bac108b12841cda5d (
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
|
#!/bin/sh
# If the nobootdisk flag is set, exit.
if ( [ -f /.nobootdisk ] ) ; then return 0 ; fi
# If we're not booting from flash, exit.
i=`grep "/dev/root / jffs2" /proc/mounts`
if ( [ -z "$i" ] ) ; then return 0 ; fi
# Establish our identity
linksys_hostname=`grep "^default_server_name=" /etc/CGI_ds.conf | sed s/default_server_name=//`
real_hostname=`hostname`
echo "====> linksys_hostname is $linksys_hostname"
echo "====> real_hostname is $real_hostname"
# but don't duplicate
if ( [ "$linksys_hostname" = `hostname` ] ) ; then linksys_hostname= ; fi
if ( [ "$real_hostname" = "default" ] ) ; then real_hostname= ; fi
# Search all FAT/NTFS filesystem in order.
# (heavily borrowed from the rc.start-optware script).
for i in /share/*/data/HDD_* ; do
# if the value of i is the string with the wildcards, no match occurred.
if ( [ "$i" = '/share/*/data/HDD_*' ] ) ; then break ; fi
echo "====> searching $i..."
# Now check inside directories named for the Linksys hostname, the real
# hostname, and finally the name "default"...
for j in $linksys_hostname $real_hostname "default" ; do
echo "====> checking $i/bootdisk/$j ..."
if ( [ -d "$i/bootdisk/$j" ] ) ; then
# We have the correct subdirectory...
for k in "$i/bootdisk/$j"/S??* ; do
# Bail out if no match in that directory
if ( [ "$k" = "$i/bootdisk/$j"'/S??*' ] ) ; then break ; fi
echo "====> found $k ..."
[ ! -f "$k" ] && continue
# Check to see if we need to copy or run in-place..
nocopy=`grep "^#bootdisk:nocopy" "$k"`
if ( [ -z "$nocopy" ] ) ; then
# copy and strip the MSDOS-style line endings, then execute.
echo "====> running copy: /tmp/tmpscript $k $i"
dos2unix -u <"$k" >/tmp/tmpscript
/bin/sh /tmp/tmpscript "$k" "$i"
rm -f /tmp/tmpscript
else
# execute in place
echo "====> running in-place $k $k $i"
/bin/sh "$k" "$k" "$i"
fi
done
fi
done
done
|