2008-02-28 01:59:32 +05:30
|
|
|
#!@SHELL@
|
2007-04-05 16:48:42 +05:30
|
|
|
# Copyright 1999-2007 Gentoo Foundation
|
2008-01-11 21:01:10 +05:30
|
|
|
# Copyright 2007-2008 Roy Marples <roy@marples.name>
|
|
|
|
# All rights reserved. Released under the 2-clause BSD license.
|
2007-11-14 20:52:04 +05:30
|
|
|
|
2008-02-03 22:51:11 +05:30
|
|
|
# This basically mounts $RC_SVCDIR as a ramdisk, but preserving its content
|
|
|
|
# which allows us to store service state and generate dependencies if needed.
|
2007-04-05 16:48:42 +05:30
|
|
|
# The tricky part is finding something our kernel supports
|
2008-02-03 22:51:11 +05:30
|
|
|
# tmpfs and ramfs are easy, so force one or the other.
|
2008-01-11 17:43:46 +05:30
|
|
|
mount_svcdir()
|
|
|
|
{
|
2008-10-10 14:07:21 +05:30
|
|
|
local fs= fsopts="-o rw,noexec,nodev,nosuid"
|
|
|
|
local devdir="rc-svcdir" devtmp="none" x=
|
2008-01-31 15:18:58 +05:30
|
|
|
local svcsize=${rc_svcsize:-1024}
|
2007-04-05 16:48:42 +05:30
|
|
|
|
2007-09-26 15:39:27 +05:30
|
|
|
if grep -Eq "[[:space:]]+tmpfs$" /proc/filesystems; then
|
2007-04-05 16:48:42 +05:30
|
|
|
fs="tmpfs"
|
|
|
|
fsopts="${fsopts},mode=0755,size=${svcsize}k"
|
2007-09-26 15:39:27 +05:30
|
|
|
elif grep -Eq "[[:space:]]+ramfs$" /proc/filesystems; then
|
2007-04-05 16:48:42 +05:30
|
|
|
fs="ramfs"
|
2007-04-14 14:57:29 +05:30
|
|
|
# ramfs has no special options
|
2007-04-05 16:48:42 +05:30
|
|
|
elif [ -e /dev/ram0 -a -e /dev/ram1 ] \
|
2007-09-26 15:39:27 +05:30
|
|
|
&& grep -Eq "[[:space:]]+ext2$" /proc/filesystems; then
|
2007-04-05 16:48:42 +05:30
|
|
|
devdir="/dev/ram0"
|
|
|
|
devtmp="/dev/ram1"
|
|
|
|
fs="ext2"
|
2007-09-26 15:39:27 +05:30
|
|
|
for x in ${devdir} ${devtmp}; do
|
2008-01-31 15:18:58 +05:30
|
|
|
dd if=/dev/zero of="${x}" bs=1k count="${svcsize}"
|
|
|
|
mkfs -t "${fs}" -i 1024 -vm0 "${x}" "${svcsize}"
|
2007-04-05 16:48:42 +05:30
|
|
|
done
|
|
|
|
else
|
|
|
|
echo
|
2007-11-14 20:52:04 +05:30
|
|
|
eerror "OpenRC requires tmpfs, ramfs or 2 ramdisks + ext2"
|
2007-04-05 16:48:42 +05:30
|
|
|
eerror "compiled into the kernel"
|
|
|
|
echo
|
2008-01-31 15:18:58 +05:30
|
|
|
return 1
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
local dotmp=false
|
2007-09-26 15:39:27 +05:30
|
|
|
if [ -e "${RC_SVCDIR}"/deptree ]; then
|
2007-04-05 16:48:42 +05:30
|
|
|
dotmp=true
|
2007-12-14 19:49:03 +05:30
|
|
|
mount -n -t "${fs}" -o rw "${devtmp}" "${RC_LIBDIR}"/tmp
|
2007-08-15 20:19:41 +05:30
|
|
|
cp -p "${RC_SVCDIR}"/deptree "${RC_SVCDIR}"/depconfig \
|
|
|
|
"${RC_SVCDIR}"/nettree "${RC_LIBDIR}"/tmp 2>/dev/null
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
2007-09-26 15:39:27 +05:30
|
|
|
|
2008-01-31 15:18:58 +05:30
|
|
|
# If we have no entry in fstab for $RC_SVCDIR, provide our own
|
2008-03-11 19:09:20 +05:30
|
|
|
if ! fstabinfo --mount "${RC_SVCDIR}"; then
|
2007-12-14 19:49:03 +05:30
|
|
|
mount -n -t "${fs}" ${fsopts} "${devdir}" "${RC_SVCDIR}"
|
2007-09-26 15:39:27 +05:30
|
|
|
fi
|
|
|
|
|
|
|
|
if ${dotmp}; then
|
2007-08-15 20:19:41 +05:30
|
|
|
cp -p "${RC_LIBDIR}"/tmp/deptree "${RC_LIBDIR}"/tmp/depconfig \
|
|
|
|
"${RC_LIBDIR}"/tmp/nettree "${RC_SVCDIR}" 2>/dev/null
|
2007-12-14 19:49:03 +05:30
|
|
|
umount -n "${RC_LIBDIR}"/tmp
|
2007-04-05 16:48:42 +05:30
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
. /etc/init.d/functions.sh
|
2007-11-23 17:34:11 +05:30
|
|
|
[ -r /etc/rc.conf ] && . /etc/rc.conf
|
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
|
|
|
|
# /proc actually works or not. We to this by comparing uptime to one a second
|
|
|
|
# ago
|
|
|
|
mountproc=true
|
2007-09-26 15:39:27 +05:30
|
|
|
if [ -e /proc/uptime ]; then
|
2007-05-23 19:42:06 +05:30
|
|
|
up="$(cat /proc/uptime)"
|
|
|
|
sleep 1
|
2007-09-26 15:39:27 +05:30
|
|
|
if [ "${up}" = "$(cat /proc/uptime)" ]; then
|
2007-05-23 19:42:06 +05:30
|
|
|
eerror "You have cruft in /proc that should be deleted"
|
|
|
|
else
|
|
|
|
einfo "/proc is already mounted, skipping"
|
|
|
|
mountproc=false
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2007-11-28 21:15:03 +05:30
|
|
|
if ${mountproc}; then
|
2007-04-05 16:48:42 +05:30
|
|
|
procfs="proc"
|
|
|
|
[ "${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
|
2007-12-14 19:49:03 +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
|
|
|
|
|
|
|
|
. "${RC_LIBDIR}"/sh/init-common-post.sh
|