forked from Stichting-MINIX-Research-Foundation/minix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrc
More file actions
209 lines (179 loc) · 4.6 KB
/
Copy pathrc
File metadata and controls
209 lines (179 loc) · 4.6 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# /usr/etc/rc - continued system initialization.
RANDOM_FILE=/usr/adm/random.dat
LOCAL_FILE=/usr/etc/rc.local
case "$#:$1" in
1:start|1:stop|1:down)
action=$1
;;
*) echo >&2 "Usage: $0 start|stop|down"
exit 1
esac
if [ -f "$LOCAL_FILE" ]
then . "$LOCAL_FILE" $1
fi
disabled()
{
ifs="$IFS"; IFS=,
for skip in `sysenv disable`
do
if [ "$skip" = "$1" ]
then
IFS="$ifs"; unset ifs
return 0
fi
done
IFS="$ifs"; unset ifs
return 1
}
daemonize()
{
# Function to start a daemon, if it exists.
local IFS=':'
local name="$1"
test "$1" = tcpd && name="$2"
for dir in $PATH
do
if [ -f "$dir/$1" ]
then
# check if this service is disabled at the boot monitor.
if disabled $name; then return; fi
echo -n " $name"
"$@" &
return
fi
done
}
up()
{
upopt " " "$@"
}
upopt()
{
opt=$1
shift
service=$1
shift
# Function to dynamically start a system service
# First check if this service is disabled at the boot monitor.
if disabled $service; then return; fi
# Service is not disabled. Try to bring it up.
echo -n " $service"
service $opt up /usr/sbin/$service "$@"
}
get_eth_labels() {
# Filter out the non-vlan ethernet entries from inet.conf.
# Produce as output a list of "drivername_instancenr"-formatted labels.
# The first sed is taken from /bin as older GNU sed versions don't know '\t'.
/bin/sed 's/\t/ /g' /etc/inet.conf | \
sed -n 's/^ *eth[0-9][0-9]* *\([^ ][^ ]*\) *\([0-9][0-9]*\).*$/\1_\2/p' | \
grep -v '^vlan_'
}
DAEMONS=/etc/rc.daemons
case $action in
start)
# Select console font.
test -f /etc/font && loadfont /etc/font </dev/console
# Cleanup.
rm -rf /tmp/. /usr/run/. /usr/spool/lpd/. /usr/spool/locks/.
# Start servers and drivers set at the boot monitor.
echo -n "Starting services:"
upopt -n random -dev /dev/random -devstyle STYLE_DEVA -period 3HZ
# load random number generator
if [ -f $RANDOM_FILE ]
then
cat < $RANDOM_FILE >/dev/random
# overwrite $RANDOM_FILE. We don't want to use this data again
dd if=/dev/random of=$RANDOM_FILE bs=1024 count=1 2> /dev/null
fi
# start network driver instances for all configured ethernet devices
for label in $(get_eth_labels); do
driver=$(echo $label | sed 's/\(.*\)_.*/\1/')
instance=$(echo $label | sed 's/.*_//')
eval arg=\$${label}_arg
if [ ! -z "$arg" ]; then arg=" $arg"; fi
arg="-args \"instance=$instance$arg\""
eval up $driver -label $label $arg -period 5HZ
done
up inet -script /etc/rs.inet -dev /dev/ip -devstyle STYLE_CLONE
upopt -n printer -dev /dev/lp -period 10HZ
upopt -n ipc
echo .
# Network initialization.
(: </dev/tcp) 2>/dev/null && net=t # Is there a TCP/IP server?
echo -n "Starting daemons:"
daemonize update
# Ugly error message when starting cron from CD.
# (and cron unnecessary then so..)
if [ ! -f /CD ]
then daemonize cron
else mkdir /tmp/log
rm -f /var/log || true
ln -s /tmp/log /var/log || true
. /etc/rc.cd
fi
# syslogd has not been started yet
rm -f /var/run/syslogd.pid
daemonize syslogd
echo .
if [ "$net" ]
then
if [ -f /etc/rc.net ]
then
# Let a customized TCP/IP initialization script figure it out.
. /etc/rc.net
else
# Standard network daemons.
echo -n "Starting networking:"
if grep -s 'psip0.*default' /etc/inet.conf
then ifconfig -h 10.0.0.1
else
daemonize dhcpd
fi
daemonize nonamed -L
if [ -f "$DAEMONS" ]
then . "$DAEMONS"
fi
# The last daemon has been started, so close the list:
echo .
fi
fi
if [ "$net" ]
then
# Get the nodename from the DNS and set it.
trap '' 2
intr -t 20 hostaddr -h
trap 2
fi
# Recover files being edited when the system crashed.
test -f /usr/bin/elvprsv && elvprsv /usr/tmp/elv*
# Run the daily cleanup on systems that are not on at night.
test -f /usr/etc/daily && sh /usr/etc/daily boot &
;;
stop|down)
# Save random data, if /usr is mounted rw.
if grep ' \/usr .*rw' /etc/mtab >/dev/null
then
if dd if=/dev/random of=$RANDOM_FILE.new bs=1024 count=1 2>/dev/null
then
mv $RANDOM_FILE.new $RANDOM_FILE
else
echo 'Failed to save random data.'
fi
fi
esac
d=/usr/local/etc/rc.d
# Let packages run their own scripts
if [ -d "$d" ]
then if cd $d
then
echo -n "Local packages ($action): "
for f in *
do
if [ -x "$f" ]
then echo -n "$f "
sh "$f" "$action"
fi
done
echo " done."
fi
fi