1 # /etc/rc - System startup script run by init before going multiuser.
3 if sysenv bootramdisk >/dev/null
5 /bin/sh /etc/rc.ramdisk
8 # Are we booting from CD?
9 bootcd="`/bin/sysenv bootcd`"
17 # Same settings as in the default /etc/profile. We do not source this file
18 # as the system administrator may decide to change those values for his users.
19 RC_TZ=/etc/rc.timezone
20 PATH=/usr/local/sbin:/usr/pkg/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/pkg/bin:/usr/bin:/bin
22 # Set TERM to minix if not present.
32 echo >&2 "Usage: $0 [-saf] autoboot|start|stop|down"
38 # Function to dynamically start a system service
40 prefix=$(expr "$1 " : '\(-\)')
41 if [ "$prefix" = "-" ];
49 service $opt up /service/$service "$@"
54 # Function to dynamically edit system service settings
56 prefix=$(expr "$1 " : '\(-\)')
57 if [ "$prefix" = "-" ];
65 # Assume binaries are always in /service or /usr/pkg/service
66 binlocation=/service/$service
67 if [ ! -x $binlocation ]
68 then binlocation=/usr/pkg/service/$service
71 # Mostly to find init...
72 if [ ! -x $binlocation ]
73 then binlocation=/sbin/$service
75 service $opt edit $binlocation -label $service "$@"
78 while getopts 'saf' opt
81 s) sflag=t ;; # Single user
82 a) aflag=t ;; # Ask for /usr
83 f) fflag=-f ;; # Force a full file system check
87 shift `expr $OPTIND - 1`
90 1:start|1:stop|1:down|1:autoboot)
98 # If booting from CD, we want some directories to be ramdisks
105 test -f /etc/keymap && loadkeys /etc/keymap
107 # options for fsck. default is -r, which prompts the user for repairs.
110 if sysenv $optname >/dev/null
111 then fsckopts="`sysenv $optname`"
114 if [ "`sysenv debug_fkeys`" != 0 ]
126 # Start real time clock driver & set system time, otherwise default date.
128 readclock -q || date 201301010000
130 # We are not shutting down.
131 if [ -f /etc/nologin ]
136 # Use MFS binary only from kernel image?
137 if [ "`sysenv bin_img`" = 1 ]
142 # fsck + mount using /etc/fstab.
143 fsck -x / $fflag $fsckopts
146 if [ -z "`sysenv bootramdisk`" ]
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"
154 >/var/run/utmp # /etc/utmp keeps track of logins
155 >/var/run/utmpx # /etc/utmpx keeps track of logins
157 # Edit settings for boot system services
158 if [ "`sysenv skip_boot_config`" != 1 ]
172 # Keep a copy around to recover the root FS from crashes
174 rootline=`cat /etc/mtab | grep "on / "`
175 rootfs=fs_`echo "$rootline" | cut -d' ' -f1 | cut -d'/' -f3`
176 roottype=`echo "$rootline" | cut -d' ' -f5`
177 service -c edit /service/$roottype -label $rootfs
182 echo "Single user. Press ^D to resume multiuser startup."
187 echo "Multiuser startup in progress ..."
189 case "`printroot -r`":$bootcd in
191 # Remove boot-only things to make space,
192 # unless booting from CD, in which case we need them.
194 # put the compiler on ram
195 cp /usr/lib/em* /usr/lib/cpp* /lib
198 echo -n "Starting hotplugging infrastructure... "
199 rm -f /var/run/devmand.pid
200 devmand -d /etc/devmand -d /usr/pkg/etc/devmand &
203 # Things should be alright now.
207 if [ -f /var/run/devmand.pid ]
209 kill -INT `cat /var/run/devmand.pid`
210 # without this delay the following will
211 # be printed in the console
212 # RS: devman not running?
216 # usbd needs to be stopped exactly
217 # at this stage(before stopping devman
218 # and after stopping the services
220 if [ -x /usr/pkg/etc/rc.d/usbd ]
222 /usr/pkg/etc/rc.d/usbd stop
225 if [ -x /service/usbd ]
230 # Tell RS server we're going down.
235 # Further initialization.
236 test -f /usr/etc/rc && sh /usr/etc/rc $action
237 test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
240 if [ "$action" = start -o "$action" = autoboot ]
241 then if [ -f /etc/issue ]