2005-04-21 16:53:53 +02:00
|
|
|
# /etc/rc - System startup script run by init before going multiuser.
|
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
# Are we booting from CD?
|
|
|
|
bootcd="`/bin/sysenv bootcd`"
|
|
|
|
|
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
|
2013-10-30 18:12:35 +01:00
|
|
|
|
|
|
|
# Same settings as in the default /etc/profile. We do not source this file
|
|
|
|
# as the system administrator may decide to change those values for his users.
|
2005-08-09 18:58:28 +02:00
|
|
|
RC_TZ=/etc/rc.timezone
|
2013-10-30 18:12:35 +01:00
|
|
|
PATH=/usr/local/sbin:/usr/pkg/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/pkg/bin:/usr/bin:/bin
|
|
|
|
|
|
|
|
# Set TERM to minix if not present.
|
|
|
|
TERM="${TERM-minix}"
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
export TERM PATH
|
|
|
|
|
2013-10-30 18:12:35 +01:00
|
|
|
# Local variables
|
2013-03-06 19:27:47 +01:00
|
|
|
ARCH="`sysenv arch`"
|
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
usage()
|
|
|
|
{
|
2013-09-09 15:20:18 +02:00
|
|
|
echo >&2 "Usage: $0 [-saf] autoboot|start|stop|down"
|
2005-04-21 16:53:53 +02:00
|
|
|
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
|
|
|
|
2014-07-29 20:29:57 +02:00
|
|
|
service $opt up /service/$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
|
|
|
|
|
2014-07-29 20:29:57 +02:00
|
|
|
# Assume binaries are always in /service or /usr/pkg/service
|
|
|
|
binlocation=/service/$service
|
2013-09-09 15:20:18 +02:00
|
|
|
if [ ! -x $binlocation ]
|
2014-07-29 20:29:57 +02:00
|
|
|
then binlocation=/usr/pkg/service/$service
|
2013-09-09 15:20:18 +02:00
|
|
|
fi
|
2014-08-08 17:50:03 +02:00
|
|
|
|
|
|
|
# Mostly to find init...
|
|
|
|
if [ ! -x $binlocation ]
|
|
|
|
then binlocation=/sbin/$service
|
|
|
|
fi
|
2015-09-14 21:46:48 +02:00
|
|
|
service $opt edit $binlocation -label $service "$@"
|
2011-11-09 16:34:47 +01: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
|
2013-09-09 15:20:18 +02:00
|
|
|
1:start|1:stop|1:down|1:autoboot)
|
2005-04-21 16:53:53 +02:00
|
|
|
action=$1
|
|
|
|
;;
|
|
|
|
*) usage
|
|
|
|
esac
|
|
|
|
|
|
|
|
case $action in
|
2013-09-09 15:20:18 +02:00
|
|
|
autoboot|start)
|
2015-09-14 21:46:48 +02:00
|
|
|
# If booting from CD, we want some directories to be ramdisks
|
|
|
|
if [ ! -z "$bootcd" ]
|
|
|
|
then
|
|
|
|
. /etc/rc.cd
|
|
|
|
fi
|
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.
|
2011-12-22 22:51:26 +01:00
|
|
|
optname=fsckopts
|
|
|
|
fsckopts=-p
|
|
|
|
if sysenv $optname >/dev/null
|
|
|
|
then fsckopts="`sysenv $optname`"
|
2010-03-31 17:06:53 +02:00
|
|
|
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
|
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" ]
|
2015-09-14 21:46:48 +02:00
|
|
|
then
|
|
|
|
. "$RC_TZ"
|
2005-08-09 18:58:28 +02:00
|
|
|
fi
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2013-08-02 16:10:30 +02:00
|
|
|
# Start real time clock driver & set system time, otherwise default date.
|
|
|
|
up readclock.drv
|
2013-08-08 02:06:47 +02:00
|
|
|
readclock -q || date 201301010000
|
2005-04-21 16:53:53 +02:00
|
|
|
|
2013-09-09 15:20:18 +02:00
|
|
|
# We are not shutting down.
|
2015-09-14 21:46:48 +02:00
|
|
|
if [ -f /etc/nologin ]
|
|
|
|
then
|
|
|
|
rm -f /etc/nologin
|
|
|
|
fi
|
2005-04-21 16:53:53 +02:00
|
|
|
|
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
|
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
# fsck + mount using /etc/fstab.
|
|
|
|
fsck -x / $fflag $fsckopts
|
|
|
|
mount -a
|
2005-09-01 18:26:22 +02:00
|
|
|
|
2012-09-18 13:17:52 +02:00
|
|
|
# Unmount and free now defunct ramdisk
|
|
|
|
umount /dev/imgrd > /dev/null || echo "Failed to unmount boot ramdisk"
|
|
|
|
ramdisk 0 /dev/imgrd || echo "Failed to free boot ramdisk"
|
|
|
|
|
2015-09-14 21:46:48 +02:00
|
|
|
# Initialize files.
|
|
|
|
>/var/run/utmp # /etc/utmp keeps track of logins
|
|
|
|
>/var/run/utmpx # /etc/utmpx keeps track of logins
|
|
|
|
|
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
|
2013-09-21 17:35:15 +02:00
|
|
|
edit pfs
|
2010-07-13 23:11:44 +02:00
|
|
|
edit init
|
2014-12-22 03:34:01 +01:00
|
|
|
#
|
|
|
|
# Keep a copy around to recover the root FS from crashes
|
|
|
|
#
|
|
|
|
rootline=`cat /etc/mtab | grep "on / "`
|
|
|
|
rootfs=fs_`echo "$rootline" | cut -d' ' -f1 | cut -d'/' -f3`
|
|
|
|
roottype=`echo "$rootline" | cut -d' ' -f5`
|
|
|
|
service -c edit /service/$roottype -label $rootfs
|
2010-07-13 23:11:44 +02:00
|
|
|
fi
|
2010-07-05 21:37:08 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
if [ "$sflag" ]
|
|
|
|
then
|
2012-04-13 15:52:48 +02:00
|
|
|
echo "Single user. Press ^D to resume multiuser startup."
|
2005-04-21 16:53:53 +02:00
|
|
|
intr sh
|
2012-04-13 15:52:48 +02:00
|
|
|
echo
|
2005-04-21 16:53:53 +02:00
|
|
|
fi
|
|
|
|
|
2012-04-13 15:52:48 +02:00
|
|
|
echo "Multiuser startup in progress ..."
|
|
|
|
|
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
|
|
|
|
|
2014-05-26 16:47:46 +02:00
|
|
|
echo -n "Starting hotplugging infrastructure... "
|
|
|
|
rm -f /var/run/devmand.pid
|
|
|
|
devmand -d /etc/devmand -d /usr/pkg/etc/devmand &
|
|
|
|
echo "done."
|
2012-06-04 13:15:23 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
# Things should be alright now.
|
2005-10-20 22:38:58 +02:00
|
|
|
;;
|
|
|
|
down|stop)
|
|
|
|
sync
|
2014-05-26 16:47:46 +02:00
|
|
|
if [ -f /var/run/devmand.pid ]
|
2012-06-04 13:15:23 +02:00
|
|
|
then
|
2014-05-26 16:47:46 +02:00
|
|
|
kill -INT `cat /var/run/devmand.pid`
|
2015-09-14 21:46:48 +02:00
|
|
|
# without this delay the following will
|
2014-05-26 16:47:46 +02:00
|
|
|
# be printed in the console
|
|
|
|
# RS: devman not running?
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
#
|
2015-09-14 21:46:48 +02:00
|
|
|
# usbd needs to be stopped exactly
|
2014-05-26 16:47:46 +02:00
|
|
|
# at this stage(before stopping devman
|
|
|
|
# and after stopping the services
|
|
|
|
# stated by devmand)
|
|
|
|
if [ -x /usr/pkg/etc/rc.d/usbd ]
|
2015-09-14 21:46:48 +02:00
|
|
|
then
|
2014-05-26 16:47:46 +02:00
|
|
|
/usr/pkg/etc/rc.d/usbd stop
|
2012-06-04 13:15:23 +02:00
|
|
|
fi
|
2013-03-06 19:27:47 +01:00
|
|
|
|
2014-07-29 20:29:57 +02:00
|
|
|
if [ -x /service/usbd ]
|
2014-05-26 16:47:53 +02:00
|
|
|
then
|
|
|
|
service down usbd
|
|
|
|
fi
|
|
|
|
|
2005-10-20 22:38:58 +02:00
|
|
|
# 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?
|
2013-09-09 15:20:18 +02:00
|
|
|
if [ "$action" = start -o "$action" = autoboot ]
|
|
|
|
then if [ -f /etc/issue ]
|
|
|
|
then cat /etc/issue
|
|
|
|
fi
|
|
|
|
fi
|
2005-08-31 18:29:56 +02:00
|
|
|
|
2005-04-21 16:53:53 +02:00
|
|
|
exit 0
|