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
17 then # Older kernels do not provide an arch sysenv variable.
18 # We assume we are on x86 then, as existing systems with
19 # kernel and userland (i.e. this script) unsynchronized
26 echo >&2 "Usage: $0 [-saf] start|stop|down"
32 # Function to dynamically start a system service
34 prefix=$(expr "$1 " : '\(-\)')
35 if [ "$prefix" = "-" ];
43 service $opt up /sbin/$service "$@"
48 # Function to dynamically edit system service settings
50 prefix=$(expr "$1 " : '\(-\)')
51 if [ "$prefix" = "-" ];
59 # Assume binaries are always in /usr/sbin
60 service $opt edit /usr/sbin/$service -label $service "$@"
63 # This function parses the deprecated minix shellscript-style
64 # /etc/fstab, and fscks and mounts its filesystems.
67 echo "WARNING: old fstab format, please upgrade!"
69 # /etc/fstab lists the root, home, and usr devices.
72 intr fsck.mfs $fsckopts $usr
74 then intr fsck.mfs $fsckopts $home
78 mount $bin_img $usr /usr
81 then mount $bin_img $home /home || echo "WARNING: couldn't mount $home on /home"
85 while getopts 'saf' opt
88 s) sflag=t ;; # Single user
89 a) aflag=t ;; # Ask for /usr
90 f) fflag=-f ;; # Force a full file system check
94 shift `expr $OPTIND - 1`
97 1:start|1:stop|1:down)
107 test -f /etc/keymap && loadkeys /etc/keymap
109 # options for fsck. default is -r, which prompts the user for repairs.
112 if sysenv $optname >/dev/null
113 then fsckopts="`sysenv $optname`"
116 if [ "`sysenv debug_fkeys`" != 0 ]
129 # Try to read the hardware real-time clock, otherwise do it manually.
130 readclock || intr date -q
140 >/etc/utmp # /etc/utmp keeps track of logins
142 # Use MFS binary only from kernel image?
143 if [ "`sysenv bin_img`" = 1 ]
148 # Are we booting from CD?
149 bootcd="`/bin/sysenv bootcd`"
151 # If booting from CD, mounting is a special case.
152 # We know what to do - only /usr is mounted and it's readonly.
154 then usrdev="$cddev"p2
155 echo "/usr on cd is $usrdev"
156 mount -r $usrdev /usr
158 # If we're not booting from CD, fsck + mount using /etc/fstab.
159 read <$FSTAB fstabline
160 if [ "$fstabline" = "# Poor man's File System Table." ]
161 then mountfstab_poorman # Old minix /etc/fstab
162 else fsck -x / $fflag $fsckopts
167 # Unmount and free now defunct ramdisk
168 umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
169 ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
171 # Edit settings for boot system services
172 if [ "`sysenv skip_boot_config`" != 1 ]
187 # This file is necessary for above 'shutdown -C' check.
188 # (Silence stderr in case of running from cd.)
189 touch /usr/adm/wtmp /etc/wtmp 2>/dev/null
193 echo "Single user. Press ^D to resume multiuser startup."
198 echo "Multiuser startup in progress ..."
200 case "`printroot -r`":$bootcd in
202 # Remove boot-only things to make space,
203 # unless booting from CD, in which case we need them.
205 # put the compiler on ram
206 cp /usr/lib/em* /usr/lib/cpp* /lib
211 echo -n "Starting hotplugging infrastructure... "
212 rm -f /var/run/devmand.pid
213 devmand -d /etc/devmand -d /usr/pkg/etc/devmand &
217 # Things should be alright now.
223 if [ -f /var/run/devmand.pid ]
225 kill -INT `cat /var/run/devmand.pid`
226 # without this delay the following will
227 # be printed in the console
228 # RS: devman not running?
232 # usbd needs to be stopped exactly
233 # at this stage(before stopping devman
234 # and after stopping the services
236 if [ -x /usr/pkg/etc/rc.d/usbd ]
238 /usr/pkg/etc/rc.d/usbd stop
242 # Tell RS server we're going down.
247 # Further initialization.
248 test -f /usr/etc/rc && sh /usr/etc/rc $action
249 test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
252 test "$action" = start -a -f /etc/issue && cat /etc/issue