2018-12-08 01:11:06 +05:30
|
|
|
#!/bin/sh
|
2015-12-05 04:22:19 +05:30
|
|
|
# Copyright (c) 2007-2015 The OpenRC Authors.
|
|
|
|
# See the Authors file at the top-level directory of this distribution and
|
2021-12-21 06:37:00 +05:30
|
|
|
# https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
|
2015-12-05 04:22:19 +05:30
|
|
|
#
|
|
|
|
# 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
|
2021-12-21 06:37:00 +05:30
|
|
|
# distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
|
2015-12-05 04:22:19 +05:30
|
|
|
# This file may not be copied, modified, propagated, or distributed
|
|
|
|
# except according to the terms contained in the LICENSE file.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2007-04-05 16:48:42 +05:30
|
|
|
# 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 15:36:13 +05:30
|
|
|
# FreeBSD-7 supports tmpfs now :)
|
2008-01-11 17:43:46 +05:30
|
|
|
mount_svcdir()
|
|
|
|
{
|
2009-04-27 02:43:26 +05:30
|
|
|
if ! fstabinfo --mount "$RC_SVCDIR"; then
|
|
|
|
if ! mount -t tmpfs -o rw,noexec,nosuid none \
|
|
|
|
"$RC_SVCDIR" 2>/dev/null
|
|
|
|
then
|
2008-03-11 19:09:20 +05:30
|
|
|
mdconfig -a -t malloc -s "${rc_svcsize:-1024}"k -u 0
|
|
|
|
newfs -b 4096 -i 1024 -n /dev/md0
|
2009-04-27 02:43:26 +05:30
|
|
|
mount -o rw,noexec,nosuid /dev/md0 "$RC_SVCDIR"
|
2008-03-11 19:09:20 +05:30
|
|
|
fi
|
2007-11-28 15:36:13 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
}
|
|
|
|
|
2009-05-24 01:08:12 +05:30
|
|
|
. "$RC_LIBEXECDIR"/sh/functions.sh
|
2013-02-12 08:43:28 +05:30
|
|
|
[ -r "@SYSCONFDIR@/rc.conf" ] && . "@SYSCONFDIR@/rc.conf"
|
2015-12-10 00:08:10 +05:30
|
|
|
if [ -d "@SYSCONFDIR@/rc.conf.d" ]; then
|
|
|
|
for _f in "@SYSCONFDIR@"/rc.conf.d/*.conf; do
|
|
|
|
[ -r "$_f" ] && . "$_f"
|
|
|
|
done
|
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
# Disable devd until we need it
|
2009-04-27 02:43:26 +05:30
|
|
|
if [ -z "$RC_SYS" -a "$RC_UNAME" = "FreeBSD" ]; then
|
2008-03-03 21:27:09 +05:30
|
|
|
sysctl hw.bus.devctl_disable=1 >/dev/null
|
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2014-01-12 01:02:43 +05:30
|
|
|
# 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-12 21:50:26 +05:30
|
|
|
if [ -e "$RC_LIBEXECDIR"/cache/softlevel ]; then
|
2014-01-12 01:02:43 +05:30
|
|
|
cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo sysinit >"$RC_SVCDIR"/softlevel
|
|
|
|
exit $retval
|