# The interfaces setting controls which interfaces the net-online
-# service considers in deciding whether the network is active. By
-# default, it is all ethernet or wireless LAN interfaces.
+# service considers in deciding whether the network is active. The
+# default is all interfaces that support ethernet.
#interfaces=""
# This setting controls whether a ping to the default gateway is
--- /dev/null
+# If you are only using local swap partitions, you should not change
+# this file. Otherwise, you need to uncomment the below rc_before line
+# followed by the appropriate rc_need line.
+#rc_before="!localmount"
+#
+# If you are using swap files stored on local file systems, uncomment
+# this line.
+#rc_need="localmount"
+#
+# If you are using swap files stored on network file systems or swap
+# partitions stored on network block devices such as iSCSI, uncomment
+# this line.
+#rc_need="netmount"
start()
{
- # HOSTNAME variable used to be defined in caps in conf.d/hostname.
- # It is also a magic variable in bash.
- hostname=${hostname-${HOSTNAME-localhost}} # checkbashisms: false positive
- ebegin "Setting hostname to $hostname"
- hostname "$hostname"
+ local h source x
+ if [ -s /etc/hostname ] && [ -r /etc/hostname ]; then
+ read h x </etc/hostname
+ source=" from /etc/hostname"
+ else
+ # HOSTNAME variable used to be defined in caps in conf.d/hostname.
+ # It is also a magic variable in bash.
+ h=${hostname-${HOSTNAME}} # checkbashisms: false positive
+ fi
+ if [ -z "$h" ]; then
+ einfo "Using default system hostname"
+ return 0
+ fi
+ ebegin "Setting hostname to $h $source"
+ hostname "$h"
eend $? "Failed to set the hostname"
}
depend()
{
provide clock
+ want modules
if yesno $clock_adjfile; then
use root
else
fi
}
+rtc_exists()
+{
+ local rtc=
+ for rtc in /dev/rtc /dev/rtc[0-9]*; do
+ [ -e "$rtc" ] && break
+ done
+ [ -e "$rtc" ]
+}
+
start()
{
- local retval=0 errstr=""
+ local retval=0 errstr="" modname
setupopts
if [ -z "$utc_cmd" ]; then
ebegin "Setting system clock using the hardware clock [$utc]"
if [ -e /proc/modules ]; then
- local rtc=
- for rtc in /dev/rtc /dev/rtc[0-9]*; do
- [ -e "$rtc" ] && break
- done
- if [ ! -e "${rtc}" ]; then
- modprobe -q rtc-cmos || modprobe -q rtc || modprobe -q genrtc
+ if ! rtc_exists; then
+ for x in rtc-cmos rtc genrtc; do
+ modprobe -q $x && rtc_exists && modname="$x" && break
+ done
+ [ -n "$modname" ] &&
+ ewarn "The $modname module needs to be configured in" \
+ "/etc/conf.d/modules or built in."
fi
fi
aufs_branch=$(sed 's/=.*//g' $x)
eindent
if ! mount -o "remount,del:$aufs_branch" "$aufs_mount_point" > /dev/null 2>&1; then
- ewarn "Failed to remove branch $aufs_branch from aufs \
- $aufs_mount_point"
+ ewarn "Failed to remove branch $aufs_branch from aufs" \
+ "$aufs_mount_point"
fi
eoutdent
sync
if [ "$RC_UNAME" = Linux ]; then
ebegin "Bringing up network interface lo"
if command -v ip > /dev/null 2>&1; then
- ip addr add 127.0.0.1/8 dev lo brd + scope host
- ip route add 127.0.0.0/8 dev lo scope host
+ ip addr add 127.0.0.1/8 dev lo brd +
ip link set lo up
else
ifconfig lo 127.0.0.1 netmask 255.0.0.0
- route add -net 127.0.0.0 netmask 255.0.0.0 gw 127.0.0.1
fi
else
ebegin "Bringing up network interface lo0"
fi
eend $?
}
-
-stop()
-{
- return 0
-}
keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
}
-start()
+FreeBSD_modules()
+{
+ local cnt=0 x
+ for x in $modules; do
+ ebegin "Loading module $x"
+ kldload "$x"
+ eend $? "Failed to load $x" && : $(( cnt += 1 ))
+ done
+ einfo "Autoloaded $cnt module(s)"
+}
+
+Linux_modules()
{
# Should not fail if kernel do not have module
# support compiled in ...
done
[ -z "$args" ] && eval args=\$module_${aa}_args
[ -z "$args" ] && eval args=\$module_${xx}_args
- eval modprobe -q "$mpargs" "$x" "$args"
+ eval modprobe --use-blacklist -q "$mpargs" "$x" "$args"
eend $? "Failed to load $x" && : $(( cnt += 1 ))
done
einfo "Autoloaded $cnt module(s)"
}
+
+start()
+{
+ case "$RC_UNAME" in
+ FreeBSD|Linux) ${RC_UNAME}_modules ;;
+ *) ;;
+ esac
+ return 0
+}
ebegin "Loading module $x"
case "$RC_UNAME" in
FreeBSD) kldload "$x"; rc=$? ;;
- Linux) modprobe -q "$x"; rc=$? ;;
+ Linux) modprobe --use-blacklist -q "$x"; rc=$? ;;
*) ;;
esac
eend $rc "Failed to load $x"
local m="/dev|/dev/.*|/proc|/proc.*|/sys|/sys/.*|/run|${rc_svcdir}" x= fs=
m="$m|/bin|/sbin|/lib(32|64)?|/libexec"
+ if [ -e "$rc_svcdir"/usr_premounted ]; then
+ m="$m|/usr"
+ fi
# RC_NO_UMOUNTS is an env var that can be set by plugins
local IFS="$IFS:"
for x in $no_umounts $RC_NO_UMOUNTS; do
start ()
{
- local carriers configured dev gateway ifcount infinite interfaces
- local rc state timeout x
+ local carriers configured dev gateway ifcount infinite
+ local rc state x
ebegin "Checking to see if the network is online"
rc=0
depend()
{
- use modules devfs
+ use devfs
+ want modules
need localmount
keyword -docker -lxc -openvz -prefix -systemd-nspawn -vserver
}
start()
{
# Setup Kernel Support for miscellaneous Binary Formats
- if [ -d /proc/sys/fs/binfmt_misc -a ! -e /proc/sys/fs/binfmt_misc/register ]; then
- modprobe -q binfmt-misc
+ if [ -d /proc/sys/fs/binfmt_misc ] &&
+ [ ! -e /proc/sys/fs/binfmt_misc/register ]; then
+ if ! grep -qs binfmt_misc /proc/filesystems &&
+ modprobe -q binfmt-misc; then
+ ewarn "The binfmt-misc module needs to be configured in" \
+ "/etc/conf.d/modules or built in."
+ fi
if grep -qs binfmt_misc /proc/filesystems; then
ebegin "Mounting misc binary format filesystem"
mount -t binfmt_misc -o nodev,noexec,nosuid \
--- /dev/null
+#!/sbin/openrc-run
+# Copyright (c) 2016 The OpenRC Authors.
+# See the Authors file at the top-level directory of this distribution and
+# https://github.com/OpenRC/openrc/blob/master/AUTHORS
+#
+# This file is part of OpenRC. It is subject to the license terms in
+# the LICENSE file found in the top-level directory of this
+# distribution and at https://github.com/OpenRC/openrc/blob/master/LICENSE
+# This file may not be copied, modified, propagated, or distributed
+# except according to the terms contained in the LICENSE file.
+
+command=/usr/bin/runsvdir
+command_background=yes
+pidfile=/var/run/runsvdir.pid
+command_args="-P $RC_SVCDIR/sv 'log: ...........................................................................................................................................................................................................................................................................................................................................................................................................'"
+
+start_pre()
+{
+ checkpath -m 0755 -o root:root -d ${RC_SVCDIR}/sv
+}
fi
ebegin "Saving dependency cache"
local rc=0 save=
- for x in deptree depconfig shutdowntime softlevel rc.log; do
+ for x in shutdowntime softlevel rc.log; do
[ -e "$RC_SVCDIR/$x" ] && save="$save $RC_SVCDIR/$x"
done
if [ -n "$save" ]; then
{
ebegin "Activating swap devices"
case "$RC_UNAME" in
- Linux) swapon -a -e >/dev/null;;
NetBSD|OpenBSD) swapctl -A -t noblk >/dev/null;;
*) swapon -a >/dev/null;;
esac
stop()
{
ebegin "Deactivating swap devices"
-
- # Try to unmount all tmpfs filesystems not in use, else a deadlock may
- # occur. As $RC_SVCDIR may also be tmpfs we cd to it to lock it
- cd "$RC_SVCDIR"
- umount -a -t tmpfs 2>/dev/null
-
case "$RC_UNAME" in
NetBSD|OpenBSD) swapctl -U -t noblk >/dev/null;;
*) swapoff -a >/dev/null;;
keyword -prefix -systemd-nspawn -vserver
}
-start()
+BSD_sysctl()
+{
+ [ -e /etc/sysctl.conf ] || return 0
+ local retval=0 var= comments= conf=
+ eindent
+ for conf in /etc/sysctl.conf /etc/sysctl.d/*.conf; do
+ if [ -r "$conf" ]; then
+ vebegin "applying $conf"
+ while read var comments; do
+ case "$var" in
+ ""|"#"*) continue;;
+ esac
+ sysctl -w "$var" >/dev/null || retval=1
+ done < "$conf"
+ veend $retval
+ fi
+ done
+ eoutdent
+ return $retval
+}
+
+Linux_sysctl()
{
local quiet
yesno $rc_verbose || quiet=-q
- ebegin "Configuring kernel parameters"
sysctl ${quiet} --system
- eend $? "Unable to configure some kernel parameters"
+}
+
+start()
+{
+ local rc=0
+
+ ebegin "Configuring kernel parameters"
+ case "$RC_UNAME" in
+ *BSD|GNU) BSD_sysctl; rc=$? ;;
+ Linux) Linux_sysctl; rc=$? ;;
+ esac
+ eend $rc "Unable to configure some kernel parameters"
}
depend()
{
+ want modules
keyword -docker -lxc -prefix -systemd-nspawn -vserver
}
fi
fi
- # setup up kernel support for efivarfs
- # slightly complicated, as if it's build as a module but NOT yet loaded,
- # it will NOT appear in /proc/filesystems yet
- if [ -d /sys/firmware/efi/efivars ] \
- && ! mountinfo -q /sys/firmware/efi/efivars; then
- modprobe -q efivarfs
- if grep -qs efivarfs /proc/filesystems; then
- ebegin "Mounting efivarfs filesystem"
- mount -n -t efivarfs -o ${sysfs_opts} \
- efivarfs /sys/firmware/efi/efivars
- eend $?
+ # set up kernel support for efivarfs
+ # The presence of /sys/firmware/efi indicates that the system was
+ # booted in efi mode.
+ if [ -d /sys/firmware/efi ]; then
+ if [ ! -d /sys/firmware/efi/efivars ] &&
+ modprobe -q efivarfs; then
+ ewarn "The efivarfs module needs to be configured in " \
+ "/etc/conf.d/modules or built in"
+ fi
+ if [ -d /sys/firmware/efi/efivars ] &&
+ ! mountinfo -q /sys/firmware/efi/efivars; then
+ if grep -qs efivarfs /proc/filesystems; then
+ ebegin "Mounting efivarfs filesystem"
+ mount -n -t efivarfs -o ${sysfs_opts} \
+ efivarfs /sys/firmware/efi/efivars
+ eend $?
+ fi
fi
fi
}
All files are processed in lexical order.
-Keep in mind that files in this directory are processed sequencially,
+Keep in mind that files in this directory are processed sequentially,
and the local service is not considered started or stopped until
everything is processed, so if you have a process which takes a long
time to run, it can delay your boot or shutdown processing.