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
executable file
·176 lines (147 loc) · 3.78 KB
/
Copy pathrc
File metadata and controls
executable file
·176 lines (147 loc) · 3.78 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
# /etc/rc - System startup script run by init before going multiuser.
umask 022
TERM="${TERM-minix}"
PATH=/usr/local/bin:/bin:/usr/bin:/usr/sbin
RC_TZ=/etc/rc.timezone
export TERM PATH
usage()
{
echo >&2 "Usage: $0 [-saf] start|stop|down"
exec intr sh
}
up()
{
service=$1
shift
# Function to dynamically start a system service
echo -n " $service"
service up /sbin/$service "$@"
}
while getopts 'saf' opt
do
case $opt in
s) sflag=t ;; # Single user
a) aflag=t ;; # Ask for /usr
f) fflag=t ;; # Force a full file system check
*) usage
esac
done
shift `expr $OPTIND - 1`
case "$#:$1" in
1:start|1:stop|1:down)
action=$1
;;
*) usage
esac
case $action in
start)
echo ""
echo -n "Multiuser startup in progress ...:"
# National keyboard?
test -f /etc/keymap && loadkeys /etc/keymap
up is -period 5HZ
echo .
# Set timezone.
export TZ=GMT0
if [ -f "$RC_TZ" ]
then . "$RC_TZ"
fi
# Try to read the hardware real-time clock, otherwise do it manually.
readclock || intr date -q
# Initialize files.
printroot >/etc/mtab # /etc/mtab keeps track of mounts
>/etc/utmp # /etc/utmp keeps track of logins
# /etc/fstab lists the root, tmp and usr devices.
. /etc/fstab
# Any swapspace on a device?
test "$swap" : '/dev/' && mount -s $swap
# Are we booting from CD?
bootcd="`/bin/sysenv bootcd`"
# If booting from CD, /usr has to be mounted readonly.
# Also, $usr won't be specified correctly in the
# fstab (the CD could be anywhere), so we decide
# where it is based on sysenv (set by FS when probing for CD).
if [ "$bootcd" = 1 ]
then
#imagedev="`/bin/sysenv cdproberoot`"
#usrdev="`expr $imagedev + 1`"
usr_roflag="-r"
usr="$cddev"p2
echo "Setting /usr on cd is $usr"
fi
# Mount the /usr partition unless this is a single floppy Minix.
if [ ! -d /usr/bin ]
then
if [ "$aflag" -o "$usr" = unknown ]
then
# We need to ask what the /usr du jour is.
intr sh -c '
echo -n "Finish the name of device to mount as /usr: /dev/"
read usr
echo "usr=/dev/$usr" >/tmp/usr'
. /tmp/usr
fi
mount $usr_roflag $usr /usr || {
echo "\
Please try to mount something else as /usr, then hit CTRL-D to continue startup.
Mount $usr /usr failed -- Single user."
intr sh
}
rm -f /tmp/usr
fi
# Check if the system crashed.
if shutdown -C
then
echo
echo "The system was not properly shut down. Checking file systems."
fflag=t
fi
if [ "$fflag" ]
then
umount $usr
echo "fsck / - $root"
intr fsck -r $root
echo "fsck /usr - $usr"
intr fsck -r $usr
if [ ! -z "$home" ]
then echo "fsck /home - $home"
intr fsck -r $home
fi
mount $usr /usr
fi
if [ ! -z "$home" ]
then mount $home /home || echo "WARNING: couldn't mount $home on /home"
fi
# This file is necessary for above 'shutdown -C' check.
# (Silence stderr in case of running from cd.)
touch /usr/adm/wtmp 2>/dev/null
if [ "$sflag" ]
then
echo "Single user."
intr sh
fi
# Any swapspace on a file?
test -n "$swap" -a ! "$swap" : '/dev/' && mount -s $swap
case "`printroot -r`":$bootcd in
/dev/ram:)
# Remove boot-only things to make space,
# unless booting from CD, in which case we need them.
rm -rf /boot
# put the compiler on ram
cp /usr/lib/em* /usr/lib/cpp* /lib
esac
# Things should be alright now.
;;
down|stop)
sync
# Tell RS server we're going down.
service shutdown
;;
esac
# Further initialization.
test -f /usr/etc/rc && sh /usr/etc/rc $action
test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
#test -f /etc/rc.rescue && sh /etc/rc.rescue $action
# Any messages?
test "$action" = start -a -f /etc/issue && cat /etc/issue
exit 0