2008-02-28 04:29:32 +08:00
|
|
|
#!@SHELL@
|
2015-12-05 06:52:19 +08:00
|
|
|
# Copyright (c) 2007-2015 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.
|
2007-11-14 23:22:04 +08:00
|
|
|
|
2007-04-05 19:18:42 +08:00
|
|
|
# This basically mounts $svcdir as a ramdisk, but preserving its content
|
|
|
|
# which allows us to run depscan.sh
|
|
|
|
# FreeBSD has a nice ramdisk - we don't set a size as we should always
|
|
|
|
# be fairly small and we unmount them after the boot level is done anyway
|
|
|
|
# NOTE we don't set a size for Linux either
|
2007-11-28 18:06:13 +08:00
|
|
|
# FreeBSD-7 supports tmpfs now :)
|
2008-01-11 20:13:46 +08:00
|
|
|
mount_svcdir()
|
|
|
|
{
|
2009-04-27 05:13:26 +08:00
|
|
|
if ! fstabinfo --mount "$RC_SVCDIR"; then
|
|
|
|
if ! mount -t tmpfs -o rw,noexec,nosuid none \
|
|
|
|
"$RC_SVCDIR" 2>/dev/null
|
|
|
|
then
|
2008-03-11 21:39:20 +08:00
|
|
|
mdconfig -a -t malloc -s "${rc_svcsize:-1024}"k -u 0
|
|
|
|
newfs -b 4096 -i 1024 -n /dev/md0
|
2009-04-27 05:13:26 +08:00
|
|
|
mount -o rw,noexec,nosuid /dev/md0 "$RC_SVCDIR"
|
2008-03-11 21:39:20 +08:00
|
|
|
fi
|
2007-11-28 18:06:13 +08:00
|
|
|
fi
|
2007-04-05 19:18:42 +08:00
|
|
|
}
|
|
|
|
|
2009-05-24 03:38:12 +08:00
|
|
|
. "$RC_LIBEXECDIR"/sh/functions.sh
|
2013-02-12 11:13:28 +08:00
|
|
|
[ -r "@SYSCONFDIR@/rc.conf" ] && . "@SYSCONFDIR@/rc.conf"
|
2015-12-10 02:38:10 +08:00
|
|
|
if [ -d "@SYSCONFDIR@/rc.conf.d" ]; then
|
|
|
|
for _f in "@SYSCONFDIR@"/rc.conf.d/*.conf; do
|
|
|
|
[ -r "$_f" ] && . "$_f"
|
|
|
|
done
|
|
|
|
fi
|
2007-04-05 19:18:42 +08:00
|
|
|
|
|
|
|
# Disable devd until we need it
|
2009-04-27 05:13:26 +08:00
|
|
|
if [ -z "$RC_SYS" -a "$RC_UNAME" = "FreeBSD" ]; then
|
2008-03-03 23:57:09 +08:00
|
|
|
sysctl hw.bus.devctl_disable=1 >/dev/null
|
|
|
|
fi
|
2007-04-05 19:18:42 +08:00
|
|
|
|
2014-01-12 03:32:43 +08:00
|
|
|
# mount $RC_SVCDIR as something we can write to if it's not rw
|
|
|
|
# On vservers, / is always rw at this point, so we need to clean out
|
|
|
|
# the old service state data
|
|
|
|
: ${RC_LIBEXECDIR:=@LIBEXECDIR@}
|
|
|
|
: ${RC_SVCDIR:=@LIBEXECDIR@/init.d}
|
|
|
|
case "$(openrc --sys)" in
|
|
|
|
OPENVZ|VSERVER) rm -rf "$RC_SVCDIR"/*;;
|
|
|
|
*) if mountinfo --quiet "$RC_SVCDIR"; then
|
|
|
|
rm -rf "$RC_SVCDIR"/*
|
|
|
|
else
|
|
|
|
mount_svcdir
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
retval=$?
|
|
|
|
|
2016-09-13 00:20:26 +08:00
|
|
|
if [ -e "$RC_LIBEXECDIR"/cache/softlevel ]; then
|
2014-01-12 03:32:43 +08:00
|
|
|
cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo sysinit >"$RC_SVCDIR"/softlevel
|
|
|
|
exit $retval
|