diff -Naur vzctl-3.0.18/etc/dists/magellan.conf vzctl-3.0.18-magellan/etc/dists/magellan.conf --- vzctl-3.0.18/etc/dists/magellan.conf 1970-01-01 01:00:00.000000000 +0100 +++ vzctl-3.0.18-magellan/etc/dists/magellan.conf 2007-07-22 00:44:53.000000000 +0200 @@ -0,0 +1,27 @@ +# Copyright (C) 2000-2007 SWsoft. 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 +# +# This configuration file is meant to be used with +# the Magellan distribution kit. +# + +ADD_IP=magellan-add_ip.sh +DEL_IP=magellan-del_ip.sh +SET_HOSTNAME=magellan-set_hostname.sh +SET_DNS=set_dns.sh +SET_USERPASS=set_userpass.sh +SET_UGID_QUOTA=magellan-set_ugid_quota.sh +POST_CREATE=postcreate.sh diff -Naur vzctl-3.0.18/etc/dists/scripts/magellan-add_ip.sh vzctl-3.0.18-magellan/etc/dists/scripts/magellan-add_ip.sh --- vzctl-3.0.18/etc/dists/scripts/magellan-add_ip.sh 1970-01-01 01:00:00.000000000 +0100 +++ vzctl-3.0.18-magellan/etc/dists/scripts/magellan-add_ip.sh 2007-07-22 00:45:06.000000000 +0200 @@ -0,0 +1,122 @@ +#!/bin/bash +# Copyright (C) 2000-2007 SWsoft. 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 +# +# +# This script configure IP alias(es) inside Magellan like VE. +# +# Parameters are passed in environment variables. +# Required parameters: +# IP_ADDR - IP address(es) to add +# (several addresses should be divided by space) +# Optional parameters: +# VE_STATE - state of VE; could be one of: +# starting | stopping | running | stopped +# IPDELALL - delete all old interfaces +# + +VENET_DEV=venet0 +IFCFG_DIR=/etc/conf.d +IFCFG=${IFCFG_DIR}/net.${VENET_DEV} +ROUTESCFG=${IFCFG_DIR}/net.routes +SCRIPT=/etc/runlevels/default/net.${VENET_DEV} +HOSTFILE=/etc/hosts + +function setup_network() +{ + cat > ${IFCFG} << EOF +ONBOOT=yes +NETWORKING=static +IP=127.0.0.1 +NETMASK=255.255.255.255 +BROADCAST=0.0.0.0 +EOF + + # setup routes + echo "-net ${FAKEGATEWAY} netmask 255.255.255.255 dev ${VENET_DEV}" > ${ROUTESCFG} + echo "default gw ${FAKEGATEWAY}" >> ${ROUTESCFG} + + # Set up /etc/hosts + if [ ! -f ${HOSTFILE} ]; then + echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE + fi +} + +function get_all_aliasid() +{ + IFNUM=-1 + IFNUMLIST=$(for i in $(find ${IFCFG_DIR} -name net.${VENET_DEV}:*); do echo $i | sed "s/.*${VENET_DEV}://"; done) +} + +function get_free_aliasid() +{ + local found= + + [ -z "${IFNUMLIST}" ] && get_all_aliasid + while test -z ${found}; do + let IFNUM=IFNUM+1 + echo "${IFNUMLIST}" | grep -q -E "${IFNUM}" 2>/dev/null || found=1 + done +} + +function create_config() +{ + local ip=$1 + local ifnum=$2 + + echo -e "# auto-generated configuration for ${VENET_DEV}:${ifnum} +ONBOOT=yes +NETWORKING=static +IP=${ip} +NETMASK=255.255.255.255 +BROADCAST=0.0.0.0 +" > ${IFCFG}:${ifnum} +} + + +function add_ip() +{ + local ip + local new_ips + + # In case we are starting VE + if [ "x${VE_STATE}" = "xstarting" ]; then + setup_network + fi + + if [ "x${IPDELALL}" = "xyes" ]; then + rm -f ${IFCFG} + rm -f ${IFCFG}:[0-9]* + fi + + for ip in ${IP_ADDR}; do + found= + if grep -e "\\<${ip}\\>" >/dev/null 2>&1 ${IFCFG}:*; then + continue + fi + get_free_aliasid + create_config ${ip} ${IFNUM} + done + + if [ "x${VE_STATE}" = "xrunning" ]; then + # synchronyze config files & interfaces + /etc/init.d/network restart 2>/dev/null 1>/dev/null + fi +} + +add_ip +exit 0 +# end of script diff -Naur vzctl-3.0.18/etc/dists/scripts/magellan-del_ip.sh vzctl-3.0.18-magellan/etc/dists/scripts/magellan-del_ip.sh --- vzctl-3.0.18/etc/dists/scripts/magellan-del_ip.sh 1970-01-01 01:00:00.000000000 +0100 +++ vzctl-3.0.18-magellan/etc/dists/scripts/magellan-del_ip.sh 2007-07-22 00:45:09.000000000 +0200 @@ -0,0 +1,53 @@ +#!/bin/bash +# Copyright (C) 2000-2007 SWsoft. 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 +# +# +# This script deletes IP alias(es) inside VE for Magellan like distros. +# For usage info see ve-alias_del(5) man page. +# +# Parameters are passed in environment variables. +# Required parameters: +# IP_ADDR - IPs to delete, several addresses should be divided by space +# Optional parameters: +# VE_STATE - state of VE; could be one of: +# starting | stopping | running | stopped + +VENET_DEV=venet0 +IFCFG_DIR=/etc/conf.d +IFCFG=${IFCFG_DIR}/net.${VENET_DEV} + +function del_ip() +{ + local found= + local ip ifname + + for ip in ${IP_ADDR}; do + ifname=$(grep -l -e "\\<${ip}\\>" ${IFCFG}:* | sed "s:${IFCFG_DIR}:net.::") + if [ -n "${ifname}" ]; then + ifconfig ${ifname} down + rm -f ${IFCFG_DIR}/net.${ifname} + found=true + fi + done + if [ -n "${found}" ]; then + /etc/init.d/network restart 2>/dev/null 1>/dev/null + fi +} + +del_ip +exit 0 +# end of script diff -Naur vzctl-3.0.18/etc/dists/scripts/magellan-set_hostname.sh vzctl-3.0.18-magellan/etc/dists/scripts/magellan-set_hostname.sh --- vzctl-3.0.18/etc/dists/scripts/magellan-set_hostname.sh 1970-01-01 01:00:00.000000000 +0100 +++ vzctl-3.0.18-magellan/etc/dists/scripts/magellan-set_hostname.sh 2007-07-22 00:45:13.000000000 +0200 @@ -0,0 +1,60 @@ +#!/bin/bash +# Copyright (C) 2000-2007 SWsoft. 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 +# +# +# This script sets hostname inside VE for Magellan like distros +# For usage info see vz-veconfig(5) man page. +# +# Some parameters are passed in environment variables. +# Required parameters: +# Optional parameters: +# HOSTNM +# Sets host name for this VE. Modifies /etc/hosts and +# /etc/sysconfig/network (in RedHat) or /etc/rc.config (in SuSE) + +function set_host() +{ + local cfgfile="$1" + local var=$2 + local val=$3 + local host= + + [ -z "${val}" ] && return 0 + if grep -q -E "[[:space:]]${val}" ${cfgfile} 2>/dev/null; then + return; + fi + if echo "${val}" | grep "\." >/dev/null 2>&1; then + host=${val%%.*} + fi + host=" ${val} ${host}" + put_param2 "${cfgfile}" "${var}" "${host} localhost localhost.localdomain" +} + +function set_hostname() +{ + local cfgfile=$1 + local hostname=$2 + + [ -z "${hostname}" ] && return 0 + echo "${hostname}" > ${cfgfile} + hostname ${hostname} +} + +set_host /etc/hosts "127.0.0.1" "${HOSTNM}" +set_hostname /etc/hostname "${HOSTNM}" + +exit 0 diff -Naur vzctl-3.0.18/etc/dists/scripts/magellan-set_ugid_quota.sh vzctl-3.0.18-magellan/etc/dists/scripts/magellan-set_ugid_quota.sh --- vzctl-3.0.18/etc/dists/scripts/magellan-set_ugid_quota.sh 1970-01-01 01:00:00.000000000 +0100 +++ vzctl-3.0.18-magellan/etc/dists/scripts/magellan-set_ugid_quota.sh 2007-07-22 00:45:17.000000000 +0200 @@ -0,0 +1,72 @@ +#!/bin/bash +# Copyright (C) 2000-2007 SWsoft. 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 +# +# +# This script configures quota startup script inside VE for Magellan like distros +# +# Parameters are passed in environment variables. +# Required parameters: +# MINOR - root device minor number +# MAJOR - root device major number +SCRIPTANAME='/etc/rc.d/init.d/vzquota' +RCDIRS="/etc/rc.d" + +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 -e '#!/bin/sh +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 + quotaon -aug +} +case "$1" in + start) + start + ;; + *) + exit +esac ' > ${SCRIPTANAME} || { + echo "Unable to create ${SCRIPTNAME}" + 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 + diff -Naur vzctl-3.0.18/etc/init.d/Makefile.am vzctl-3.0.18-magellan/etc/init.d/Makefile.am --- vzctl-3.0.18/etc/init.d/Makefile.am 2007-07-06 09:46:25.000000000 +0200 +++ vzctl-3.0.18-magellan/etc/init.d/Makefile.am 2007-07-21 17:29:07.000000000 +0200 @@ -15,7 +15,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -INITSCRIPTS = vz-redhat vz-gentoo +INITSCRIPTS = vz-redhat vz-gentoo vz-magellan EXTRA_DIST = $(INITSCRIPTS:%=%.in) @@ -34,3 +34,7 @@ install-gentoo: vz-gentoo $(mkinstalldirs) $(DESTDIR)$(initddir) $(INSTALL_SCRIPT) vz-gentoo $(DESTDIR)$(initddir)/vz + +install-gentoo: vz-magellan + $(mkinstalldirs) $(DESTDIR)$(initddir) + $(INSTALL_SCRIPT) vz-magellan $(DESTDIR)$(initddir)/vz diff -Naur vzctl-3.0.18/etc/init.d/Makefile.in vzctl-3.0.18-magellan/etc/init.d/Makefile.in --- vzctl-3.0.18/etc/init.d/Makefile.in 2007-07-06 09:46:34.000000000 +0200 +++ vzctl-3.0.18-magellan/etc/init.d/Makefile.in 2007-07-21 17:28:37.000000000 +0200 @@ -204,7 +204,7 @@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ -INITSCRIPTS = vz-redhat vz-gentoo +INITSCRIPTS = vz-redhat vz-gentoo vz-magellan EXTRA_DIST = $(INITSCRIPTS:%=%.in) CLEANFILES = $(INITSCRIPTS) @ENABLE_BASHCOMP_TRUE@bashcdir = $(sysconfdir)/bash_completion.d @@ -407,6 +407,11 @@ install-gentoo: vz-gentoo $(mkinstalldirs) $(DESTDIR)$(initddir) $(INSTALL_SCRIPT) vz-gentoo $(DESTDIR)$(initddir)/vz + +install-magellan: vz-magellan + $(mkinstalldirs) $(DESTDIR)$(initddir) + $(INSTALL_SCRIPT) vz-magellan $(DESTDIR)$(initddir)/vz + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff -Naur vzctl-3.0.18/etc/init.d/vz-magellan.in vzctl-3.0.18-magellan/etc/init.d/vz-magellan.in --- vzctl-3.0.18/etc/init.d/vz-magellan.in 1970-01-01 01:00:00.000000000 +0100 +++ vzctl-3.0.18-magellan/etc/init.d/vz-magellan.in 2007-07-22 00:44:28.000000000 +0200 @@ -0,0 +1,405 @@ +#!/bin/bash +# $Header: /root/magellan-cvs/src/vzctl/patches/vzctl-3.0.18-magellan.patch,v 1.2 2007-07-21 22:55:33 niro Exp $ + +#%rlevels: 3:s 4:s 5:s 0:k 1:k 2:k 6:k +#%start: 96 +#%stop: 88 + +#deps +#%needs: +#%before: +#%after: + +source /etc/sysconfig/rc +source $rc_functions + +check_config() +{ + source /etc/vz/vz.conf + + # if we don't want openvz running, say so + [ "${VIRTUOZZO}" = "yes" ] || return 1 + + # set default values + : ${VZCTL:=@SBINDIR@/vzctl} + : ${VZQUOTA:=@SBINDIR@/vzquota} + : ${VZVEINFO:=/proc/vz/veinfo} + : ${VESTAT:=/proc/vz/vestat} + : ${VPSCONFDIR:=@VPSCONFDIR@} + : ${VZDEV:=venet0} + : ${SRC_CRONSCRIPT_DIR:=@CRONDDIR@} + : ${DST_CRONSCRIPT_DIR:=@DST_CRONDDIR@} + + if [ "${MODULES_DISABLED}" != "yes" ] + then + : ${PRELOAD_MODULES:="af_packet"} + : ${MODULES:="vzmon vzdquota vzdev"} + : ${MIGRATE_MODULES:="vzcpt vzrst"} + : ${NET_MODULES="vznetdev vznet"} + + # check if you should load vzwdog module + [ "${VZWDOG}" = "yes" ] && MODULES="${MODULES} vzwdog" + fi + + # we need a working vzctl + if [ ! -x "${VZCTL}" ] + then + ${FAILURE} "vzctl missing (${VZCTL})" + return 1 + fi + + if [ -z "${VE0CPUUNITS}" ] + then + ${WARNING} "VE0CPUUNITS is not set in /etc/conf.d/vz; using default value of 1000" + VE0CPUUNITS=1000 + fi + return 0 +} + +# We used to install OpenVZ cron job when the vzctl package was +# installed, irrespective of whether OpenVZ was actually being +# run. Although the cron jobs didn't create any problems if someone +# wasn't running OpenVZ some users complained about the cron log file +# filling up, resource usage, and power consumption since systems +# wouldn't really idle. It really only makes sense to run the OpenVZ +# cron job if the vz service is turned on and not just merely +# having the package installed. This init.d script is an obvious place +# to install or remove the cron jobs based on the service +# being enabled or not. +setup_cron() +{ + [ -z "${SRC_CRONSCRIPT_DIR}" ] && return + [ -d "${SRC_CRONSCRIPT_DIR}" ] || return + install -m644 -o root -g root ${SRC_CRONSCRIPT_DIR}/vz ${DST_CRONSCRIPT_DIR} +} + +remove_cron() +{ + [ -z "${SRC_CRONSCRIPT_DIR}" ] && return + [ -d "${SRC_CRONSCRIPT_DIR}" ] || return + cat > ${DST_CRONSCRIPT_DIR}/vz <&1) + [ $? -ne 0 ] && ${WARNING} "vzctl set 0 --cpuunits ${VE0CPUUNITS} failed: ${msg}" + + test -f ${ve0conf} || return + egrep -q '^ONBOOT=yes\|^ONBOOT=\"yes\"' ${ve0conf} || return + + echo -en ${COLOREDSTAR}"Configuring hardware node UB resources: " + msg=$(${VZCTL} set 0 --reset_ub 2>&1) + retval=$? + echo "${msg}" + evaluate_retval ${retval} +} + +start_net() +{ + local mod + + # we don't operate on a running interface + if /sbin/ip addr list | grep -q "venet0:.*UP" 2>/dev/null + then + return 0 + fi + + # load necessary modules + for mod in ${NET_MODULES} + do + /sbin/modprobe ${mod} 2>/dev/null + done + + if [ ! -f ${VZVEINFO} ] + then + return 0 + fi + + # configure the device + echo -e ${COLOREDSTAR}"Bringing up interface ${VZDEV}" + /sbin/ip link set ${VZDEV} up + evaluate_retval + + /sbin/ip addr add 0.0.0.0/0 dev ${VZDEV} + + echo -e ${COLOREDSTAR}"Configuring interface ${VZDEV}" + /sbin/sysctl -q -w net.ipv4.conf.${VZDEV}.send_redirects=0 + evaluate_retval +} + +stop_net() +{ + local mod + + if /sbin/ip addr list | grep -q "venet0:.*UP" 2>/dev/null + then + echo -e ${COLOREDSTAR}"Bringing down interface ${VZDEV}" + /sbin/ip link set ${VZDEV} down 2>/dev/null + evaluate_retval + fi + + # remove all modules we probably loaded on start_net + for mod in ${NET_MODULES} + do + /sbin/modprobe -r ${mod} > /dev/null 2>&1 + done +} + +start_ve() +{ + local veid velist msg need_restart="" retval + + # get all VEs we should start on boot + if ! cd ${VPSCONFDIR} + then + ${FAILURE} "Unable to cd to ${VPSCONFDIR}" + return 1 + fi + velist=$(grep -l '^ONBOOT=yes\|^ONBOOT=\"yes\"' [0-9]*.conf 2>/dev/null | sed -e 's/.conf//g' | sort -n) + cd - >/dev/null + + /sbin/sysctl -q -w net.ipv4.route.src_check=0 + + for veid in ${velist} + do + echo -en ${COLOREDSTAR}"Starting VE ${veid}" + if [ "${VZFASTBOOT}" = "yes" -a "${DISK_QUOTA}" = "yes" ] + then + ${VZQUOTA} stat ${veid} >/dev/null 2>&1 + if [ $? -eq 6 ] + then + if ${VZQUOTA} show ${veid} 2>&1 | grep "vzquota : (warning) Quota is running" >/dev/null 2>&1 + then + ${VZQUOTA} on ${veid} --nocheck >/dev/null 2>&1 + need_restart="${need_restart} ${veid}" + fi + fi + fi + msg=$(${VZCTL} start ${veid} 2>&1) + retval=$? + echo "${mesg}" + evaluate_retval ${retval} + done + + for veid in ${need_restart} + do + echo -en ${COLOREDSTAR}"Stopping VE ${veid}" + msg=$(${VZCTL} stop ${veid}) + retval=$? + echo "${mesg}" + evaluate_retval ${retval} + + echo -e ${COLOREDSTAR}"Starting VE ${veid}" + msg=$($VZCTL start ${veid} 2>&1) + retval=$? + echo "${mesg}" + evaluate_retval ${retval} + done + + # we're ok even if some VEs failed to start + return 0 +} + +get_parallel() +{ + [ -n "${PARALLEL}" ] && return + PARALLEL=`awk ' +BEGIN { num=0; } +$1 == "processor" { num++; } +END { print num * 4; }' /proc/cpuinfo` +} + +stop_ve() +{ + local veid velist msg m mounts fail i iter pid pids quota retval + + if [ -f ${VESTAT} ] + then + get_parallel + for ((i = 0; i <= 2; i++)) + do + iter=0 + pids= + velist=$(awk '$1 != "VEID" && $1 != "Version:" {print $1}' ${VESTAT}) + for veid in ${velist} + do + echo -e ${COLOREDSTAR}"Shutting down VE $veid" + # Set fairsched parameters to maximum so + # VE will stop fast + ${VZCTL} set ${veid} --cpuunits 2000 --cpulimit 0 >/dev/null 2>&1 + ${VZCTL} --skiplock stop ${veid} >/dev/null 2>&1 & + pids="${pids} $!" + let iter++ + if [ ${iter} -gt ${PARALLEL} ] + then + for pid in ${pids} + do + wait ${pid} + done + pids= + iter=0 + fi + done + + for pid in ${pids} + do + wait ${pid} + done + done + fi + + iter=0 + fail=1 + + while [ ${iter} -lt 5 -a ${fail} -ne 0 ] + do + fail=0 + mounts=$(awk '{if ($3=="simfs") print $2}' /proc/mounts) + + for m in ${mounts} + do + echo -en ${COLOREDSTAR}"Unmounting VE area ${m}" + msg=$(umount ${m} 2>&1) + retval=$? + echo "${mesg}" + evaluate_retval ${retval} + if [ $? -ne 0 ] + then + let fail++ + fuser -k -m ${m} > /dev/null 2>&1 + fi + done + + let iter++ + done + + # turn quota off + quota=$(awk -F: '/^[0-9]+:/{print $1}' /proc/vz/vzquota 2>/dev/null) + + for m in ${quota} + do + echo -e ${COLOREDSTAR}"Turning quota off for VE ${m}" + msg=$(vzquota off ${m} 2>&1) + retval=$? + echo "${mesg}" + evaluate_retval ${retval} + done +} + +status_ve() +{ + local velist veid + + check_config + + if [ -f ${VESTAT} ] + then + velist=$(awk '$1 != "VEID" && $1 != "Version:" {print $1}' ${VESTAT}) + for veid in ${velist} + do + ${VZCTL} status ${veid} + done + fi +} + +case "$1" in + start) + check_config || exit + + echo -e ${COLOREDSTAR}"Loading OpenVZ modules" + for mod in ${PRELOAD_MODULES} + do + /sbin/modprobe -r ${mod} >/dev/null 2>&1 + /sbin/modprobe ${mod} >/dev/null 2>&1 + done + + for mod in ${MODULES} + do + /sbin/modprobe ${mod} >/dev/null 2>&1 + retval=$? + if [ ${retval} -ne 0 ] + then + ${FAILURE} "failed to load module ${mod}" + exit ${retval} + fi + done + + for mod in ${MIGRATE_MODULES} + do + /sbin/modprobe ${mod} >/dev/null 2>&1 + done + evaluate_retval + + if [ ! -e /dev/vzctl ] + then + ${FAILURE} "Missing device node /dev/vzctl" + echo + echo "Please create the vzctl device node using the following command:" + echo " /bin/mknod /dev/vzctl c 126 0" + echo + exit 1 + fi + + start_net + setup_ve0 + setup_cron + start_ve + + update_svcstatus $1 + splash svc_started "$(basename $0)" 0 + ;; + + stop) + check_config || exit + + stop_ve + remove_cron + stop_net + + echo -e ${COLOREDSTAR}"Unloading OpenVZ modules" + for mod in ${MIGRATE_MODULES} + do + /sbin/modprobe -r ${mod} > /dev/null 2>&1 + done + + for mod in ${MODULES} + do + /sbin/modprobe -r ${mod} > /dev/null 2>&1 + done + + for mod in ${PRELOAD_MODULES} + do + /sbin/modprobe -r ${mod} > /dev/null 2>&1 + done + # Even if some modules failed to unload (say they were not loaded) + # we return success for the service to be marked as stopped. + print_status success + + update_svcstatus $1 + splash svc_stopped "$(basename $0)" 0 + ;; + + restart) + $0 stop + sleep 1 + $0 start + ;; + + status) + status_ve + ;; + + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac diff -Naur vzctl-3.0.18/Makefile.am vzctl-3.0.18-magellan/Makefile.am --- vzctl-3.0.18/Makefile.am 2007-07-06 09:46:25.000000000 +0200 +++ vzctl-3.0.18-magellan/Makefile.am 2007-07-22 00:54:26.000000000 +0200 @@ -44,6 +44,7 @@ DISTRO_TARGETS = \ install-redhat \ install-gentoo \ + install-magellan \ install-suse \ install-debian diff -Naur vzctl-3.0.18/Makefile.in vzctl-3.0.18-magellan/Makefile.in --- vzctl-3.0.18/Makefile.in 2007-07-06 09:46:36.000000000 +0200 +++ vzctl-3.0.18-magellan/Makefile.in 2007-07-22 00:54:41.000000000 +0200 @@ -214,6 +214,7 @@ DISTRO_TARGETS = \ install-redhat \ install-gentoo \ + install-magellan \ install-suse \ install-debian