Added initscripts-2009.01 template.
This package contains all files required for booting the lsXL linux system built through xbps. Currently it uses the NetBSD rc.d(8) system, sysvinit and modified BSD style scripts modified from Arch linux. --HG-- extra : convert_revision : 4584be26dd672ba33f9b1d76534a22d4715664ea
This commit is contained in:
parent
d5426651e8
commit
ed07259681
|
@ -0,0 +1,14 @@
|
|||
udevd=yes
|
||||
udev_events=yes
|
||||
klogd=yes
|
||||
syslogd=yes
|
||||
net_loopback=yes
|
||||
checkfs=yes
|
||||
mountfs=yes
|
||||
swap=yes
|
||||
sysclock=yes
|
||||
random_seed=yes
|
||||
cleartmp=yes
|
||||
locale=yes
|
||||
persistent_rules=yes
|
||||
dmesg=yes
|
|
@ -0,0 +1,42 @@
|
|||
#
|
||||
# /etc/inittab
|
||||
#
|
||||
|
||||
# Runlevels:
|
||||
# 0 Halt
|
||||
# 1(S) Single-user
|
||||
# 2 Not used
|
||||
# 3 Multi-user
|
||||
# 4 Not used
|
||||
# 5 X11
|
||||
# 6 Reboot
|
||||
|
||||
## Only one of the following two lines can be uncommented!
|
||||
# Boot to console
|
||||
id:3:initdefault:
|
||||
# Boot to X11
|
||||
#id:5:initdefault:
|
||||
|
||||
rc::sysinit:/etc/rc.sysinit
|
||||
rs:S1:wait:/etc/rc.single
|
||||
rm:2345:wait:/etc/rc.multi
|
||||
rh:06:wait:/etc/rc.shutdown
|
||||
su:S:wait:/sbin/sulogin -p
|
||||
|
||||
# -8 options fixes umlauts problem on login
|
||||
c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux
|
||||
c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux
|
||||
c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux
|
||||
c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux
|
||||
c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux
|
||||
c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux
|
||||
|
||||
ca::ctrlaltdel:/sbin/shutdown -t3 -r now
|
||||
|
||||
# Example lines for starting a login manager
|
||||
x:5:respawn:/usr/bin/xdm -nodaemon
|
||||
#x:5:respawn:/usr/sbin/gdm -nodaemon
|
||||
#x:5:respawn:/usr/bin/kdm -nodaemon
|
||||
#x:5:respawn:/usr/bin/slim >& /dev/null
|
||||
|
||||
# End of file
|
|
@ -0,0 +1,27 @@
|
|||
#
|
||||
# /etc/rc.conf - Main Configuration.
|
||||
#
|
||||
if [ -r /etc/defaults/rc.conf ]; then
|
||||
. /etc/defaults/rc.conf
|
||||
fi
|
||||
#
|
||||
# -----------------------------------------------------------------------
|
||||
# LOCALIZATION
|
||||
# -----------------------------------------------------------------------
|
||||
#
|
||||
# LOCALE: available languages can be listed with the 'locale -a' command
|
||||
# HARDWARECLOCK: set to "UTC" or "localtime"
|
||||
# TIMEZONE: timezones are found in /usr/share/zoneinfo
|
||||
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
|
||||
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
|
||||
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
|
||||
#
|
||||
LOCALE="es_ES.utf-8"
|
||||
HARDWARECLOCK="localtime"
|
||||
TIMEZONE="Europe/Madrid"
|
||||
KEYMAP="es"
|
||||
CONSOLEFONT=
|
||||
CONSOLEMAP=
|
||||
|
||||
USELVM="no"
|
||||
HOSTNAME="xbps"
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: DAEMON,v 1.8 2002/03/22 04:33:57 thorpej Exp $
|
||||
#
|
||||
|
||||
# PROVIDE: DAEMON
|
||||
# REQUIRE: NETWORKING SERVERS
|
||||
|
||||
# This is a dummy dependency, to ensure that general purpose daemons
|
||||
# are run _after_ the above are.
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: LOGIN,v 1.7 2002/03/22 04:33:57 thorpej Exp $
|
||||
#
|
||||
|
||||
# PROVIDE: LOGIN
|
||||
# REQUIRE: DAEMON
|
||||
|
||||
# This is a dummy dependency to ensure user services such as xdm,
|
||||
# inetd, cron and kerberos are started after everything else.
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: NETWORKING,v 1.2 2002/03/22 04:33:57 thorpej Exp $
|
||||
#
|
||||
|
||||
# PROVIDE: NETWORKING NETWORK
|
||||
|
||||
# This is a dummy dependency, for services which require networking
|
||||
# to be operational before starting.
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: SERVERS,v 1.9 2002/03/22 04:33:57 thorpej Exp $
|
||||
#
|
||||
|
||||
# PROVIDE: SERVERS
|
||||
# REQUIRE: udevd
|
||||
|
||||
# This is a dummy dependency, for early-start servers relying on
|
||||
# some basic configuration.
|
|
@ -0,0 +1,66 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: checkfs
|
||||
# REQUIRE: SERVERS
|
||||
# BEFORE: NETWORKING
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="checkfs"
|
||||
start_cmd="checkfs_start"
|
||||
stop_cmd=":"
|
||||
|
||||
NETFS="nonfs,nonfs4,nosmbfs,nocifs,nocodafs,noncpfs,nosysfs,noshfs,nofuse,nofuseblk"
|
||||
|
||||
checkfs_start()
|
||||
{
|
||||
echo -n "=> Mounting root read-only... "
|
||||
mount -n -o remount,ro /
|
||||
show_rval
|
||||
|
||||
FORCEFSCK=
|
||||
[ -f /forcefsck ] && FORCEFSCK="-- -f"
|
||||
|
||||
echo -n "=> Checking filesystems... "
|
||||
if grep -qw quiet /proc/cmdline; then
|
||||
fsck -A -T -C -a -t $NETFS $FORCEFSCK >/dev/null 2>&1
|
||||
else
|
||||
fsck -A -T -C -a -t $NETFS $FORCEFSCK 2>/dev/null
|
||||
fi
|
||||
fsckret=$?
|
||||
if [ ${fsckret} -gt 1 ]; then
|
||||
echo "failed!"
|
||||
if [ $((${fsckret}&2)) -eq 2 ]; then
|
||||
echo
|
||||
echo "********************** REBOOT REQUIRED *********************"
|
||||
echo "* *"
|
||||
echo "* The system will be rebooted automatically in 15 seconds. *"
|
||||
echo "* *"
|
||||
echo "************************************************************"
|
||||
echo
|
||||
sleep 15
|
||||
else
|
||||
echo
|
||||
echo "***************** FILESYSTEM CHECK FAILED ****************"
|
||||
echo "* *"
|
||||
echo "* Please repair manually and reboot. Note that the root *"
|
||||
echo "* file system is currently mounted read-only. To remount *"
|
||||
echo "* it read-write type: mount -n -o remount,rw / *"
|
||||
echo "* When you exit the maintenance shell the system will *"
|
||||
echo "* reboot automatically. *"
|
||||
echo "* *"
|
||||
echo "************************************************************"
|
||||
echo
|
||||
sulogin -p
|
||||
fi
|
||||
echo "Automatic reboot in progress..."
|
||||
umount -a
|
||||
mount -n -o remount,ro /
|
||||
reboot -f
|
||||
exit 0
|
||||
fi
|
||||
show_rval
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: cleartmp
|
||||
# REQUIRE: SERVERS random_seed
|
||||
# BEFORE: NETWORKING
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="cleartmp"
|
||||
start_cmd="cleartmp_start"
|
||||
stop_cmd=":"
|
||||
|
||||
cleartmp_start()
|
||||
{
|
||||
echo -n "=> Clearing temporary files... "
|
||||
|
||||
rm -f /etc/nologin &>/dev/null
|
||||
rm -f /etc/shutdownpid &>/dev/null
|
||||
rm -f /var/lock/* &>/dev/null
|
||||
rm -rf /tmp/* &>/dev/null
|
||||
rm -f /forcefsck &>/dev/null
|
||||
(cd /var/run && find . ! -type d -exec rm -f -- {} \; )
|
||||
: > /var/run/utmp
|
||||
chmod 0664 /var/run/utmp
|
||||
show_rval
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: dmesg
|
||||
# REQUIRE: SERVERS persistent_rules
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="dmesg"
|
||||
start_cmd="dmesg_start"
|
||||
stop_cmd=":"
|
||||
|
||||
dmesg_start()
|
||||
{
|
||||
if [ -f /var/log/dmesg.log ]; then
|
||||
rm -f /var/log/dmesg.log
|
||||
fi
|
||||
dmesg > /var/log/dmesg.log
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,118 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: locale
|
||||
# REQUIRE: cleartmp
|
||||
# BEFORE: NETWORKING
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="locale"
|
||||
start_cmd="locale_start"
|
||||
stop_cmd=":"
|
||||
|
||||
locale_start()
|
||||
{
|
||||
# Flush old locale settings
|
||||
[ ! -d /etc/profile.d ] && mkdir -p /etc/profile.d
|
||||
|
||||
: >/etc/profile.d/locale.sh
|
||||
chmod 755 /etc/profile.d/locale.sh
|
||||
|
||||
# Check if requested locale was already created
|
||||
if ! $(localedef --list-archive|grep -q $LOCALE); then
|
||||
[ ! -d /usr/lib/locale ] && mkdir -p /usr/lib/locale
|
||||
echo -n "=> Building locale: $LOCALE... "
|
||||
localedef -i ${LOCALE%.*} -f UTF-8 ${LOCALE}
|
||||
show_rval
|
||||
fi
|
||||
|
||||
# Set user defined locale
|
||||
[ -z "$LOCALE" ] && LOCALE="en_US"
|
||||
echo -n "=> Setting locale: $LOCALE... "
|
||||
echo "export LANG=$LOCALE" >> /etc/profile.d/locale.sh
|
||||
show_rval
|
||||
|
||||
if echo "$LOCALE" | grep -qi utf ; then
|
||||
echo -n "=> Setting consoles to UTF-8 mode... "
|
||||
# UTF-8 consoles are default since 2.6.24 kernel
|
||||
# this code is needed not only for older kernels,
|
||||
# but also when user has set vt.default_utf8=0 but LOCALE
|
||||
# is *.UTF-8.
|
||||
for i in $(seq 0 63); do
|
||||
[ ! -e /dev/tty${i} ] && continue
|
||||
kbd_mode -u < /dev/tty${i}
|
||||
printf "\e%%G" > /dev/tty${i}
|
||||
done
|
||||
# the $CONSOLE check helps us avoid this when running scripts
|
||||
# from cron.
|
||||
cat >> /etc/profile.d/locale.sh <<_EOF
|
||||
if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then
|
||||
printf "\e%%G"
|
||||
fi
|
||||
_EOF
|
||||
show_rval
|
||||
if [ -n "$KEYMAP" ]; then
|
||||
echo -n "=> Loading keyboard map: $KEYMAP... "
|
||||
loadkeys -q -u $KEYMAP
|
||||
show_rval
|
||||
fi
|
||||
else
|
||||
echo -n "=> Setting consoles to legacy mode... "
|
||||
# make non-UTF-8 consoles work on 2.6.24 and newer kernels
|
||||
for i in $(seq 0 63); do
|
||||
[ ! -e /dev/tty${i} ] && continue
|
||||
kbd_mode -a < /dev/tty${i}
|
||||
printf "\e%%@" > /dev/tty${i}
|
||||
done
|
||||
# the $CONSOLE check helps us avoid this when running scripts
|
||||
# from cron.
|
||||
cat >> /etc/profile.d/locale.sh <<_EOF
|
||||
if [ -z "$CONSOLE" -a "$TERM" = "linux" -a -t 1 ]; then
|
||||
printf "\e%%@"
|
||||
fi
|
||||
_EOF
|
||||
show_rval
|
||||
if [ -n "$KEYMAP" ]; then
|
||||
echo -n "=> Loading keyboard map: $KEYMAP... "
|
||||
loadkeys -q $KEYMAP
|
||||
show_rval
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$CONSOLEFONT" ]; then
|
||||
echo -n "=> Loading console font: $CONSOLEFONT... "
|
||||
# CONSOLEMAP in UTF-8 shouldn't be used
|
||||
if [ -n "$CONSOLEMAP" ] && echo "$LOCALE" | grep -qi utf ; then
|
||||
CONSOLEMAP=""
|
||||
fi
|
||||
for i in $(seq 0 63); do
|
||||
[ ! -e /dev/tty${i} ] && continue
|
||||
if [ -n "$CONSOLEMAP" ]; then
|
||||
setfont -m $CONSOLEMAP $CONSOLEFONT -C \
|
||||
/dev/tty${i} >/dev/null 2>&1
|
||||
else
|
||||
setfont $CONSOLEFONT -C /dev/tty${i} \
|
||||
>/dev/null 2>&1
|
||||
fi
|
||||
done
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "failed!"
|
||||
else
|
||||
for i in $(seq 0 63); do
|
||||
[ ! -e /dev/tty${i} ] && continue
|
||||
printf "\e(K" > /dev/tty${i}
|
||||
done
|
||||
# the $CONSOLE check helps us avoid this when running
|
||||
# scripts from cron.
|
||||
cat >> /etc/profile.d/locale.sh <<_EOF
|
||||
if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then
|
||||
printf "\e(K"
|
||||
fi
|
||||
_EOF
|
||||
echo "done."
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: mountfs
|
||||
# REQUIRE: SERVERS checkfs
|
||||
# BEFORE: NETWORKING
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="mountfs"
|
||||
start_cmd="mountfs_start"
|
||||
stop_cmd=":"
|
||||
|
||||
NETFS="nonfs,nonfs4,nosmbfs,nocifs,nocodafs,noncpfs,nosysfs,noshfs,nofuse,nofuseblk"
|
||||
|
||||
mountfs_start()
|
||||
{
|
||||
echo -n "=> Mounting local filesystems... "
|
||||
mount -n -o remount,rw /
|
||||
rm -f /etc/mtab*
|
||||
# make sure / gets written to /etc/mtab
|
||||
mount -o remount,rw /
|
||||
# Write /proc, /sys and /dev to /etc/mtab
|
||||
if [ -e /proc/mounts ]; then
|
||||
grep -e "/proc " -e "/sys " -e "/dev " /proc/mounts \
|
||||
>> /etc/mtab
|
||||
fi
|
||||
# now mount all the local filesystems
|
||||
mount -a -t $NETFS
|
||||
echo "done."
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: net_loopback
|
||||
# REQUIRE: SERVERS
|
||||
# BEFORE: checkfs
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="net_loopback"
|
||||
start_cmd="loopback_start"
|
||||
stop_cmd=":"
|
||||
|
||||
loopback_start()
|
||||
{
|
||||
if [ -d /sys/class/net/lo ]; then
|
||||
echo -n "=> Bringing up loopback interface... "
|
||||
ifconfig lo 127.0.0.1 up
|
||||
show_rval
|
||||
fi
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: persistent_rules
|
||||
# REQUIRE: SERVERS locale
|
||||
# BEFORE: NETWORKING
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="persistent_rules"
|
||||
start_cmd="persistent_start"
|
||||
stop_cmd=":"
|
||||
|
||||
persistent_start()
|
||||
{
|
||||
# Adding persistent network/cdrom generated rules
|
||||
if [ -f "/dev/.udev/tmp-rules--70-persistent-cd.rules" ]; then
|
||||
echo -n "=> Adding persistent cdrom udev rules... "
|
||||
cat /dev/.udev/tmp-rules--70-persistent-cd.rules \
|
||||
>> /etc/udev/rules.d/70-persistent-cd.rules
|
||||
show_rval
|
||||
fi
|
||||
if [ -f "/dev/.udev/tmp-rules--70-persistent-net.rules" ]; then
|
||||
echo -n "=> Adding persistent network udev rules... "
|
||||
cat /dev/.udev/tmp-rules--70-persistent-net.rules \
|
||||
>> /etc/udev/rules.d/70-persistent-net.rules
|
||||
show_rval
|
||||
fi
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: random_seed
|
||||
# REQUIRE: SERVERS sysclock
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="random_seed"
|
||||
start_cmd="rseed_start"
|
||||
stop_cmd=":"
|
||||
|
||||
rseed_start()
|
||||
{
|
||||
if [ -f /var/run/random-seed ]; then
|
||||
echo -n "=> Initializing random seed... "
|
||||
cat /var/run/random-seed >/dev/urandom
|
||||
show_rval
|
||||
fi
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: swap
|
||||
# REQUIRE: SERVERS mountfs
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="swap"
|
||||
start_cmd="swap_start"
|
||||
stop_cmd=":"
|
||||
|
||||
swap_start()
|
||||
{
|
||||
echo -n "=> Activating swap... "
|
||||
swapon -a
|
||||
show_rval
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,29 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: sysclock
|
||||
# REQUIRE: SERVERS swap
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="sysclock"
|
||||
start_cmd="sysclock_start"
|
||||
stop_cmd=":"
|
||||
|
||||
sysclock_start()
|
||||
{
|
||||
echo -n "=> Configuring system clock... "
|
||||
[ ! -d /var/lib/hwclock ] && mkdir -p /var/lib/hwclock
|
||||
if [ ! -f /var/lib/hwclock/adjtime ]; then
|
||||
echo "0.0 0 0.0" > /var/lib/hwclock/adjtime
|
||||
fi
|
||||
if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]; then
|
||||
rm -f /etc/localtime
|
||||
cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
|
||||
fi
|
||||
|
||||
hwclock $HWCLOCK_PARAMS 2>&1 >/dev/null
|
||||
show_rval
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: udev_events
|
||||
# REQUIRE: udevd
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="udev_events"
|
||||
start_cmd="udev_events_start"
|
||||
stop_cmd=":"
|
||||
|
||||
udev_events_start()
|
||||
{
|
||||
echo -n "=> Waiting for udev uevents... "
|
||||
udevadm trigger
|
||||
udevadm settle
|
||||
echo "done."
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: udevd
|
||||
|
||||
$_rc_subr_loaded . /etc/rc.subr
|
||||
|
||||
name="udevd"
|
||||
rcvar=$name
|
||||
command="/sbin/udevd"
|
||||
command_args="--daemon"
|
||||
start_precmd="udevd_precmd"
|
||||
|
||||
udevd_precmd()
|
||||
{
|
||||
# More initial /dev setup that udev doesn't do
|
||||
[ ! -d /dev/pts ] && /bin/mkdir /dev/pts
|
||||
[ ! -d /dev/shm ] && /bin/mkdir /dev/shm
|
||||
|
||||
echo > /proc/sys/kernel/hotplug
|
||||
echo
|
||||
}
|
||||
|
||||
load_rc_config $name
|
||||
run_rc_command "$1"
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# /etc/rc.local: Local multi-user startup script.
|
||||
#
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# /etc/rc.local.shutdown: Local shutdown script.
|
||||
#
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# This script is called when runlevel 3 (multiuser) is entered.
|
||||
#
|
||||
|
||||
export HOME=/
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
umask 022
|
||||
|
||||
. /etc/rc.subr
|
||||
. /etc/rc.conf
|
||||
_rc_conf_loaded=true
|
||||
|
||||
# Start services
|
||||
files=$(rcorder -s nostart ${rc_rcorder_flags} /etc/rc.d/*)
|
||||
|
||||
for _rc_elem in $files; do
|
||||
run_rc_script $_rc_elem start
|
||||
done
|
||||
|
||||
[ -x /etc/rc.local ] && /etc/rc.local
|
|
@ -0,0 +1,99 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# /etc/rc.shutdown
|
||||
#
|
||||
|
||||
export HOME=/
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
. /etc/rc.subr
|
||||
. /etc/rc.conf
|
||||
|
||||
# avoid staircase effect
|
||||
stty onlcr
|
||||
|
||||
echo " "
|
||||
echo "*** Initiating shutdown ***"
|
||||
echo " "
|
||||
|
||||
[ -x /etc/rc.local.shutdown ] && /etc/rc.local.shutdown
|
||||
|
||||
if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
|
||||
# Shutdown daemons
|
||||
files=$(rcorder -k shutdown ${rcshutdown_rcorder_flags} /etc/rc.d/*)
|
||||
|
||||
for _rc_elem in $(reverse_list $files); do
|
||||
run_rc_script $_rc_elem stop
|
||||
done
|
||||
fi
|
||||
|
||||
# Terminate all processes
|
||||
echo -n "=> Sending SIGTERM to processes... "
|
||||
killall5 -15 &> /dev/null
|
||||
sleep 5
|
||||
show_rval
|
||||
|
||||
echo -n "=> Sending SIGKILL to processes... "
|
||||
killall5 -9 &> /dev/null
|
||||
sleep 1
|
||||
show_rval
|
||||
|
||||
echo -n "=> Saving random seed... "
|
||||
dd if=/dev/urandom of=/var/run/random-seed count=1 bs=512 2> /dev/null
|
||||
show_rval
|
||||
|
||||
echo -n "=> Saving system clock... "
|
||||
if [ "$TIMEZONE" != "" -a -e "/usr/share/zoneinfo/$TIMEZONE" ]; then
|
||||
rm -f /etc/localtime
|
||||
cp "/usr/share/zoneinfo/$TIMEZONE" /etc/localtime
|
||||
fi
|
||||
|
||||
HWCLOCK_PARAMS="--systohc"
|
||||
if [ "$HARDWARECLOCK" = "UTC" ]; then
|
||||
HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc"
|
||||
else
|
||||
HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime"
|
||||
fi
|
||||
hwclock $HWCLOCK_PARAMS
|
||||
show_rval
|
||||
|
||||
# removing psmouse module to fix some reboot issues on newer laptops
|
||||
modprobe -r psmouse >/dev/null 2>&1
|
||||
|
||||
# Write to wtmp file before unmounting
|
||||
halt -w
|
||||
|
||||
echo -n "=> Deactivating swap... "
|
||||
swapoff -a
|
||||
show_rval
|
||||
|
||||
echo -n "=> Unmounting filesystems... "
|
||||
umount -a -r -t noramfs,notmpfs,nosysfs,noproc
|
||||
show_rval
|
||||
|
||||
if [ "$USELVM" = "yes" -o "$USELVM" = "YES" ]; then
|
||||
if [ -x /sbin/lvm -a -d /sys/block ]; then
|
||||
echo -n "=> Deactivating LVM2 groups... "
|
||||
lvm vgchange --ignorelockingfailure -an >/dev/null 2>&1
|
||||
show_rval
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -n "=> Remounting root filesystem read-only... "
|
||||
mount -n -o remount,ro /
|
||||
show_rval
|
||||
|
||||
# Power off or reboot
|
||||
if [ "$RUNLEVEL" = "0" ]; then
|
||||
echo
|
||||
echo "*** POWER OFF ***"
|
||||
echo
|
||||
poweroff -d -f -h -i
|
||||
else
|
||||
echo
|
||||
echo "*** REBOOTING ***"
|
||||
echo
|
||||
# if kexec is installed and a kernel is loaded, use it
|
||||
[ -x /sbin/kexec ] && /sbin/kexec -e > /dev/null 2>&1
|
||||
reboot -d -f -i
|
||||
fi
|
|
@ -0,0 +1,57 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# /etc/rc.single: Single-user startup script.
|
||||
#
|
||||
|
||||
export HOME=/
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
umask 022
|
||||
|
||||
. /etc/rc.subr
|
||||
. /etc/rc.conf
|
||||
_rc_conf_loaded=true
|
||||
|
||||
if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
|
||||
# Determine the shutdown order of the /etc/rc.d scripts,
|
||||
# and perform the operation
|
||||
#
|
||||
files=$(rcorder ${rcshutdown_rcorder_flags} /etc/rc.d/*)
|
||||
|
||||
for _rc_elem in $(reverse_list $files); do
|
||||
run_rc_script $_rc_elem stop
|
||||
done
|
||||
fi
|
||||
|
||||
if [ "$PREVLEVEL" != "N" ]; then
|
||||
echo -n "=> Sending SIGTERM to processes... "
|
||||
killall5 -15 &> /dev/null
|
||||
sleep 5
|
||||
echo "done."
|
||||
|
||||
echo -n "=> Sending SIGKILL to processes... "
|
||||
killall5 -9
|
||||
sleep 1
|
||||
echo "done."
|
||||
|
||||
if [ -x /sbin/udevadm -a -d /sys/block ]; then
|
||||
/etc/rc.d/udevd start
|
||||
/etc/rc.d/udev_events start
|
||||
else
|
||||
# Static /dev, our last resort
|
||||
echo "=> Using static /dev filesystem"
|
||||
fi
|
||||
|
||||
# Start syslogd.
|
||||
if [ -x /etc/rc.d/syslogd -a -x /etc/rc.d/klogd ]; then
|
||||
/etc/rc.d/klogd start
|
||||
/etc/rc.d/syslogd start
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$RUNLEVEL" = "1" ]; then
|
||||
echo
|
||||
echo "*** Entering single-user mode..."
|
||||
# make sure /dev/initctl is in place
|
||||
kill -HUP 1
|
||||
exec /sbin/init -t1 S
|
||||
fi
|
|
@ -0,0 +1,827 @@
|
|||
# $NetBSD: rc.subr,v 1.74 2008/12/06 23:21:32 salo Exp $
|
||||
#
|
||||
# Copyright (c) 1997-2004 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to The NetBSD Foundation
|
||||
# by Luke Mewburn.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
# rc.subr
|
||||
# functions used by various rc scripts
|
||||
#
|
||||
|
||||
: ${rcvar_manpage:='rc.conf(5)'}
|
||||
: ${RC_PID:=$$} ; export RC_PID
|
||||
|
||||
#
|
||||
# functions
|
||||
# ---------
|
||||
|
||||
#
|
||||
# checkyesno var
|
||||
# Test $1 variable, and warn if not set to YES or NO.
|
||||
# Return 0 if it's "yes" (et al), nonzero otherwise.
|
||||
#
|
||||
checkyesno()
|
||||
{
|
||||
eval _value=\$${1}
|
||||
case $_value in
|
||||
|
||||
# "yes", "true", "on", or "1"
|
||||
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
|
||||
return 0
|
||||
;;
|
||||
|
||||
# "no", "false", "off", or "0"
|
||||
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
|
||||
return 1
|
||||
;;
|
||||
*)
|
||||
warn "\$${1} is not set properly - see ${rcvar_manpage}."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# reverse_list list
|
||||
# print the list in reverse order
|
||||
#
|
||||
reverse_list()
|
||||
{
|
||||
_revlist=
|
||||
for _revfile; do
|
||||
_revlist="$_revfile $_revlist"
|
||||
done
|
||||
echo $_revlist
|
||||
}
|
||||
|
||||
#
|
||||
# If booting directly to multiuser, send SIGTERM to
|
||||
# the parent (/etc/rc) to abort the boot.
|
||||
# Otherwise just exit.
|
||||
#
|
||||
stop_boot()
|
||||
{
|
||||
if [ "$autoboot" = yes ]; then
|
||||
echo "ERROR: ABORTING BOOT (sending SIGTERM to parent)!"
|
||||
kill -TERM ${RC_PID}
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# check_pidfile pidfile procname [interpreter]
|
||||
# Parses the first line of pidfile for a PID, and ensures
|
||||
# that the process is running and matches procname.
|
||||
# Prints the matching PID upon success, nothing otherwise.
|
||||
# interpreter is optional; see _find_processes() for details.
|
||||
#
|
||||
check_pidfile()
|
||||
{
|
||||
_pidfile=$1
|
||||
_procname=$2
|
||||
_interpreter=$3
|
||||
if [ -z "$_pidfile" -o -z "$_procname" ]; then
|
||||
err 3 'USAGE: check_pidfile pidfile procname [interpreter]'
|
||||
fi
|
||||
if [ ! -f $_pidfile ]; then
|
||||
return
|
||||
fi
|
||||
read _pid _junk < $_pidfile
|
||||
if [ -z "$_pid" ]; then
|
||||
return
|
||||
fi
|
||||
_find_processes $_procname ${_interpreter:-.} '-p '"$_pid"
|
||||
}
|
||||
|
||||
#
|
||||
# check_process procname [interpreter]
|
||||
# Ensures that a process (or processes) named procname is running.
|
||||
# Prints a list of matching PIDs.
|
||||
# interpreter is optional; see _find_processes() for details.
|
||||
#
|
||||
check_process()
|
||||
{
|
||||
_procname=$1
|
||||
_interpreter=$2
|
||||
if [ -z "$_procname" ]; then
|
||||
err 3 'USAGE: check_process procname [interpreter]'
|
||||
fi
|
||||
_find_processes $_procname ${_interpreter:-.} 'ax'
|
||||
}
|
||||
|
||||
#
|
||||
# _find_processes procname interpreter psargs
|
||||
# Search for procname in the output of ps generated by psargs.
|
||||
# Prints the PIDs of any matching processes, space separated.
|
||||
#
|
||||
# If interpreter == ".", check the following variations of procname
|
||||
# against the first word of each command:
|
||||
# procname
|
||||
# `basename procname`
|
||||
# `basename procname` + ":"
|
||||
# "(" + `basename procname` + ")"
|
||||
#
|
||||
# If interpreter != ".", read the first line of procname, remove the
|
||||
# leading #!, normalise whitespace, append procname, and attempt to
|
||||
# match that against each command, either as is, or with extra words
|
||||
# at the end. As an alternative, to deal with interpreted daemons
|
||||
# using perl, the basename of the interpreter plus a colon is also
|
||||
# tried as the prefix to procname.
|
||||
#
|
||||
_find_processes()
|
||||
{
|
||||
if [ $# -ne 3 ]; then
|
||||
err 3 'USAGE: _find_processes procname interpreter psargs'
|
||||
fi
|
||||
_procname=$1
|
||||
_interpreter=$2
|
||||
_psargs=$3
|
||||
|
||||
_pref=
|
||||
_procnamebn=${_procname##*/}
|
||||
if [ $_interpreter != "." ]; then # an interpreted script
|
||||
read _interp < ${_chroot:-}/$_procname # read interpreter name
|
||||
_interp=${_interp#\#!} # strip #!
|
||||
set -- $_interp
|
||||
if [ $_interpreter != $1 ]; then
|
||||
warn "\$command_interpreter $_interpreter != $1"
|
||||
fi
|
||||
_interp="$* $_procname" # cleanup spaces, add _procname
|
||||
_interpbn=${1##*/}
|
||||
_fp_args='_argv'
|
||||
_fp_match='case "$_argv" in
|
||||
$_procname|$_procnamebn|${_procnamebn}:|"(${_procnamebn})"|"[${_procnamebn}]")'
|
||||
else # a normal daemon
|
||||
_fp_args='_arg0 _argv'
|
||||
_fp_match='case "$_arg0" in
|
||||
$_procname|$_procnamebn|${_procnamebn}:|"(${_procnamebn})")'
|
||||
fi
|
||||
|
||||
_proccheck='
|
||||
ps -o "pid,command" '"$_psargs"' |
|
||||
while read _npid '"$_fp_args"'; do
|
||||
case "$_npid" in
|
||||
PID)
|
||||
continue ;;
|
||||
esac ; '"$_fp_match"'
|
||||
echo -n "$_pref$_npid" ;
|
||||
_pref=" "
|
||||
;;
|
||||
esac
|
||||
done'
|
||||
|
||||
#echo 1>&2 "proccheck is :$_proccheck:"
|
||||
eval $_proccheck
|
||||
}
|
||||
|
||||
#
|
||||
# wait_for_pids pid [pid ...]
|
||||
# spins until none of the pids exist
|
||||
#
|
||||
wait_for_pids()
|
||||
{
|
||||
_list="$@"
|
||||
if [ -z "$_list" ]; then
|
||||
return
|
||||
fi
|
||||
_prefix=
|
||||
while true; do
|
||||
_nlist="";
|
||||
for _j in $_list; do
|
||||
if kill -0 $_j 2>/dev/null; then
|
||||
_nlist="${_nlist}${_nlist:+ }$_j"
|
||||
fi
|
||||
done
|
||||
if [ -z "$_nlist" ]; then
|
||||
break
|
||||
fi
|
||||
_list=$_nlist
|
||||
echo -n ${_prefix:-"Waiting for PIDS: "}$_list
|
||||
_prefix=", "
|
||||
sleep 2
|
||||
done
|
||||
if [ -n "$_prefix" ]; then
|
||||
echo "."
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# run_rc_command argument
|
||||
# Search for argument in the list of supported commands, which is:
|
||||
# "start stop restart rcvar status poll ${extra_commands}"
|
||||
# If there's a match, run ${argument}_cmd or the default method
|
||||
# (see below).
|
||||
#
|
||||
# If argument has a given prefix, then change the operation as follows:
|
||||
# Prefix Operation
|
||||
# ------ ---------
|
||||
# fast Skip the pid check, and set rc_fast=yes
|
||||
# force Set ${rcvar} to YES, and set rc_force=yes
|
||||
# one Set ${rcvar} to YES
|
||||
#
|
||||
# The following globals are used:
|
||||
#
|
||||
# Name Needed Purpose
|
||||
# ---- ------ -------
|
||||
# name y Name of script.
|
||||
#
|
||||
# command n Full path to command.
|
||||
# Not needed if ${rc_arg}_cmd is set for
|
||||
# each keyword.
|
||||
#
|
||||
# command_args n Optional args/shell directives for command.
|
||||
#
|
||||
# command_interpreter n If not empty, command is interpreted, so
|
||||
# call check_{pidfile,process}() appropriately.
|
||||
#
|
||||
# extra_commands n List of extra commands supported.
|
||||
#
|
||||
# pidfile n If set, use check_pidfile $pidfile $command,
|
||||
# otherwise use check_process $command.
|
||||
# In either case, only check if $command is set.
|
||||
#
|
||||
# procname n Process name to check for instead of $command.
|
||||
#
|
||||
# rcvar n This is checked with checkyesno to determine
|
||||
# if the action should be run.
|
||||
#
|
||||
# ${name}_chroot n Directory to chroot to before running ${command}
|
||||
# Requires /usr to be mounted.
|
||||
#
|
||||
# ${name}_chdir n Directory to cd to before running ${command}
|
||||
# (if not using ${name}_chroot).
|
||||
#
|
||||
# ${name}_flags n Arguments to call ${command} with.
|
||||
# NOTE: $flags from the parent environment
|
||||
# can be used to override this.
|
||||
#
|
||||
# ${name}_env n Additional environment variable settings
|
||||
# for running ${command}
|
||||
#
|
||||
# ${name}_nice n Nice level to run ${command} at.
|
||||
#
|
||||
# ${name}_user n User to run ${command} as, using su(1) if not
|
||||
# using ${name}_chroot.
|
||||
# Requires /usr to be mounted.
|
||||
#
|
||||
# ${name}_group n Group to run chrooted ${command} as.
|
||||
# Requires /usr to be mounted.
|
||||
#
|
||||
# ${name}_groups n Comma separated list of supplementary groups
|
||||
# to run the chrooted ${command} with.
|
||||
# Requires /usr to be mounted.
|
||||
#
|
||||
# ${rc_arg}_cmd n If set, use this as the method when invoked;
|
||||
# Otherwise, use default command (see below)
|
||||
#
|
||||
# ${rc_arg}_precmd n If set, run just before performing the
|
||||
# ${rc_arg}_cmd method in the default
|
||||
# operation (i.e, after checking for required
|
||||
# bits and process (non)existence).
|
||||
# If this completes with a non-zero exit code,
|
||||
# don't run ${rc_arg}_cmd.
|
||||
#
|
||||
# ${rc_arg}_postcmd n If set, run just after performing the
|
||||
# ${rc_arg}_cmd method, if that method
|
||||
# returned a zero exit code.
|
||||
#
|
||||
# required_dirs n If set, check for the existence of the given
|
||||
# directories before running the default
|
||||
# (re)start command.
|
||||
#
|
||||
# required_files n If set, check for the readability of the given
|
||||
# files before running the default (re)start
|
||||
# command.
|
||||
#
|
||||
# required_vars n If set, perform checkyesno on each of the
|
||||
# listed variables before running the default
|
||||
# (re)start command.
|
||||
#
|
||||
# Default behaviour for a given argument, if no override method is
|
||||
# provided:
|
||||
#
|
||||
# Argument Default behaviour
|
||||
# -------- -----------------
|
||||
# start if !running && checkyesno ${rcvar}
|
||||
# ${command}
|
||||
#
|
||||
# stop if ${pidfile}
|
||||
# rc_pid=$(check_pidfile $pidfile $command)
|
||||
# else
|
||||
# rc_pid=$(check_process $command)
|
||||
# kill $sig_stop $rc_pid
|
||||
# wait_for_pids $rc_pid
|
||||
# ($sig_stop defaults to TERM.)
|
||||
#
|
||||
# reload Similar to stop, except use $sig_reload instead,
|
||||
# and doesn't wait_for_pids.
|
||||
# $sig_reload defaults to HUP.
|
||||
#
|
||||
# restart Run `stop' then `start'.
|
||||
#
|
||||
# status Show if ${command} is running, etc.
|
||||
#
|
||||
# poll Wait for ${command} to exit.
|
||||
#
|
||||
# rcvar Display what rc.conf variable is used (if any).
|
||||
#
|
||||
# Variables available to methods, and after run_rc_command() has
|
||||
# completed:
|
||||
#
|
||||
# Variable Purpose
|
||||
# -------- -------
|
||||
# rc_arg Argument to command, after fast/force/one processing
|
||||
# performed
|
||||
#
|
||||
# rc_flags Flags to start the default command with.
|
||||
# Defaults to ${name}_flags, unless overridden
|
||||
# by $flags from the environment.
|
||||
# This variable may be changed by the precmd method.
|
||||
#
|
||||
# rc_pid PID of command (if appropriate)
|
||||
#
|
||||
# rc_fast Not empty if "fast" was provided (q.v.)
|
||||
#
|
||||
# rc_force Not empty if "force" was provided (q.v.)
|
||||
#
|
||||
#
|
||||
run_rc_command()
|
||||
{
|
||||
rc_arg=$1
|
||||
if [ -z "$name" ]; then
|
||||
err 3 'run_rc_command: $name is not set.'
|
||||
fi
|
||||
|
||||
_rc_prefix=
|
||||
case "$rc_arg" in
|
||||
fast*) # "fast" prefix; don't check pid
|
||||
rc_arg=${rc_arg#fast}
|
||||
rc_fast=yes
|
||||
;;
|
||||
force*) # "force" prefix; always run
|
||||
rc_force=yes
|
||||
_rc_prefix=force
|
||||
rc_arg=${rc_arg#${_rc_prefix}}
|
||||
if [ -n "${rcvar}" ]; then
|
||||
eval ${rcvar}=YES
|
||||
fi
|
||||
;;
|
||||
one*) # "one" prefix; set ${rcvar}=yes
|
||||
_rc_prefix=one
|
||||
rc_arg=${rc_arg#${_rc_prefix}}
|
||||
if [ -n "${rcvar}" ]; then
|
||||
eval ${rcvar}=YES
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
_keywords="start stop restart rcvar $extra_commands"
|
||||
rc_pid=
|
||||
_pidcmd=
|
||||
_procname=${procname:-${command}}
|
||||
|
||||
# setup pid check command if not fast
|
||||
if [ -z "$rc_fast" -a -n "$_procname" ]; then
|
||||
if [ -n "$pidfile" ]; then
|
||||
_pidcmd='rc_pid=$(check_pidfile '"$pidfile $_procname $command_interpreter"')'
|
||||
else
|
||||
_pidcmd='rc_pid=$(check_process '"$_procname $command_interpreter"')'
|
||||
fi
|
||||
if [ -n "$_pidcmd" ]; then
|
||||
_keywords="${_keywords} status poll"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$rc_arg" ]; then
|
||||
rc_usage "$_keywords"
|
||||
fi
|
||||
|
||||
if [ -n "$flags" ]; then # allow override from environment
|
||||
rc_flags=$flags
|
||||
else
|
||||
eval rc_flags=\$${name}_flags
|
||||
fi
|
||||
eval _chdir=\$${name}_chdir _chroot=\$${name}_chroot \
|
||||
_nice=\$${name}_nice _user=\$${name}_user \
|
||||
_group=\$${name}_group _groups=\$${name}_groups \
|
||||
_env=\"\$${name}_env\"
|
||||
|
||||
if [ -n "$_user" ]; then # unset $_user if running as that user
|
||||
if [ "$_user" = "$(id -un)" ]; then
|
||||
unset _user
|
||||
fi
|
||||
fi
|
||||
|
||||
# if ${rcvar} is set, and $1 is not
|
||||
# "rcvar", then run
|
||||
# checkyesno ${rcvar}
|
||||
# and return if that failed or warn
|
||||
# user and exit when interactive
|
||||
#
|
||||
if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" ]; then
|
||||
if ! checkyesno ${rcvar}; then
|
||||
# check whether interactive or not
|
||||
if [ -n "$_run_rc_script" ]; then
|
||||
return 0
|
||||
fi
|
||||
for _elem in $_keywords; do
|
||||
if [ "$_elem" = "$rc_arg" ]; then
|
||||
echo 1>&2 "\$${rcvar} is not enabled - see ${rcvar_manpage}."
|
||||
echo 1>&2 "Use the following if you wish to perform the operation:"
|
||||
echo 1>&2 " $0 one${rc_arg}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
echo 1>&2 "$0: unknown directive '$rc_arg'."
|
||||
rc_usage "$_keywords"
|
||||
fi
|
||||
fi
|
||||
|
||||
eval $_pidcmd # determine the pid if necessary
|
||||
|
||||
for _elem in $_keywords; do
|
||||
if [ "$_elem" != "$rc_arg" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# if there's a custom ${XXX_cmd},
|
||||
# run that instead of the default
|
||||
#
|
||||
eval _cmd=\$${rc_arg}_cmd _precmd=\$${rc_arg}_precmd \
|
||||
_postcmd=\$${rc_arg}_postcmd
|
||||
if [ -n "$_cmd" ]; then
|
||||
# if the precmd failed and force
|
||||
# isn't set, exit
|
||||
#
|
||||
if ! eval $_precmd && [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if ! eval $_cmd && [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
eval $_postcmd
|
||||
return 0
|
||||
fi
|
||||
|
||||
case "$rc_arg" in # default operations...
|
||||
|
||||
status)
|
||||
if [ -n "$rc_pid" ]; then
|
||||
echo "${name} is running as pid $rc_pid."
|
||||
else
|
||||
echo "${name} is not running."
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
|
||||
start)
|
||||
if [ -n "$rc_pid" ]; then
|
||||
echo 1>&2 "${name} already running? (pid=$rc_pid)."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x ${_chroot}${command} ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
# check for required variables,
|
||||
# directories, and files
|
||||
#
|
||||
for _f in $required_vars; do
|
||||
if ! checkyesno $_f; then
|
||||
warn "\$${_f} is not enabled."
|
||||
if [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
for _f in $required_dirs; do
|
||||
if [ ! -d "${_f}/." ]; then
|
||||
warn "${_f} is not a directory."
|
||||
if [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
for _f in $required_files; do
|
||||
if [ ! -r "${_f}" ]; then
|
||||
warn "${_f} is not readable."
|
||||
if [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# if the precmd failed and force
|
||||
# isn't set, exit
|
||||
#
|
||||
if ! eval $_precmd && [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# setup the command to run, and run it
|
||||
#
|
||||
echo "=> Starting ${name}."
|
||||
if [ -n "$_chroot" ]; then
|
||||
_doit="\
|
||||
${_env:+env $_env }\
|
||||
${_nice:+nice -n $_nice }\
|
||||
chroot ${_user:+-u $_user }${_group:+-g $_group }${_groups:+-G $_groups }\
|
||||
$_chroot $command $rc_flags $command_args"
|
||||
else
|
||||
_doit="\
|
||||
${_chdir:+cd $_chdir; }\
|
||||
${_env:+env $_env }\
|
||||
${_nice:+nice -n $_nice }\
|
||||
$command $rc_flags $command_args"
|
||||
if [ -n "$_user" ]; then
|
||||
_doit="su -m $_user -c 'sh -c \"$_doit\"'"
|
||||
fi
|
||||
fi
|
||||
|
||||
# if the cmd failed and force
|
||||
# isn't set, exit
|
||||
#
|
||||
if ! eval $_doit && [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# finally, run postcmd
|
||||
#
|
||||
eval $_postcmd
|
||||
;;
|
||||
|
||||
stop)
|
||||
if [ -z "$rc_pid" ]; then
|
||||
if [ -n "$pidfile" ]; then
|
||||
echo 1>&2 \
|
||||
"${name} not running? (check $pidfile)."
|
||||
else
|
||||
echo 1>&2 "${name} not running?"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if the precmd failed and force
|
||||
# isn't set, exit
|
||||
#
|
||||
if ! eval $_precmd && [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# send the signal to stop
|
||||
#
|
||||
echo "=> Stopping ${name}."
|
||||
_doit="kill -${sig_stop:-TERM} $rc_pid"
|
||||
if [ -n "$_user" ]; then
|
||||
_doit="su -m $_user -c 'sh -c \"$_doit\"'"
|
||||
fi
|
||||
|
||||
# if the stop cmd failed and force
|
||||
# isn't set, exit
|
||||
#
|
||||
if ! eval $_doit && [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# wait for the command to exit,
|
||||
# and run postcmd.
|
||||
wait_for_pids $rc_pid
|
||||
eval $_postcmd
|
||||
;;
|
||||
|
||||
reload)
|
||||
if [ -z "$rc_pid" ]; then
|
||||
if [ -n "$pidfile" ]; then
|
||||
echo 1>&2 \
|
||||
"${name} not running? (check $pidfile)."
|
||||
else
|
||||
echo 1>&2 "${name} not running?"
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
echo "=> Reloading ${name} config files."
|
||||
if ! eval $_precmd && [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
_doit="kill -${sig_reload:-HUP} $rc_pid"
|
||||
if [ -n "$_user" ]; then
|
||||
_doit="su -m $_user -c 'sh -c \"$_doit\"'"
|
||||
fi
|
||||
if ! eval $_doit && [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
eval $_postcmd
|
||||
;;
|
||||
|
||||
restart)
|
||||
if ! eval $_precmd && [ -z "$rc_force" ]; then
|
||||
return 1
|
||||
fi
|
||||
# prevent restart being called more
|
||||
# than once by any given script
|
||||
#
|
||||
if ${_rc_restart_done:-false}; then
|
||||
return 0
|
||||
fi
|
||||
_rc_restart_done=true
|
||||
|
||||
( $0 ${_rc_prefix}stop )
|
||||
$0 ${_rc_prefix}start
|
||||
|
||||
eval $_postcmd
|
||||
;;
|
||||
|
||||
poll)
|
||||
if [ -n "$rc_pid" ]; then
|
||||
wait_for_pids $rc_pid
|
||||
fi
|
||||
;;
|
||||
|
||||
rcvar)
|
||||
echo "# $name"
|
||||
if [ -n "$rcvar" ]; then
|
||||
if checkyesno ${rcvar}; then
|
||||
echo "\$${rcvar}=YES"
|
||||
else
|
||||
echo "\$${rcvar}=NO"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
rc_usage "$_keywords"
|
||||
;;
|
||||
|
||||
esac
|
||||
return 0
|
||||
done
|
||||
|
||||
echo 1>&2 "$0: unknown directive '$rc_arg'."
|
||||
rc_usage "$_keywords"
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# run_rc_script file arg
|
||||
# Start the script `file' with `arg', and correctly handle the
|
||||
# return value from the script. If `file' ends with `.sh', it's
|
||||
# sourced into the current environment. If `file' appears to be
|
||||
# a backup or scratch file, ignore it. Otherwise if it's
|
||||
# executable run as a child process.
|
||||
#
|
||||
run_rc_script()
|
||||
{
|
||||
_file=$1
|
||||
_arg=$2
|
||||
if [ -z "$_file" -o -z "$_arg" ]; then
|
||||
err 3 'USAGE: run_rc_script file arg'
|
||||
fi
|
||||
|
||||
_run_rc_script=true
|
||||
|
||||
unset name command command_args command_interpreter \
|
||||
extra_commands pidfile procname \
|
||||
rcvar required_dirs required_files required_vars
|
||||
eval unset ${_arg}_cmd ${_arg}_precmd ${_arg}_postcmd
|
||||
|
||||
case "$_file" in
|
||||
*.sh) # run in current shell
|
||||
set $_arg ; . $_file
|
||||
;;
|
||||
*[~#]|*.OLD|*.orig|*,v) # scratch file; skip
|
||||
warn "Ignoring scratch file $_file"
|
||||
;;
|
||||
*) # run in subshell
|
||||
if [ -x $_file ]; then
|
||||
if [ -n "$rc_fast_and_loose" ]; then
|
||||
set $_arg ; . $_file
|
||||
else
|
||||
( set $_arg ; . $_file )
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#
|
||||
# load_rc_config command
|
||||
# Source in the configuration file for a given command.
|
||||
#
|
||||
load_rc_config()
|
||||
{
|
||||
_command=$1
|
||||
if [ -z "$_command" ]; then
|
||||
err 3 'USAGE: load_rc_config command'
|
||||
fi
|
||||
|
||||
if ${_rc_conf_loaded:-false}; then
|
||||
:
|
||||
else
|
||||
. /etc/rc.conf
|
||||
_rc_conf_loaded=true
|
||||
fi
|
||||
if [ -f /etc/rc.conf.d/"$_command" ]; then
|
||||
. /etc/rc.conf.d/"$_command"
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# load_rc_config_var cmd var
|
||||
# Read the rc.conf(5) var for cmd and set in the
|
||||
# current shell, using load_rc_config in a subshell to prevent
|
||||
# unwanted side effects from other variable assignments.
|
||||
#
|
||||
load_rc_config_var()
|
||||
{
|
||||
if [ $# -ne 2 ]; then
|
||||
err 3 'USAGE: load_rc_config_var cmd var'
|
||||
fi
|
||||
eval $(eval '(
|
||||
load_rc_config '$1' >/dev/null;
|
||||
if [ -n "${'$2'}" -o "${'$2'-UNSET}" != "UNSET" ]; then
|
||||
echo '$2'=\'\''${'$2'}\'\'';
|
||||
fi
|
||||
)' )
|
||||
}
|
||||
|
||||
#
|
||||
# rc_usage commands
|
||||
# Print a usage string for $0, with `commands' being a list of
|
||||
# valid commands.
|
||||
#
|
||||
rc_usage()
|
||||
{
|
||||
echo -n 1>&2 "Usage: $0 [fast|force|one]("
|
||||
|
||||
_sep=
|
||||
for _elem; do
|
||||
echo -n 1>&2 "$_sep$_elem"
|
||||
_sep="|"
|
||||
done
|
||||
echo 1>&2 ")"
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# err exitval message
|
||||
# Display message to stderr and log to the syslog, and exit with exitval.
|
||||
#
|
||||
err()
|
||||
{
|
||||
exitval=$1
|
||||
shift
|
||||
|
||||
if [ -x /bin/logger ]; then
|
||||
logger "$0: ERROR: $*"
|
||||
fi
|
||||
echo 1>&2 "$0: ERROR: $*"
|
||||
exit $exitval
|
||||
}
|
||||
|
||||
#
|
||||
# warn message
|
||||
# Display message to stderr and log to the syslog.
|
||||
#
|
||||
warn()
|
||||
{
|
||||
if [ -x /bin/logger ]; then
|
||||
logger "$0: WARNING: $*"
|
||||
fi
|
||||
echo 1>&2 "$0: WARNING: $*"
|
||||
}
|
||||
|
||||
show_rval()
|
||||
{
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "done."
|
||||
else
|
||||
echo "failed!"
|
||||
fi
|
||||
}
|
||||
|
||||
_rc_subr_loaded=:
|
|
@ -0,0 +1,52 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# /etc/rc.sysinit
|
||||
#
|
||||
|
||||
export HOME=/
|
||||
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
. /etc/rc.subr
|
||||
. /etc/rc.conf
|
||||
|
||||
echo
|
||||
echo "Welcome to the lsXL Linux system."
|
||||
echo
|
||||
|
||||
# Create our default nodes that minilogd may need
|
||||
[ ! -e /dev/null ] && mknod /dev/null c 1 3
|
||||
[ ! -e /dev/zero ] && mknod /dev/zero c 1 5
|
||||
[ ! -e /dev/console ] && mknod /dev/console c 5 1
|
||||
|
||||
# start up our mini logger until syslog takes over
|
||||
minilogd
|
||||
|
||||
# anything more serious than KERN_WARNING goes to the console
|
||||
# 'verbose' cmdline parameter enables more messages
|
||||
if grep -q " verbose" /proc/cmdline; then
|
||||
dmesg -n 8
|
||||
else
|
||||
dmesg -n 3
|
||||
fi
|
||||
|
||||
# enable rtc access
|
||||
modprobe rtc-cmos >/dev/null 2>&1
|
||||
RTC_MAJOR=$(grep -w rtc /proc/devices 2>/dev/null); RTC_MAJOR="${RTC_MAJOR%% *}"
|
||||
if [ -n "$RTC_MAJOR" ]; then
|
||||
mkdir /dev/misc/
|
||||
mknod /dev/misc/rtc0 c $RTC_MAJOR 0
|
||||
ln -s /dev/misc/rtc0 /dev/rtc
|
||||
fi
|
||||
|
||||
HWCLOCK_PARAMS="--hctosys"
|
||||
if [ "$HARDWARECLOCK" = "UTC" ]; then
|
||||
HWCLOCK_PARAMS="$HWCLOCK_PARAMS --utc"
|
||||
else
|
||||
HWCLOCK_PARAMS="$HWCLOCK_PARAMS --localtime"
|
||||
fi
|
||||
|
||||
# Set clock early to fix some bugs with filesystem checks
|
||||
# Clock is set again later to match rc.conf
|
||||
if [ -f /etc/localtime ]; then
|
||||
hwclock $HWCLOCK_PARAMS --noadjfile
|
||||
fi
|
|
@ -0,0 +1,45 @@
|
|||
# Template file for 'initscripts'
|
||||
pkgname=initscripts
|
||||
version=2009.01
|
||||
build_style=custom-install
|
||||
short_desc="xbps base system init scripts"
|
||||
maintainer="Juan RP <xtraeme@gmail.com>"
|
||||
long_desc="
|
||||
This package installs the xbps base init scripts, used for booting
|
||||
the system and starting/stopping services.
|
||||
|
||||
The scripts use the BSD style and contain portions from Arch Linux and
|
||||
from NetBSD."
|
||||
|
||||
noarch=yes
|
||||
conf_files="/etc/inittab /etc/rc.conf /etc/rc.local /etc/rc.local.shutdown"
|
||||
keep_dirs="/etc/rc.d /etc/rc.conf.d"
|
||||
|
||||
Add_dependency full glibc
|
||||
Add_dependency full bash
|
||||
Add_dependency full gawk
|
||||
Add_dependency full grep
|
||||
Add_dependency full coreutils
|
||||
Add_dependency full sed
|
||||
Add_dependency full udev
|
||||
Add_dependency full kbd
|
||||
Add_dependency full findutils
|
||||
Add_dependency full net-tools
|
||||
Add_dependency full rcorder
|
||||
Add_dependency full minilogd
|
||||
|
||||
do_install()
|
||||
{
|
||||
local destdir=$XBPS_DESTDIR/$pkgname-$version
|
||||
local filesdir=$XBPS_TEMPLATESDIR/$pkgname/files
|
||||
|
||||
install -d ${destdir}/etc/rc.d
|
||||
install -d ${destdir}/etc/rc.conf.d
|
||||
install -d ${destdir}/etc/defaults
|
||||
|
||||
for f in inittab rc.*; do
|
||||
install -m755 ${filesdir}/${f} ${destdir}/etc
|
||||
done
|
||||
install -m644 ${filesdir}/defaults/rc.conf ${destdir}/etc/defaults
|
||||
install -m755 ${filesdir}/rc.d/* ${destdir}/etc/rc.d
|
||||
}
|
Loading…
Reference in New Issue