2008-02-27 20:29:32 +00:00
|
|
|
#!@SHELL@
|
2009-05-01 15:11:40 +01:00
|
|
|
# Copyright (c) 1999-2007 Gentoo Foundation
|
|
|
|
# Copyright (c) 2007-2009 Roy Marples <roy@marples.name>
|
2011-06-29 19:46:31 -04:00
|
|
|
# Released under the 2-clause BSD license.
|
2007-11-14 15:22:04 +00:00
|
|
|
|
2009-05-23 20:38:12 +01:00
|
|
|
. "$RC_LIBEXECDIR"/sh/functions.sh
|
2013-02-11 22:13:28 -05:00
|
|
|
[ -r "@SYSCONFDIR@/rc.conf" ] && . "@SYSCONFDIR@/rc.conf"
|
2007-04-05 11:18:42 +00:00
|
|
|
|
|
|
|
# By default VServer already has /proc mounted, but OpenVZ does not!
|
2007-05-23 14:12:06 +00:00
|
|
|
# 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-24 18:27:35 -05:00
|
|
|
# /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 14:12:06 +00:00
|
|
|
mountproc=true
|
2011-03-24 18:27:35 -05:00
|
|
|
f=/proc/self/environ
|
2011-01-18 01:26:34 +00:00
|
|
|
if [ -e $f ]; then
|
2011-03-24 18:27:35 -05:00
|
|
|
if [ "$(VAR=a cat $f)" = "$(VAR=b cat $f)" ]; then
|
2007-05-23 14:12:06 +00:00
|
|
|
eerror "You have cruft in /proc that should be deleted"
|
|
|
|
else
|
2012-05-02 14:48:52 -05:00
|
|
|
einfo "/proc is already mounted"
|
2007-05-23 14:12:06 +00:00
|
|
|
mountproc=false
|
|
|
|
fi
|
|
|
|
fi
|
2011-03-24 18:27:35 -05:00
|
|
|
unset f
|
2007-05-23 14:12:06 +00:00
|
|
|
|
2009-04-26 21:13:26 +00:00
|
|
|
if $mountproc; then
|
2007-04-05 11:18:42 +00:00
|
|
|
procfs="proc"
|
2009-04-26 21:13:26 +00:00
|
|
|
[ "$RC_UNAME" = "GNU/kFreeBSD" ] && proc="linprocfs"
|
2008-03-11 13:55:39 +00:00
|
|
|
ebegin "Mounting /proc"
|
2008-03-11 13:39:20 +00:00
|
|
|
if ! fstabinfo --mount /proc; then
|
2009-04-26 21:13:26 +00:00
|
|
|
mount -n -t "$procfs" -o noexec,nosuid,nodev proc /proc
|
2007-09-26 10:09:27 +00:00
|
|
|
fi
|
2007-04-05 11:18:42 +00:00
|
|
|
eend $?
|
|
|
|
fi
|
|
|
|
|
2011-09-12 17:46:51 +02:00
|
|
|
# /run is a new directory for storing volatile runtime data.
|
|
|
|
# Read more about /run at https://lwn.net/Articles/436012
|
2013-12-11 17:39:38 -06:00
|
|
|
sys="$(openrc --sys)"
|
2012-07-02 13:22:04 -05:00
|
|
|
|
2012-02-22 20:44:32 -06:00
|
|
|
if [ ! -d /run ]; then
|
2012-07-02 13:22:04 -05:00
|
|
|
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-22 20:44:32 -06:00
|
|
|
fi
|
|
|
|
|
2012-07-02 13:22:04 -05:00
|
|
|
if [ "$sys" = VSERVER ]; then
|
|
|
|
rm -rf /run/*
|
|
|
|
elif ! mountinfo -q /run; then
|
2012-02-22 20:44:32 -06:00
|
|
|
ebegin "Mounting /run"
|
|
|
|
rc=0
|
|
|
|
if ! fstabinfo --mount /run; then
|
2014-01-18 02:34:39 -06:00
|
|
|
mount -t tmpfs -o mode=0755,nodev,size=10% tmpfs /run
|
2012-02-22 20:44:32 -06:00
|
|
|
rc=$?
|
|
|
|
fi
|
|
|
|
if [ $rc != 0 ]; then
|
|
|
|
eerror "Unable to mount tmpfs on /run."
|
|
|
|
eerror "Can't continue."
|
|
|
|
exit 1
|
2011-09-12 17:46:51 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2012-02-22 20:44:32 -06:00
|
|
|
checkpath -d $RC_SVCDIR
|
|
|
|
checkpath -d -m 0775 -o root:uucp /run/lock
|
|
|
|
|
2010-02-26 09:34:43 +00:00
|
|
|
# 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
|
|
|
|
|
2012-02-22 20:44:32 -06:00
|
|
|
if [ -e "$RC_LIBEXECDIR"/cache/deptree ]; then
|
|
|
|
cp -p "$RC_LIBEXECDIR"/cache/* "$RC_SVCDIR" 2>/dev/null
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo sysinit >"$RC_SVCDIR"/softlevel
|
|
|
|
exit 0
|