1 # /etc/rc - System startup script run by init before going multiuser.
9 # Same settings as in the default /etc/profile. We do not source this file
10 # as the system administrator may decide to change those values for his users.
11 RC_TZ=/etc/rc.timezone
12 PATH=/usr/local/sbin:/usr/pkg/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/pkg/bin:/usr/bin:/bin
14 # Set TERM to minix if not present.
24 echo >&2 "Usage: $0 [-saf] autoboot|start|stop|down"
30 # Function to dynamically start a system service
32 prefix=$(expr "$1 " : '\(-\)')
33 if [ "$prefix" = "-" ];
41 service $opt up /service/$service "$@"
46 # Function to dynamically edit system service settings
48 prefix=$(expr "$1 " : '\(-\)')
49 if [ "$prefix" = "-" ];
57 # Assume binaries are always in /service or /usr/pkg/service
58 binlocation=/service/$service
59 if [ ! -x $binlocation ]
60 then binlocation=/usr/pkg/service/$service
63 # Mostly to find init...
64 if [ ! -x $binlocation ]
65 then binlocation=/sbin/$service
67 service $opt edit $binlocation -label $service "$@"
70 while getopts 'saf' opt
73 s) sflag=t ;; # Single user
74 a) aflag=t ;; # Ask for /usr
75 f) fflag=-f ;; # Force a full file system check
79 shift `expr $OPTIND - 1`
82 1:start|1:stop|1:down|1:autoboot)
92 test -f /etc/keymap && loadkeys /etc/keymap
94 # options for fsck. default is -r, which prompts the user for repairs.
97 if sysenv $optname >/dev/null
98 then fsckopts="`sysenv $optname`"
101 if [ "`sysenv debug_fkeys`" != 0 ]
112 # Start real time clock driver & set system time, otherwise default date.
114 readclock -q || date 201301010000
116 # We are not shutting down.
120 >/var/run/utmp # /etc/utmp keeps track of logins
121 >/var/run/utmpx # /etc/utmpx 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 fsck -x / $fflag $fsckopts
144 # Unmount and free now defunct ramdisk
145 umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
146 ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
148 # Edit settings for boot system services
149 if [ "`sysenv skip_boot_config`" != 1 ]
165 echo "Single user. Press ^D to resume multiuser startup."
170 echo "Multiuser startup in progress ..."
172 case "`printroot -r`":$bootcd in
174 # Remove boot-only things to make space,
175 # unless booting from CD, in which case we need them.
177 # put the compiler on ram
178 cp /usr/lib/em* /usr/lib/cpp* /lib
181 echo -n "Starting hotplugging infrastructure... "
182 rm -f /var/run/devmand.pid
183 devmand -d /etc/devmand -d /usr/pkg/etc/devmand &
186 # Things should be alright now.
190 if [ -f /var/run/devmand.pid ]
192 kill -INT `cat /var/run/devmand.pid`
193 # without this delay the following will
194 # be printed in the console
195 # RS: devman not running?
199 # usbd needs to be stopped exactly
200 # at this stage(before stopping devman
201 # and after stopping the services
203 if [ -x /usr/pkg/etc/rc.d/usbd ]
205 /usr/pkg/etc/rc.d/usbd stop
208 if [ -x /service/usbd ]
213 # Tell RS server we're going down.
218 # Further initialization.
219 test -f /usr/etc/rc && sh /usr/etc/rc $action
220 test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
223 if [ "$action" = start -o "$action" = autoboot ]
224 then if [ -f /etc/issue ]