1 # /etc/rc.minix - MINIX system startup script
3 PATH=/sbin:/usr/sbin:/bin:/usr/bin
5 # The normal system boot situation is that init(8) invokes the ramdisk RC
6 # script, which invokes the NetBSD rc infrastructure, which in turn calls this
7 # script through /etc/rc.d/minixrc. With a boot ramdisk (x86_ramimage), the
8 # ramdisk RC is bypassed altogether, but stored as /etc/rc.ramdisk. We then
9 # have to invoke it here (for startup only!) to let it perform its tasks first.
10 if sysenv bootramdisk >/dev/null
12 [ "$1" = "start" ] && sh /etc/rc.ramdisk "$@"
15 # Same settings as in the default /etc/profile. We do not source this file
16 # as the system administrator may decide to change those values for his users.
17 RC_TZ=/etc/rc.timezone
19 # Are we booting from CD?
20 bootcd="`/bin/sysenv bootcd`"
22 # Set TERM to minix if not present.
32 echo >&2 "Usage: $0 [-saf] [start|stop]"
38 # Function to dynamically start a system service
40 prefix=$(expr "$1 " : '\(-\)')
41 if [ "$prefix" = "-" ];
49 minix-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 minix-service $opt edit $binlocation -label $service "$@"
78 set -- `sysenv bootopt` "$@"
79 while getopts 'saf' opt
82 s) sflag=t ;; # Single user
83 a) aflag=t ;; # Ask for /usr
84 f) fflag=-f ;; # Force a full file system check
88 shift `expr $OPTIND - 1`
99 # If booting from CD, we want some directories to be ramdisks
100 if [ ! -z "$bootcd" ]
106 test -f /etc/keymap && loadkeys /etc/keymap
108 # options for fsck. default is -r, which prompts the user for repairs.
111 if sysenv $optname >/dev/null
112 then fsckopts="`sysenv $optname`"
115 if [ "`sysenv debug_fkeys`" != 0 ]
127 # Start real time clock driver & set system time, otherwise default date.
129 readclock -q || date 201301010000
131 # We are not shutting down.
132 if [ -f /etc/nologin ]
137 # Use MFS binary only from kernel image?
138 if [ "`sysenv bin_img`" = 1 ]
143 # fsck + mount using /etc/fstab.
144 fsck -x / $fflag $fsckopts
147 if [ -z "`sysenv bootramdisk`" ]
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"
155 >/var/run/utmp # /etc/utmp keeps track of logins
156 >/var/run/utmpx # /etc/utmpx keeps track of logins
158 # Edit settings for boot system services
159 if [ "`sysenv skip_boot_config`" != 1 ]
173 # Keep a copy around to recover the root FS from crashes
175 rootline=`cat /etc/mtab | grep "on / "`
176 rootfs=fs_`echo "$rootline" | cut -d' ' -f1 | cut -d'/' -f3`
177 [ "$rootfs" = "fs_bootramdisk" ] && rootfs=fs_imgrd
178 roottype=`echo "$rootline" | cut -d' ' -f5`
179 minix-service -c edit /service/$roottype -label $rootfs
184 echo "Single user. Press ^D to resume multiuser startup."
189 echo "Multiuser startup in progress ..."
191 case "`printroot -r`":$bootcd in
193 # Remove boot-only things to make space,
194 # unless booting from CD, in which case we need them.
196 # put the compiler on ram
197 cp /usr/lib/em* /usr/lib/cpp* /lib
200 echo -n "Starting hotplugging infrastructure... "
201 rm -f /var/run/devmand.pid
202 devmand -d /etc/devmand -d /usr/pkg/etc/devmand &
205 # Things should be alright now.
209 if [ -f /var/run/devmand.pid ]
211 kill -INT `cat /var/run/devmand.pid`
212 # without this delay the following will
213 # be printed in the console
214 # RS: devman not running?
218 if [ -x /service/usbd ]
220 minix-service down usbd
223 # Tell RS server we're going down.
224 minix-service shutdown
228 # Further initialization.
229 test -f /usr/etc/rc && sh /usr/etc/rc $action
230 test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
233 if [ "$action" = start ]
234 then if [ -f /etc/issue ]