[go: up one dir, main page]

File: init

package info (click to toggle)
initrd-tools 0.1.32woody.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 96 kB
  • ctags: 10
  • sloc: sh: 591; makefile: 37
file content (88 lines) | stat: -rw-r--r-- 1,549 bytes parent folder | download
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
87
88
#!/bin/sh
#
# $Id: init,v 1.11.2.1 2002/11/04 09:17:42 herbert Exp $

mount_root() {
	unset flags fstype
	set -f
	set +f $cmdline
	for i; do
		case "$i" in
		rootflags=*)
			flags=${i#rootflags=}
			;;
		rootfstype=*)
			fstype=${i#rootfstype=}
			;;
		esac
	done
	if [ -n "$fstype" ]; then
		mount -nrt "$fstype" ${flags:+-o "$flags"} /dev2/root /mnt
		return
	fi
	IFS=,
	set -f
	set +f -- $FSTYPES
	unset IFS
	for i; do
		mount -nrt "$i" ${flags:+-o "$flags"} /dev2/root /mnt &&
			break
	done
}

call() {
	. "$@"
}

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

. /linuxrc.conf

read root < tmp/root
umount -n tmp
mount -nt proc proc proc
echo $root > proc/sys/kernel/real-root-dev
umount -n proc

[ -c /dev/.devfsd ] && DEVFS=yes

if [ -n "`modprobe -l -t boot`" ]; then
	modprobe -k -a -t boot \*
fi
if [ -n "`modprobe -l unix.o`" ]; then
	modprobe -k unix
fi
call /loadmodules
call /script

for i in /scripts/*; do
	[ -f "$i" ] || continue
	case "$i" in
	*.sh)
		(. $i)
		;;
	*)
		$i
		;;
	esac
done

cd /
mount -nt proc proc proc
root=$(cat proc/sys/kernel/real-root-dev)
cmdline=$(cat /proc/cmdline)
umount -n proc
if [ $root != 256 ]; then
	mount -nt tmpfs tmpfs dev2 ||
		mount -nt ramfs ramfs dev2
	mknod dev2/root b $(($root >> 8)) $(($root & 255))
	mount_root
	umount -n dev2
	cd mnt
	[ $DEVFS ] && mount -nt devfs devfs dev
	pivot_root . initrd
fi
if type chroot > /dev/null 2>&1; then
	exec chroot . /sbin/init "$@" < dev/console > dev/console 2>&1
fi
exec /sbin/init "$@" < dev/console > dev/console 2>&1