2008-02-28 01:59:32 +05:30
|
|
|
#!@SHELL@
|
2009-05-01 19:41:40 +05:30
|
|
|
# Copyright (c) 1999-2007 Gentoo Foundation
|
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2011-06-30 05:16:31 +05:30
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-14 20:52:04 +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
|
|
|
|
[ -e "$_f" ] && . "$_f"
|
|
|
|
done
|
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
|
|
|
|
# By default VServer already has /proc mounted, but OpenVZ does not!
|
2007-05-23 19:42:06 +05:30
|
|
|
# However, some of our users have an old proc image in /proc
|
|
|
|
# NFC how they managed that, but the end result means we have to test if
|
2011-03-25 04:57:35 +05:30
|
|
|
# /proc actually works or not. We do this by comparing two reads of
|
|
|
|
# /proc/self/environ for which we have set the variable VAR to two
|
|
|
|
# different values. If the comparison comes back equal, we know that
|
|
|
|
# /proc is not working.
|
2007-05-23 19:42:06 +05:30
|
|
|
mountproc=true
|
2011-03-25 04:57:35 +05:30
|
|
|
f=/proc/self/environ
|
2011-01-18 06:56:34 +05:30
|
|
|
if [ -e $f ]; then
|
2016-09-23 03:52:03 +05:30
|
|
|
if [ "$(VAR=a md5sum $f)" = "$(VAR=b md5sum $f)" ]; then
|
2007-05-23 19:42:06 +05:30
|
|
|
eerror "You have cruft in /proc that should be deleted"
|
|
|
|
else
|
2012-05-03 01:18:52 +05:30
|
|
|
einfo "/proc is already mounted"
|
2007-05-23 19:42:06 +05:30
|
|
|
mountproc=false
|
|
|
|
fi
|
|
|
|
fi
|
2011-03-25 04:57:35 +05:30
|
|
|
unset f
|
2007-05-23 19:42:06 +05:30
|
|
|
|
2009-04-27 02:43:26 +05:30
|
|
|
if $mountproc; then
|
2007-04-05 16:48:42 +05:30
|
|
|
procfs="proc"
|
2009-04-27 02:43:26 +05:30
|
|
|
[ "$RC_UNAME" = "GNU/kFreeBSD" ] && proc="linprocfs"
|
2008-03-11 19:25:39 +05:30
|
|
|
ebegin "Mounting /proc"
|
2008-03-11 19:09:20 +05:30
|
|
|
if ! fstabinfo --mount /proc; then
|
2009-04-27 02:43:26 +05:30
|
|
|
mount -n -t "$procfs" -o noexec,nosuid,nodev proc /proc
|
2007-09-26 15:39:27 +05:30
|
|
|
fi
|
2007-04-05 16:48:42 +05:30
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
|
2011-09-12 21:16:51 +05:30
|
|
|
# /run is a new directory for storing volatile runtime data.
|
|
|
|
# Read more about /run at https://lwn.net/Articles/436012
|
2013-12-12 05:09:38 +05:30
|
|
|
sys="$(openrc --sys)"
|
2012-07-02 23:52:04 +05:30
|
|
|
|
2012-02-23 08:14:32 +05:30
|
|
|
if [ ! -d /run ]; then
|
2012-07-02 23:52:04 +05:30
|
|
|
if [ "$sys" = VSERVER ]; then
|
|
|
|
if [ -e /run ]; then
|
|
|
|
rm -rf /run
|
|
|
|
fi
|
|
|
|
mkdir /run
|
|
|
|
else
|
|
|
|
eerror "The /run directory does not exist. Unable to continue."
|
|
|
|
return 1
|
|
|
|
fi
|
2012-02-23 08:14:32 +05:30
|
|
|
fi
|
|
|
|
|
2012-07-02 23:52:04 +05:30
|
|
|
if [ "$sys" = VSERVER ]; then
|
|
|
|
rm -rf /run/*
|
|
|
|
elif ! mountinfo -q /run; then
|
2012-02-23 08:14:32 +05:30
|
|
|
ebegin "Mounting /run"
|
|
|
|
rc=0
|
|
|
|
if ! fstabinfo --mount /run; then
|
2014-01-18 14:04:39 +05:30
|
|
|
mount -t tmpfs -o mode=0755,nodev,size=10% tmpfs /run
|
2012-02-23 08:14:32 +05:30
|
|
|
rc=$?
|
|
|
|
fi
|
|
|
|
if [ $rc != 0 ]; then
|
|
|
|
eerror "Unable to mount tmpfs on /run."
|
|
|
|
eerror "Can't continue."
|
|
|
|
exit 1
|
2011-09-12 21:16:51 +05:30
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-02-23 08:14:32 +05:30
|
|
|
checkpath -d $RC_SVCDIR
|
|
|
|
checkpath -d -m 0775 -o root:uucp /run/lock
|
|
|
|
|
2010-02-26 15:04:43 +05:30
|
|
|
# Try to mount xenfs as early as possible, otherwise rc_sys() will always
|
|
|
|
# return RC_SYS_XENU and will think that we are in a domU while it's not.
|
|
|
|
if grep -Eq "[[:space:]]+xenfs$" /proc/filesystems; then
|
|
|
|
ebegin "Mounting xenfs"
|
|
|
|
if ! fstabinfo --mount /proc/xen; then
|
|
|
|
mount -n -t xenfs xenfs /proc/xen -o nosuid,nodev,noexec
|
|
|
|
fi
|
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
|
2016-09-12 21:50:26 +05:30
|
|
|
if [ -e "$RC_LIBEXECDIR"/cache/softlevel ]; then
|
2012-02-23 08:14:32 +05:30
|
|
|
cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo sysinit >"$RC_SVCDIR"/softlevel
|
|
|
|
exit 0
|