summaryrefslogtreecommitdiff
path: root/package/base-files/files/init.d/rcS
blob: bc27ed29c417941b6c96fc38890e231f8c4e83ac (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
#!/bin/sh
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
# disable kernel messages
if [ -f /proc/sys/kernel/printk ];then
	echo 0 > /proc/sys/kernel/printk
fi
ln -s /proc/self/fd/0 /dev/stdin
ln -s /proc/self/fd/1 /dev/stdout
ln -s /proc/self/fd/2 /dev/stderr
: ${rcquiet=0}
if [ $rcquiet -ne 1 ];then
	echo "System initialization ..."
fi

# create some useful directories in tmpfs
mkdir -p /var/log
mkdir -p /var/run
mkdir -p /var/tmp
touch /var/log/lastlog
touch /var/log/wtmp

# start dynamic device node management
[ -f /etc/init.d/rcdev ] && . /etc/init.d/rcdev

# seed some random
cat /etc/.rnd >/dev/urandom 2>&1

# setup cfgfs
[ -x /sbin/cfgfs ] && {
  cfgfs setup
  mount -o remount,ro /
}

# remount /tmp with smaller size
size=$(cat /etc/tmpfs 2>/dev/null)
[ -z $size ] && size=2048
mount -o remount,nosuid,nodev,mode=1777,size=${size}k -t tmpfs tmpfs /tmp

HOSTNAME=
[[ -s /etc/hostname ]] && HOSTNAME=$(cat /etc/hostname)
HOSTNAME=${HOSTNAME%%.*}
echo ${HOSTNAME:=openadk} >/proc/sys/kernel/hostname

chown 0:0 /tmp; chmod 1777 /tmp

if test x"$rcquiet" = x"0" && sh -n /etc/rc.conf >/dev/null 2>&1; then
	. /etc/rc.conf
	unset rcquiet
	rcquiet=0
else
	unset rcquiet
	rcquiet=1
fi
{
	grep '^#INIT ' /etc/init.d/* | \
	    sort -nk2 | \
	    while read line; do
		rcenabled=NO
		rcname=${line%%:*}
		rcname=${rcname##*/}
		test x"$rcquiet" = x"0" && eval 'rcenabled=${'"${rcname}"':-NO}'
		test x"$rcenabled" = x"NO" || echo -n "Starting ${rcname}... "
		sh ${line%%:*} autostart
		rc=$?
		case $rcenabled:$rc in
		(NO:*)
			;;
		(*:0)
			echo done.
			;;
		(*:*)
			echo "failed ($rc)."
			;;
		esac
	    done
} |tee /dev/stderr |logger -p 6 -t ''

if [ $rcquiet -ne 1 ]; then
  if [ -f /etc/rc.netinfo ]; then
    . /etc/rc.netinfo
  fi
fi