1 | # /etc/rc - System startup script run by init before going multiuser.
|
---|
2 |
|
---|
3 | umask 022
|
---|
4 | TERM="${TERM-minix}"
|
---|
5 | PATH=/usr/local/bin:/bin:/usr/bin:/usr/sbin
|
---|
6 | RC_TZ=/etc/rc.timezone
|
---|
7 | export TERM PATH
|
---|
8 |
|
---|
9 | usage()
|
---|
10 | {
|
---|
11 | echo >&2 "Usage: $0 [-saf] start|stop|down"
|
---|
12 | exec intr sh
|
---|
13 | }
|
---|
14 |
|
---|
15 | up()
|
---|
16 | {
|
---|
17 | service=$1
|
---|
18 | shift
|
---|
19 |
|
---|
20 | # Function to dynamically start a system service
|
---|
21 | echo -n " $service"
|
---|
22 | service up /sbin/$service "$@"
|
---|
23 | }
|
---|
24 |
|
---|
25 | while getopts 'saf' opt
|
---|
26 | do
|
---|
27 | case $opt in
|
---|
28 | s) sflag=t ;; # Single user
|
---|
29 | a) aflag=t ;; # Ask for /usr
|
---|
30 | f) fflag=t ;; # Force a full file system check
|
---|
31 | *) usage
|
---|
32 | esac
|
---|
33 | done
|
---|
34 | shift `expr $OPTIND - 1`
|
---|
35 |
|
---|
36 | case "$#:$1" in
|
---|
37 | 1:start|1:stop|1:down)
|
---|
38 | action=$1
|
---|
39 | ;;
|
---|
40 | *) usage
|
---|
41 | esac
|
---|
42 |
|
---|
43 | case $action in
|
---|
44 | start)
|
---|
45 | echo ""
|
---|
46 | echo -n "Multiuser startup in progress ...:"
|
---|
47 |
|
---|
48 | # National keyboard?
|
---|
49 | test -f /etc/keymap && loadkeys /etc/keymap
|
---|
50 |
|
---|
51 | up is -period 5HZ
|
---|
52 | up cmos -dev /dev/cmos -period 5HZ
|
---|
53 | echo .
|
---|
54 |
|
---|
55 | # Set timezone.
|
---|
56 | export TZ=GMT0
|
---|
57 | if [ -f "$RC_TZ" ]
|
---|
58 | then . "$RC_TZ"
|
---|
59 | fi
|
---|
60 |
|
---|
61 | # Try to read the hardware real-time clock, otherwise do it manually.
|
---|
62 | readclock || intr date -q
|
---|
63 |
|
---|
64 | # Initialize files.
|
---|
65 | printroot >/etc/mtab # /etc/mtab keeps track of mounts
|
---|
66 | >/etc/utmp # /etc/utmp keeps track of logins
|
---|
67 |
|
---|
68 | # /etc/fstab lists the root, tmp and usr devices.
|
---|
69 | . /etc/fstab
|
---|
70 |
|
---|
71 | # Any swapspace on a device?
|
---|
72 | test "$swap" : '/dev/' && mount -s $swap
|
---|
73 |
|
---|
74 | # Are we booting from CD?
|
---|
75 | bootcd="`/bin/sysenv bootcd`"
|
---|
76 |
|
---|
77 | # If booting from CD, /usr has to be mounted readonly.
|
---|
78 | # Also, $usr won't be specified correctly in the
|
---|
79 | # fstab (the CD could be anywhere), so we decide
|
---|
80 | # where it is based on sysenv (set by FS when probing for CD).
|
---|
81 | if [ "$bootcd" = 1 ]
|
---|
82 | then
|
---|
83 | #imagedev="`/bin/sysenv cdproberoot`"
|
---|
84 | #usrdev="`expr $imagedev + 1`"
|
---|
85 | usr_roflag="-r"
|
---|
86 | usr="$cddev"p2
|
---|
87 | echo "Setting /usr on cd is $usr"
|
---|
88 | fi
|
---|
89 |
|
---|
90 | # Mount the /usr partition unless this is a single floppy Minix.
|
---|
91 | if [ ! -d /usr/bin ]
|
---|
92 | then
|
---|
93 | if [ "$aflag" -o "$usr" = unknown ]
|
---|
94 | then
|
---|
95 | # We need to ask what the /usr du jour is.
|
---|
96 | intr sh -c '
|
---|
97 | echo -n "Finish the name of device to mount as /usr: /dev/"
|
---|
98 | read usr
|
---|
99 | echo "usr=/dev/$usr" >/tmp/usr'
|
---|
100 | . /tmp/usr
|
---|
101 | fi
|
---|
102 | mount $usr_roflag $usr /usr || {
|
---|
103 | echo "\
|
---|
104 | Please try to mount something else as /usr, then hit CTRL-D to continue startup.
|
---|
105 | Mount $usr /usr failed -- Single user."
|
---|
106 | intr sh
|
---|
107 | }
|
---|
108 | rm -f /tmp/usr
|
---|
109 | fi
|
---|
110 |
|
---|
111 | # Check if the system crashed.
|
---|
112 | if shutdown -C
|
---|
113 | then
|
---|
114 | echo
|
---|
115 | echo "The system was not properly shut down. Checking file systems."
|
---|
116 | fflag=t
|
---|
117 | fi
|
---|
118 |
|
---|
119 | if [ "$fflag" ]
|
---|
120 | then
|
---|
121 | umount $usr
|
---|
122 | echo "fsck / - $root"
|
---|
123 | intr fsck -r $root
|
---|
124 | echo "fsck /usr - $usr"
|
---|
125 | intr fsck -r $usr
|
---|
126 | if [ ! -z "$home" ]
|
---|
127 | then echo "fsck /home - $home"
|
---|
128 | intr fsck -r $home
|
---|
129 | fi
|
---|
130 | mount $usr /usr
|
---|
131 | fi
|
---|
132 |
|
---|
133 | if [ ! -z "$home" ]
|
---|
134 | then mount $home /home || echo "WARNING: couldn't mount $home on /home"
|
---|
135 | fi
|
---|
136 |
|
---|
137 | # This file is necessary for above 'shutdown -C' check.
|
---|
138 | # (Silence stderr in case of running from cd.)
|
---|
139 | touch /usr/adm/wtmp 2>/dev/null
|
---|
140 |
|
---|
141 | if [ "$sflag" ]
|
---|
142 | then
|
---|
143 | echo "Single user."
|
---|
144 | intr sh
|
---|
145 | fi
|
---|
146 |
|
---|
147 | # Any swapspace on a file?
|
---|
148 | test -n "$swap" -a ! "$swap" : '/dev/' && mount -s $swap
|
---|
149 |
|
---|
150 |
|
---|
151 | case "`printroot -r`":$bootcd in
|
---|
152 | /dev/ram:)
|
---|
153 | # Remove boot-only things to make space,
|
---|
154 | # unless booting from CD, in which case we need them.
|
---|
155 | rm -rf /boot
|
---|
156 | # put the compiler on ram
|
---|
157 | cp /usr/lib/em* /usr/lib/cpp* /lib
|
---|
158 | esac
|
---|
159 |
|
---|
160 | # Things should be alright now.
|
---|
161 | ;;
|
---|
162 | down|stop)
|
---|
163 | sync
|
---|
164 | # Tell RS server we're going down.
|
---|
165 | service shutdown
|
---|
166 | ;;
|
---|
167 | esac
|
---|
168 |
|
---|
169 | # Further initialization.
|
---|
170 | test -f /usr/etc/rc && sh /usr/etc/rc $action
|
---|
171 | test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
|
---|
172 | test -f /etc/rc.rescue && sh /etc/rc.rescue $action
|
---|
173 |
|
---|
174 | # Any messages?
|
---|
175 | test "$action" = start -a -f /etc/issue && cat /etc/issue
|
---|
176 |
|
---|
177 | exit 0
|
---|