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 printroot >/etc/mtab # /etc/mtab keeps track of mounts
122 >/etc/utmp # /etc/utmp keeps track of logins
124 # Use MFS binary only from kernel image?
125 if [ "`sysenv bin_img`" = 1 ]
130 # Are we booting from CD?
131 bootcd="`/bin/sysenv bootcd`"
133 # If booting from CD, mounting is a special case.
134 # We know what to do - only /usr is mounted and it's readonly.
136 then usrdev="$cddev"p2
137 echo "/usr on cd is $usrdev"
138 mount -r $usrdev /usr
140 # If we're not booting from CD, fsck + mount using /etc/fstab.
141 read <$FSTAB fstabline
142 if [ "$fstabline" = "# Poor man's File System Table." ]
143 then mountfstab_poorman # Old minix /etc/fstab
144 else fsck -x / $fflag $fsckopts
149 # Unmount and free now defunct ramdisk
150 umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
151 ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
153 # Edit settings for boot system services
154 if [ "`sysenv skip_boot_config`" != 1 ]
169 # This file is necessary for above 'shutdown -C' check.
170 # (Silence stderr in case of running from cd.)
171 touch /usr/adm/wtmp /etc/wtmp 2>/dev/null
175 echo "Single user. Press ^D to resume multiuser startup."
180 echo "Multiuser startup in progress ..."
182 case "`printroot -r`":$bootcd in
184 # Remove boot-only things to make space,
185 # unless booting from CD, in which case we need them.
187 # put the compiler on ram
188 cp /usr/lib/em* /usr/lib/cpp* /lib
191 echo -n "Starting hotplugging infrastructure... "
192 rm -f /var/run/devmand.pid
193 devmand -d /etc/devmand -d /usr/pkg/etc/devmand &
196 # Things should be alright now.
200 if [ -f /var/run/devmand.pid ]
202 kill -INT `cat /var/run/devmand.pid`
203 # without this delay the following will
204 # be printed in the console
205 # RS: devman not running?
209 # usbd needs to be stopped exactly
210 # at this stage(before stopping devman
211 # and after stopping the services
213 if [ -x /usr/pkg/etc/rc.d/usbd ]
215 /usr/pkg/etc/rc.d/usbd stop
217 # Tell RS server we're going down.
222 # Further initialization.
223 test -f /usr/etc/rc && sh /usr/etc/rc $action
224 test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
227 test "$action" = start -a -f /etc/issue && cat /etc/issue