1 # /etc/rc - System startup script run by init before going multiuser.
12 PATH=/usr/local/bin:/bin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/pkg/sbin:/sbin
13 RC_TZ=/etc/rc.timezone
18 echo >&2 "Usage: $0 [-saf] start|stop|down"
24 # Function to dynamically start a system service
26 prefix=$(expr "$1 " : '\(-\)')
27 if [ "$prefix" = "-" ];
35 service $opt up /sbin/$service "$@"
40 # Function to dynamically edit system service settings
42 prefix=$(expr "$1 " : '\(-\)')
43 if [ "$prefix" = "-" ];
51 # Assume binaries are always in /usr/sbin
52 service $opt edit /usr/sbin/$service -label $service "$@"
55 # This function parses the deprecated minix shellscript-style
56 # /etc/fstab, and fscks and mounts its filesystems.
59 echo "WARNING: old fstab format, please upgrade!"
61 # /etc/fstab lists the root, home, and usr devices.
64 intr fsck.mfs $fsckopts $usr
66 then intr fsck.mfs $fsckopts $home
70 mount $bin_img $usr /usr
73 then mount $bin_img $home /home || echo "WARNING: couldn't mount $home on /home"
77 while getopts 'saf' opt
80 s) sflag=t ;; # Single user
81 a) aflag=t ;; # Ask for /usr
82 f) fflag=-f ;; # Force a full file system check
86 shift `expr $OPTIND - 1`
89 1:start|1:stop|1:down)
97 echo -n "Multiuser startup in progress ..."
100 test -f /etc/keymap && loadkeys /etc/keymap
102 # options for fsck. default is -r, which prompts the user for repairs.
105 if sysenv $optname >/dev/null
106 then fsckopts="`sysenv $optname`"
109 if [ "`sysenv debug_fkeys`" != 0 ]
121 # Try to read the hardware real-time clock, otherwise do it manually.
122 readclock || intr date -q
125 printroot >/etc/mtab # /etc/mtab keeps track of mounts
126 >/etc/utmp # /etc/utmp keeps track of logins
128 # Unmount now defunct ramdisk
129 umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
131 # Use MFS binary only from kernel image?
132 if [ "`sysenv bin_img`" = 1 ]
137 # Are we booting from CD?
138 bootcd="`/bin/sysenv bootcd`"
140 # If booting from CD, mounting is a special case.
141 # We know what to do - only /usr is mounted and it's readonly.
143 then usrdev="$cddev"p2
144 echo "/usr on cd is $usrdev"
145 mount -r $usrdev /usr
147 # If we're not booting from CD, fsck + mount using /etc/fstab.
148 read <$FSTAB fstabline
149 if [ "$fstabline" = "# Poor man's File System Table." ]
150 then mountfstab_poorman # Old minix /etc/fstab
151 else fsck -x / $fflag $fsckopts
156 # Edit settings for boot system services
157 if [ "`sysenv skip_boot_config`" != 1 ]
172 # This file is necessary for above 'shutdown -C' check.
173 # (Silence stderr in case of running from cd.)
174 touch /usr/adm/wtmp /etc/wtmp 2>/dev/null
182 case "`printroot -r`":$bootcd in
184 # Remove boot-only things to make space,
185 # unless booting from CD, in which case we need them.
187 # put the compiler on ram
188 cp /usr/lib/em* /usr/lib/cpp* /lib
191 # Things should be alright now.
195 # Tell RS server we're going down.
200 # Further initialization.
201 test -f /usr/etc/rc && sh /usr/etc/rc $action
202 test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
205 test "$action" = start -a -f /etc/issue && cat /etc/issue