1 # /etc/rc - System startup script run by init before going multiuser.
10 PATH=/usr/local/bin:/bin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/pkg/sbin:/sbin
11 RC_TZ=/etc/rc.timezone
16 echo >&2 "Usage: $0 [-saf] start|stop|down"
22 # Function to dynamically start a system service
24 prefix=$(expr "$1 " : '\(-\)')
25 if [ "$prefix" = "-" ];
33 service $opt up /sbin/$service "$@"
38 # Function to dynamically edit system service settings
40 prefix=$(expr "$1 " : '\(-\)')
41 if [ "$prefix" = "-" ];
49 # Assume binaries are always in /usr/sbin
50 service $opt edit /usr/sbin/$service -label $service "$@"
53 # This function parses the deprecated minix shellscript-style
54 # /etc/fstab, and fscks and mounts its filesystems.
57 echo "WARNING: old fstab format, please upgrade!"
59 # /etc/fstab lists the root, home, and usr devices.
62 intr fsck.mfs $fsckopts $usr
64 then intr fsck.mfs $fsckopts $home
68 mount $bin_img $usr /usr
71 then mount $bin_img $home /home || echo "WARNING: couldn't mount $home on /home"
75 while getopts 'saf' opt
78 s) sflag=t ;; # Single user
79 a) aflag=t ;; # Ask for /usr
80 f) fflag=-f ;; # Force a full file system check
84 shift `expr $OPTIND - 1`
87 1:start|1:stop|1:down)
97 test -f /etc/keymap && loadkeys /etc/keymap
99 # options for fsck. default is -r, which prompts the user for repairs.
102 if sysenv $optname >/dev/null
103 then fsckopts="`sysenv $optname`"
106 if [ "`sysenv debug_fkeys`" != 0 ]
117 # Try to read the hardware real-time clock, otherwise do it manually.
118 readclock || intr date -q
121 >/etc/utmp # /etc/utmp keeps track of logins
123 # Use MFS binary only from kernel image?
124 if [ "`sysenv bin_img`" = 1 ]
129 # Are we booting from CD?
130 bootcd="`/bin/sysenv bootcd`"
132 # If booting from CD, mounting is a special case.
133 # We know what to do - only /usr is mounted and it's readonly.
135 then usrdev="$cddev"p2
136 echo "/usr on cd is $usrdev"
137 mount -r $usrdev /usr
139 # If we're not booting from CD, fsck + mount using /etc/fstab.
140 read <$FSTAB fstabline
141 if [ "$fstabline" = "# Poor man's File System Table." ]
142 then mountfstab_poorman # Old minix /etc/fstab
143 else fsck -x / $fflag $fsckopts
148 # Unmount and free now defunct ramdisk
149 umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
150 ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
152 # Edit settings for boot system services
153 if [ "`sysenv skip_boot_config`" != 1 ]
168 # This file is necessary for above 'shutdown -C' check.
169 # (Silence stderr in case of running from cd.)
170 touch /usr/adm/wtmp /etc/wtmp 2>/dev/null
174 echo "Single user. Press ^D to resume multiuser startup."
179 echo "Multiuser startup in progress ..."
181 case "`printroot -r`":$bootcd in
183 # Remove boot-only things to make space,
184 # unless booting from CD, in which case we need them.
186 # put the compiler on ram
187 cp /usr/lib/em* /usr/lib/cpp* /lib
190 echo -n "Starting hotplugging infrastructure... "
191 rm -f /var/run/devmand.pid
192 devmand -d /etc/devmand -d /usr/pkg/etc/devmand &
195 # Things should be alright now.
199 if [ -f /var/run/devmand.pid ]
201 kill -INT `cat /var/run/devmand.pid`
202 # without this delay the following will
203 # be printed in the console
204 # RS: devman not running?
208 # usbd needs to be stopped exactly
209 # at this stage(before stopping devman
210 # and after stopping the services
212 if [ -x /usr/pkg/etc/rc.d/usbd ]
214 /usr/pkg/etc/rc.d/usbd stop
216 # Tell RS server we're going down.
221 # Further initialization.
222 test -f /usr/etc/rc && sh /usr/etc/rc $action
223 test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
226 test "$action" = start -a -f /etc/issue && cat /etc/issue