blob: c9706917978496590b58cc56d2ab4012577b4da8 [file] [log] [blame] [raw]
#!/bin/bash
# Copyright (C) 2000-2008, Parallels, Inc. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Configures quota startup script in a container.
SCRIPTANAME='/etc/init.d/vzquota'
RCDIRS="/etc/rc.d /etc"
if [ -z "$MAJOR" ]; then
rm -f ${SCRIPTANAME} > /dev/null 2>&1
rm -f /etc/mtab > /dev/null 2>&1
ln -sf /proc/mounts /etc/mtab
exit 0
fi
echo '#!/bin/sh
### BEGIN INIT INFO
# Provides: vzquota
# Required-Start: $local_fs $time $syslog
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start vzquota at the end of boot
# Description: Configure OpenVZ disk quota for a container.
### END INIT INFO
start() {
[ -e "/dev/'${DEVFS}'" ] || mknod /dev/'${DEVFS}' b '$MAJOR' '$MINOR'
rm -f /etc/mtab >/dev/null 2>&1
echo "/dev/'${DEVFS}' / reiserfs rw,usrquota,grpquota 0 0" > /etc/mtab
mnt=`grep -v " / " /proc/mounts`
if [ $? = 0 ]; then
echo "$mnt" >> /etc/mtab
fi
chmod 644 /etc/mtab
quotaon -aug
}
case "$1" in
start)
start
;;
*)
exit
esac ' > ${SCRIPTANAME} || {
echo "Unable to create ${SCRIPTANAME}"
exit 1
}
chmod 755 ${SCRIPTANAME}
RC=
for RC in ${RCDIRS}; do
[ -d ${RC}/rc3.d ] && break
done
if [ -z "${RC}" ]; then
echo "Unable to find runlevel directories"
exit 1
fi
for dir in `ls -d ${RC}/rc[0-6].d`; do
ln -sf ${SCRIPTANAME} ${dir}/S10vzquota
done
exit 0