File: init

package info (click to toggle)
diskless 0.3.18.0.5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 772 kB
  • ctags: 119
  • sloc: perl: 2,628; xml: 782; sh: 439; makefile: 103
file content (47 lines) | stat: -rwxr-xr-x 974 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

if [ $$ -ne 1 ]
then
	exec /sbin/init.orig $*
	echo "FATAL ERROR: exec /sbin/init.orig failed"
	exit 1
fi

if [ -f /etc/diskless-image/config ]
then
	mount -n none /proc -t proc
	#IP=`cat /proc/cmdline | sed 's/^.*nfsaddrs=\([0-9\.]\+\).*$/\1/'`
	IP=`ifconfig | grep -A1 eth0 | grep -v eth0 | sed 's/^.*inet addr:\([0-9\.]\+\).*$/\1/'`
	echo IP address is $IP

	. /etc/diskless-image/config
fi

if touch /test-rw
then
	rm /test-rw
	echo "WARNING: master system installed"

	exec /sbin/init.orig $*
	echo "FATAL ERROR: exec /sbin/init.orig failed"
	exit 1
fi

if [ -f /etc/diskless-image/config ]
then
	echo -n "Mounting NFS-root directories..."
	mount -n $nfsserver:/$nfshostsdir/$IP/etc /etc -orw,nolock
	rm -f /etc/mtab~ /etc/nologin
	: > /etc/mtab

	mount -o remount /
	mount -o remount /etc
	mount -o remount /proc
	echo "done."
else
	echo "Not mounting NFS-root directories"
fi

exec /sbin/init.orig $*
echo "FATAL ERROR: exec /sbin/init.orig failed"
exit 1