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 /sbin/$service "$@"
46 # Function to dynamically edit system service settings
48 prefix=$(expr "$1 " : '\(-\)')
49 if [ "$prefix" = "-" ];
57 # Assume binaries are always in /sbin or /usr/sbin
58 binlocation=/usr/sbin/$service
59 if [ ! -x $binlocation ]
60 then binlocation=/sbin/$service
62 service $opt edit $binlocation -label $service "$@"
65 while getopts 'saf' opt
68 s) sflag=t ;; # Single user
69 a) aflag=t ;; # Ask for /usr
70 f) fflag=-f ;; # Force a full file system check
74 shift `expr $OPTIND - 1`
77 1:start|1:stop|1:down|1:autoboot)
87 test -f /etc/keymap && loadkeys /etc/keymap
89 # options for fsck. default is -r, which prompts the user for repairs.
92 if sysenv $optname >/dev/null
93 then fsckopts="`sysenv $optname`"
96 if [ "`sysenv debug_fkeys`" != 0 ]
107 # Start real time clock driver & set system time, otherwise default date.
109 readclock -q || date 201301010000
111 # We are not shutting down.
115 >/var/run/utmp # /etc/utmp keeps track of logins
116 >/var/run/utmpx # /etc/utmpx keeps track of logins
118 # Use MFS binary only from kernel image?
119 if [ "`sysenv bin_img`" = 1 ]
124 # Are we booting from CD?
125 bootcd="`/bin/sysenv bootcd`"
127 # If booting from CD, mounting is a special case.
128 # We know what to do - only /usr is mounted and it's readonly.
130 then usrdev="$cddev"p2
131 echo "/usr on cd is $usrdev"
132 mount -r $usrdev /usr
134 # If we're not booting from CD, fsck + mount using /etc/fstab.
135 fsck -x / $fflag $fsckopts
139 # Unmount and free now defunct ramdisk
140 umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
141 ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
143 # Edit settings for boot system services
144 if [ "`sysenv skip_boot_config`" != 1 ]
160 echo "Single user. Press ^D to resume multiuser startup."
165 echo "Multiuser startup in progress ..."
167 case "`printroot -r`":$bootcd in
169 # Remove boot-only things to make space,
170 # unless booting from CD, in which case we need them.
172 # put the compiler on ram
173 cp /usr/lib/em* /usr/lib/cpp* /lib
176 echo -n "Starting hotplugging infrastructure... "
177 rm -f /var/run/devmand.pid
178 devmand -d /etc/devmand -d /usr/pkg/etc/devmand &
181 # Things should be alright now.
185 if [ -f /var/run/devmand.pid ]
187 kill -INT `cat /var/run/devmand.pid`
188 # without this delay the following will
189 # be printed in the console
190 # RS: devman not running?
194 # usbd needs to be stopped exactly
195 # at this stage(before stopping devman
196 # and after stopping the services
198 if [ -x /usr/pkg/etc/rc.d/usbd ]
200 /usr/pkg/etc/rc.d/usbd stop
203 if [ -x /usr/sbin/usbd ]
208 # Tell RS server we're going down.
213 # Further initialization.
214 test -f /usr/etc/rc && sh /usr/etc/rc $action
215 test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
218 if [ "$action" = start -o "$action" = autoboot ]
219 then if [ -f /etc/issue ]