2005-04-21 16:53:53 +02:00
|
|
|
# /etc/rc - System startup script run by init before going multiuser.
|
|
|
|
|
2011-11-09 16:34:47 +01:00
|
|
|
. /etc/rc.subr.minix
|
|
|
|
|
2008-12-11 15:50:56 +01:00
|
|
|
exec >/dev/log
|
|
|
|
exec 2>/dev/log
|
|
|
|
exec </dev/null
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
umask 022
|
2011-11-09 16:34:47 +01:00
|
|
|
FSTAB=/etc/fstab
|
2005-04-21 16:53:53 +02:00
|
|
|
TERM="${TERM-minix}"
|
2010-09-12 19:56:53 +02:00
|
|
|
PATH=/usr/local/bin:/bin:/usr/bin:/usr/sbin:/usr/pkg/bin:/usr/pkg/sbin:/sbin
|
2005-08-09 18:58:28 +02:00
|
|
|
RC_TZ=/etc/rc.timezone
|
2005-04-21 16:53:53 +02:00
|
|
|
export TERM PATH
|
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo >&2 "Usage: $0 [-saf] start|stop|down"
|
|
|
|
exec intr sh
|
|
|
|
}
|
|
|
|
|
2010-07-05 21:37:08 +02:00
|
|
|
up()
|
2005-08-04 21:23:03 +02:00
|
|
|
{
|
2010-07-05 21:37:08 +02:00
|
|
|
# Function to dynamically start a system service
|
|
|
|
opt=""
|
|
|
|
prefix=$(expr "$1 " : '\(-\)')
|
|
|
|
if [ "$prefix" = "-" ];
|
|
|
|
then
|
|
|
|
opt=$1
|
|
|
|
shift
|
|
|
|
fi
|
2005-08-04 21:23:03 +02:00
|
|
|
service=$1
|
2005-11-28 16:39:01 +01:00
|
|
|
shift
|
2005-08-04 21:23:03 +02:00
|
|
|
|
2010-04-09 23:56:44 +02:00
|
|
|
service $opt up /sbin/$service "$@"
|
2005-08-04 21:23:03 +02:00
|
|
|
}
|
|
|
|
|
2010-07-05 21:37:08 +02:00
|
|
|
edit()
|
|
|
|
{
|
|
|
|
# Function to dynamically edit system service settings
|
|
|
|
opt=""
|
|
|
|
prefix=$(expr "$1 " : '\(-\)')
|
|
|
|
if [ "$prefix" = "-" ];
|
|
|
|
then
|
|
|
|
opt=$1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
service=$1
|
|
|
|
shift
|
|
|
|
|
|
|
|
# Assume binaries are always in /usr/sbin
|
2011-11-09 16:34:47 +01:00
|
|
|
service $opt edit /usr/sbin/$service -label $service "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# This function parses the deprecated minix shellscript-style
|
|
|
|
# /etc/fstab, and fscks and mounts its filesystems.
|
|
|
|
mountfstab_poorman()
|
|
|
|
{
|
|
|
|
# /etc/fstab lists the root, tmp and usr devices.
|
|
|
|
. $FSTAB
|
|
|
|
|
|
|
|
# Check if the system crashed.
|
|
|
|
if shutdown -C
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "The system was not properly shut down. Checking file systems."
|
|
|
|
fflag=-f
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$fflag" ]
|
|
|
|
then
|
|
|
|
echo "fsck.mfs / - $root"
|
|
|
|
intr fsck.mfs $fsckopts $root
|
|
|
|
echo "fsck.mfs /usr - $usr"
|
|
|
|
intr fsck.mfs $fsckopts $usr
|
|
|
|
if [ ! -z "$home" ]
|
|
|
|
then echo "fsck.mfs /home - $home"
|
|
|
|
intr fsck.mfs $fsckopts $home
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# mount /usr
|
|
|
|
mount $bin_img $usr /usr
|
|
|
|
|
|
|
|
if [ ! -z "$home" ]
|
|
|
|
then mount $bin_img $home /home || echo "WARNING: couldn't mount $home on /home"
|
|
|
|
fi
|
2010-07-05 21:37:08 +02:00
|
|
|
}
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
while getopts 'saf' opt
|
|
|
|
do
|
|
|
|
case $opt in
|
|
|
|
s) sflag=t ;; # Single user
|
|
|
|
a) aflag=t ;; # Ask for /usr
|
2011-11-09 16:34:47 +01:00
|
|
|
f) fflag=-f ;; # Force a full file system check
|
2005-04-21 16:53:53 +02:00
|
|
|
*) usage
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift `expr $OPTIND - 1`
|
|
|
|
|
|
|
|
case "$#:$1" in
|
|
|
|
1:start|1:stop|1:down)
|
|
|
|
action=$1
|
|
|
|
;;
|
|
|
|
*) usage
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $action in
|
|
|
|
start)
|
2010-07-05 21:37:08 +02:00
|
|
|
echo -n "Multiuser startup in progress ..."
|
2005-06-17 11:00:31 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
# National keyboard?
|
|
|
|
test -f /etc/keymap && loadkeys /etc/keymap
|
|
|
|
|
2010-03-31 17:06:53 +02:00
|
|
|
# options for fsck. default is -r, which prompts the user for repairs.
|
|
|
|
fsckopts="`sysenv fsckopts`"
|
|
|
|
if [ ! "$fsckopts" ]
|
|
|
|
then fsckopts=-r
|
|
|
|
fi
|
|
|
|
|
2009-12-23 00:30:50 +01:00
|
|
|
if [ "`sysenv debug_fkeys`" != 0 ]
|
|
|
|
then
|
2010-07-05 21:37:08 +02:00
|
|
|
up -n is -period 5HZ
|
2009-12-23 00:30:50 +01:00
|
|
|
fi
|
2010-07-05 21:37:08 +02:00
|
|
|
echo
|
2005-08-04 21:23:03 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
# Set timezone.
|
2005-08-09 18:58:28 +02:00
|
|
|
export TZ=GMT0
|
|
|
|
if [ -f "$RC_TZ" ]
|
|
|
|
then . "$RC_TZ"
|
|
|
|
fi
|
2005-04-21 16:53:53 +02:00
|
|
|
|
|
|
|
# Try to read the hardware real-time clock, otherwise do it manually.
|
|
|
|
readclock || intr date -q
|
|
|
|
|
|
|
|
# Initialize files.
|
|
|
|
printroot >/etc/mtab # /etc/mtab keeps track of mounts
|
|
|
|
>/etc/utmp # /etc/utmp keeps track of logins
|
|
|
|
|
2010-01-21 10:58:07 +01:00
|
|
|
# Unmount now defunct ramdisk
|
|
|
|
umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
|
|
|
|
|
2009-08-18 13:36:01 +02:00
|
|
|
# Use MFS binary only from kernel image?
|
|
|
|
if [ "`sysenv bin_img`" = 1 ]
|
|
|
|
then
|
|
|
|
bin_img="-i "
|
|
|
|
fi
|
|
|
|
|
2005-05-03 10:56:01 +02:00
|
|
|
# Are we booting from CD?
|
|
|
|
bootcd="`/bin/sysenv bootcd`"
|
|
|
|
|
2011-11-09 16:34:47 +01:00
|
|
|
# If booting from CD, mounting is a special case.
|
|
|
|
# We know what to do - only /usr is mounted and it's readonly.
|
2005-05-03 10:56:01 +02:00
|
|
|
if [ "$bootcd" = 1 ]
|
2011-11-09 16:34:47 +01:00
|
|
|
then usrdev="$cddev"p2
|
|
|
|
echo "/usr on cd is $usrdev"
|
|
|
|
mount -r $usrdev /usr
|
|
|
|
else
|
|
|
|
# If we're not booting from CD, fsck + mount using /etc/fstab.
|
|
|
|
read <$FSTAB fstabline
|
|
|
|
if [ "$fstabline" = "# Poor man's File System Table." ]
|
|
|
|
then mountfstab_poorman # Old minix /etc/fstab
|
|
|
|
else mountfstab $fflag -o"$fsckopts" $FSTAB
|
|
|
|
fi
|
2005-09-01 18:26:22 +02:00
|
|
|
fi
|
|
|
|
|
2010-07-05 21:37:08 +02:00
|
|
|
# Edit settings for boot system services
|
2010-07-13 23:11:44 +02:00
|
|
|
if [ "`sysenv skip_boot_config`" != 1 ]
|
|
|
|
then
|
|
|
|
edit rs
|
|
|
|
edit vm
|
|
|
|
edit pm
|
|
|
|
edit sched
|
|
|
|
edit vfs
|
|
|
|
edit ds
|
|
|
|
edit tty
|
|
|
|
edit memory
|
|
|
|
edit -p log
|
|
|
|
edit -c pfs
|
|
|
|
edit init
|
|
|
|
fi
|
2010-07-05 21:37:08 +02:00
|
|
|
|
2005-07-04 15:30:55 +02:00
|
|
|
# This file is necessary for above 'shutdown -C' check.
|
2005-07-24 03:17:32 +02:00
|
|
|
# (Silence stderr in case of running from cd.)
|
2011-11-09 16:34:47 +01:00
|
|
|
touch /usr/adm/wtmp /etc/wtmp 2>/dev/null
|
2005-07-04 15:30:55 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
if [ "$sflag" ]
|
|
|
|
then
|
|
|
|
echo "Single user."
|
|
|
|
intr sh
|
|
|
|
fi
|
|
|
|
|
2005-05-03 10:56:01 +02:00
|
|
|
case "`printroot -r`":$bootcd in
|
|
|
|
/dev/ram:)
|
|
|
|
# Remove boot-only things to make space,
|
|
|
|
# unless booting from CD, in which case we need them.
|
|
|
|
rm -rf /boot
|
2005-08-09 16:41:54 +02:00
|
|
|
# put the compiler on ram
|
|
|
|
cp /usr/lib/em* /usr/lib/cpp* /lib
|
2005-04-21 16:53:53 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Things should be alright now.
|
2005-10-20 22:38:58 +02:00
|
|
|
;;
|
|
|
|
down|stop)
|
|
|
|
sync
|
|
|
|
# Tell RS server we're going down.
|
|
|
|
service shutdown
|
|
|
|
;;
|
2005-04-21 16:53:53 +02:00
|
|
|
esac
|
|
|
|
|
|
|
|
# Further initialization.
|
|
|
|
test -f /usr/etc/rc && sh /usr/etc/rc $action
|
|
|
|
test -f /usr/local/etc/rc && sh /usr/local/etc/rc $action
|
|
|
|
|
|
|
|
# Any messages?
|
|
|
|
test "$action" = start -a -f /etc/issue && cat /etc/issue
|
2005-08-31 18:29:56 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
exit 0
|