]> git.pld-linux.org Git - packages/vzctl.git/commitdiff
- added PLD resources from ΔΉ\81ukasz Chrustek <lukasz@chrustek.net>
authorTomasz Pala <gotar@pld-linux.org>
Fri, 28 Jan 2011 01:06:54 +0000 (01:06 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    pld-add_ip.sh -> 1.1
    pld-del_ip.sh -> 1.1
    pld-set_hostname.sh -> 1.1
    pld.conf -> 1.1
    vz-pld.in -> 1.1
    vzctl-pld.patch -> 1.1
    vzctl.spec -> 1.9
    vzeventd-pld.in -> 1.1

pld-add_ip.sh [new file with mode: 0644]
pld-del_ip.sh [new file with mode: 0644]
pld-set_hostname.sh [new file with mode: 0644]
pld.conf [new file with mode: 0644]
vz-pld.in [new file with mode: 0644]
vzctl-pld.patch [new file with mode: 0644]
vzctl.spec
vzeventd-pld.in [new file with mode: 0644]

diff --git a/pld-add_ip.sh b/pld-add_ip.sh
new file mode 100644 (file)
index 0000000..fc2c1a5
--- /dev/null
@@ -0,0 +1,240 @@
+#!/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 RedHat 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
+VENET_DEV_CFG=ifcfg-$VENET_DEV
+
+
+IFCFG_DIR=/etc/sysconfig/interfaces
+IFCFG=${IFCFG_DIR}/ifcfg-${VENET_DEV}
+NETFILE=/etc/sysconfig/network
+HOSTFILE=/etc/hosts
+ROUTE=/etc/sysconfig/network
+NETWORKRESTART=
+
+function fix_ifup
+{
+       file="/sbin/ifup"
+
+       [ -f "${file}" ] || return 0
+       [ "x${VE_STATE}" != "xstarting" ] && return 0
+
+       if grep -q 'if \[ "\${DEVICE}" = "lo" \]; then' ${file} 2>/dev/null
+       then
+               ${CP} ${file} ${file}.$$ || return 1
+               /bin/sed -e 's/if \[ "\${DEVICE}" = "lo" \]; then/if \[ "${IPADDR}" = "127.0.0.1" \]; then/g' < ${file} > ${file}.$$ &&
+                       mv -f ${file}.$$ ${file}
+               rm -f ${file}.$$ 2>/dev/null
+       fi
+}
+
+function setup_network
+{
+       # Set up venet0 main interface as 127.0.0.1
+       mkdir -p ${IFCFG_DIR}
+       echo "DEVICE=${VENET_DEV}
+BOOTPROTO=static
+ONBOOT=yes
+IPADDR=127.0.0.1
+NETMASK=255.255.255.255
+BROADCAST=0.0.0.0" > $IFCFG || error "Can't write to file $IFCFG" $VZ_FS_NO_DISK_SPACE
+
+
+       remove_fake_old_route ${ROUTE}
+#      if ! grep -q "${FAKEGATEWAYNET}/24 dev ${VENET_DEV}" ${ROUTE} 2>/dev/null; then
+#              echo "${FAKEGATEWAYNET}/24 dev ${VENET_DEV} scope host
+#default via ${FAKEGATEWAY}" >> ${ROUTE} || error "Can't create ${ROUTE}" ${VZ_FS_NO_DISK_SPACE}
+#      fi
+       # Set /etc/sysconfig/network
+       put_param $NETFILE NETWORKING yes
+       put_param $NETFILE GATEWAY ${FAKEGATEWAY}
+
+       # setup ipv6
+       setup6_network
+
+       # Set up /etc/hosts
+       if [ ! -f ${HOSTFILE} ]; then
+               echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE
+       fi
+       fix_ifup
+}
+
+function setup6_network
+{
+       [ "${IPV6}" != "yes" ] && return 0
+
+       if ! grep -q 'IPV6INIT="yes"' ${IFCFG}; then
+               put_param ${IFCFG} IPV6INIT yes
+       fi
+       if ! grep -q 'NETWORKING_IPV6="yes"' ${NETFILE}; then
+               put_param ${NETFILE} NETWORKING_IPV6 yes
+               put_param ${NETFILE} IPV6_DEFAULTDEV ${VENET_DEV}
+               NETWORKRESTART=yes
+       fi
+}
+
+function create_config
+{
+       local ip=$1
+       local ifnum=$2
+
+       echo "DEVICE=${VENET_DEV}:${ifnum}
+BOOTPROTO=static
+ONBOOT=yes
+IPADDR=${ip}
+NETMASK=255.255.255.255" > ${IFCFG_DIR}/bak/${VENET_DEV_CFG}:${ifnum} ||
+       error "Unable to create interface config file" ${VZ_FS_NO_DISK_SPACE}
+}
+
+function add_ip6
+{
+       [ "${IPV6}" != "yes" ] && return
+       if ! grep -qw "$1" ${IFCFG} 2>/dev/null; then
+               setup6_network
+               add_param ${IFCFG} IPV6ADDR_SECONDARIES "$1/128"
+               ifconfig ${VENET_DEV} add "$1/128"
+       fi
+}
+
+function get_all_aliasid
+{
+       IFNUM=-1
+
+       cd ${IFCFG_DIR} || return 1
+       IFNUMLIST=`ls -1 bak/${VENET_DEV_CFG}:* 2>/dev/null |
+               sed "s/.*${VENET_DEV_CFG}://"`
+}
+
+function get_aliasid_by_ip
+{
+       local ip=$1
+       local idlist
+
+       cd ${IFCFG_DIR} || return 1
+       IFNUM=`grep -l "IPADDR=${ip}$" ${VENET_DEV_CFG}:* | head -n 1 |
+               sed -e 's/.*:\([0-9]*\)$/\1/'`
+}
+
+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 backup_configs
+{
+       local delall=$1
+
+       rm -rf ${IFCFG_DIR}/bak/ >/dev/null 2>&1
+       mkdir -p ${IFCFG_DIR}/bak
+       [ -n "${delall}" ] && return 0
+
+       cd ${IFCFG_DIR} || return 1
+       if ls ${VENET_DEV_CFG}:* > /dev/null 2>&1; then
+               ${CP} ${VENET_DEV_CFG}:* ${IFCFG_DIR}/bak/ ||
+                       error "Unable to backup intrface config files" ${VZ_FS_NO_DISK_SPACE}
+       fi
+}
+
+function move_configs
+{
+       cd ${IFCFG_DIR} || return 1
+       rm -rf ${VENET_DEV_CFG}:*
+       mv -f bak/* ${IFCFG_DIR}/ >/dev/null 2>&1
+       rm -rf ${IFCFG_DIR}/bak
+}
+
+function add_ip
+{
+       local ip
+       local new_ips
+       local if_restart=
+
+       # In case we are starting VE
+       if [ "x${VE_STATE}" = "xstarting" ]; then
+               # Remove all VENET config files
+               rm -f ${IFCFG} ${IFCFG}:* >/dev/null 2>&1
+       fi
+       if [ ! -f "${IFCFG}" ]; then
+               setup_network
+               if_restart=1
+       fi
+       backup_configs ${IPDELALL}
+       new_ips="${IP_ADDR}"
+       if [ "x${IPDELALL}" = "xyes" ]; then
+               new_ips=
+               for ip in ${IP_ADDR}; do
+                       get_aliasid_by_ip "${ip}"
+                       if [ -n "${IFNUM}" ]; then
+                               # ip already exists just create it in bak
+                               create_config "${ip}" "${IFNUM}"
+                       else
+                               new_ips="${new_ips} ${ip}"
+                       fi
+               done
+       fi
+       for ip in ${new_ips}; do
+               if [ "${ip#*:}" = "${ip}" ]; then
+                       get_free_aliasid
+                       create_config "${ip}" "${IFNUM}"
+               else
+                       if [ "x${IPDELALL}" = "xyes" ]; then
+                               del_param ${IFCFG} IPV6ADDR_SECONDARIES ""
+                       fi
+                       add_ip6 "${ip}"
+               fi
+       done
+       move_configs
+       if [ "x${VE_STATE}" = "xrunning" ]; then
+               # synchronyze config files & interfaces
+               if [ "${NETWORKRESTART}" = "yes" ]; then
+                       /etc/init.d/network restart
+               echo "Tutaj 2"
+               elif [ -n "${if_restart}" ]; then
+                       ifup ${VENET_DEV}:${IFNUM}
+                       echo "Tutaj 3: ${VENET_DEV}:${IFNUM}";
+               else
+                       cd /etc/sysconfig/network-scripts &&
+                               ./ifup-aliases ${VENET_DEV}
+                               ifup ${VENET_DEV}:${IFNUM}
+                       echo "Tutaj 4: ${VENET_DEV}:${IFNUM}";
+               fi
+       fi
+}
+
+add_ip
+exit 0
+# end of script
diff --git a/pld-del_ip.sh b/pld-del_ip.sh
new file mode 100644 (file)
index 0000000..67e1252
--- /dev/null
@@ -0,0 +1,69 @@
+#!/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 RedHat like systems.
+#
+# Parameters are passed in environment variables.
+# Required parameters:
+#   IP_ADDR       - IPs to delete, several addresses should be divided by space
+# Optional parameters:
+#   IPDELALL      - delete all ip addresses
+VENET_DEV=venet0
+VENET_DEV_CFG=ifcfg-${VENET_DEV}
+IFCFG_DIR=/etc/sysconfig/interfaces/
+IFCFG=${IFCFG_DIR}${VENET_DEV_CFG}
+
+# Function to delete IP address for PLD like systems
+function del_ip
+{
+       local ip
+       local filetodel
+       local file
+       local aliasid
+
+       [ -d ${IFCFG_DIR} ] || return 0
+       cd ${IFCFG_DIR} || return 0
+       if [ "x${IPDELALL}" = "xyes" ]; then
+               ifdown ${VENET_DEV} >/dev/null 2>&1
+               rm -f ${VENET_DEV_CFG} ${VENET_DEV_CFG}:* 2>/dev/null
+               del_param ${IFCFG} IPV6ADDR_SECONDARIES ""
+               return 0;
+       fi
+       for ip in ${IP_ADDR}; do
+               # IPV6 processing
+               if [ "${ip#*:}" != "${ip}" ]; then
+                       del_param ${IFCFG} IPV6ADDR_SECONDARIES "${ip}\\/128"
+                       ifconfig ${VENET_DEV} del ${ip}/128
+                       continue
+               fi
+               # find and delete a file with this alias
+               filetodel=`grep -l "IPADDR=${ip}$" \
+                       ${VENET_DEV_CFG}:* 2>/dev/null`
+               for file in ${filetodel}; do
+                       rm -f "${file}"
+                       aliasid=`echo ${file} | sed s/.*://g`
+                       if [ -n "${aliasid}" ]; then
+                               ifconfig ${VENET_DEV}:${aliasid} down >/dev/null 2>&1
+                       fi
+               done
+       done
+}
+
+del_ip
+exit 0
+# end of script
diff --git a/pld-set_hostname.sh b/pld-set_hostname.sh
new file mode 100644 (file)
index 0000000..044f839
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh
+#  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 up hostname inside VE for PLD like system
+# 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 PLD)
+function set_hostname
+{
+       local cfgfile="$1"
+       local var=$2
+       local val=$3
+
+       [ -z "${val}" ] && return 0
+       put_param "${cfgfile}" "${var}" "${val}"
+
+       hostname "${val}"
+}
+
+change_hostname /etc/hosts "${HOSTNM}" "${IP_ADDR}"
+set_hostname /etc/sysconfig/network HOSTNAME "${HOSTNM}"
+
+exit 0
+
diff --git a/pld.conf b/pld.conf
new file mode 100644 (file)
index 0000000..52cdc54
--- /dev/null
+++ b/pld.conf
@@ -0,0 +1,107 @@
+#  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 is a distribution configuration file template.
+# This configuration file is meant to run specific actions
+# depending on the Linux version the VE is running.
+#
+# After an action is initiated, it requests vzctl to read the configuration on the basis
+# of the DISTRIBUTION or (if not present) on the OSTEMPLATE variable in the VE
+# configuration file. In case an unknown distribution version has been found,
+# the default configuration file is used for this distribution.
+# If no configuration file was found, the default.conf file is used.
+#
+
+# This script is launched inside a VE on executing the following commands:
+#      vzctl start VEID
+#      vzctl set VEID --ipadd <ip>
+#
+# The script is used to configure the network settings
+# on the VE startup or on the IP address(es) assignment.
+# The parameters are passed to the corresponding environment variables.
+# Required parameters:
+#   IP_ADDR    - the IP address(es) to be added to the VE
+#                 (the space is used to separate several IP addresses)
+# Optional parameters:
+#   VE_STATE   - the state of the VE; can be either "starting" or "running"
+#   IPDELALL   - deletes all old interfaces
+#
+ADD_IP=pld-add_ip.sh
+
+# This script is launched inside a VE on executing the following commands:
+#      vzctl set VEID --ipdel <ip>
+#      vzctl set VEID --ipdel <all>
+#
+# The script is used to delete an existing IP address(es).
+# The parameters are passed to the corresponding environment variables.
+# Required parameters:
+#   IP_ADDR    - the IP addresses to be deleted from the VE
+#              (the space is used to separate several IP addresses)
+# Optional parameters:
+#   IPDELALL   - deletes all existing IP addresses
+#
+DEL_IP=pld-del_ip.sh
+
+# This script is launched inside a VE on executing the following command:
+#      vzctl set VEID --hostname <name>
+#
+# The script is used to configure the hostname of the VE.
+# The parameters are passed to the corresponding environment variables.
+# Required parameters:
+#   HOSTNM     - the hostname of the VE
+#
+SET_HOSTNAME=pld-set_hostname.sh
+
+# This script is launched inside a VE on executing the following command:
+#      vzctl set VEID --searchdomain <domain> --nameserver <ip>
+#
+# The script is used to configure DNS parameters in the /etc/resolv.conf file.
+# The parameters are passed to the corresponding environment variables.
+# Optional parameters:
+#   SEARCHDOMAIN- Sets a search domain(s) for the VE. Modifies the /etc/resolv.conf file.
+#   NAMESERVER - Sets a name server(s) for the VE. Modifies the /etc/resolv.conf file.
+#
+SET_DNS=set_dns.sh
+
+# This script is launched inside a VE on executing the following command:
+#      vzctl set VEID --userpasswd <user:passwd>
+#
+# The script is used to add a new user or change the current password.
+# The parameters are passed to the corresponding environment variables.
+# Required parameters:
+#   USERPW  - Sets a new password for the VE user. If the user does not exist,
+#              the script creates a new user with the specified password.
+#
+SET_USERPASS=set_userpass.sh
+
+# This script is launched inside a VE on executing the following command:
+#      vzctl set VEID --quotaugidlimit <num>
+#
+# The script is used to set up second level quota.
+# The parameters are passed to the corresponding environment variables.
+# Required parameters:
+#   MINOR      - the root device minor number
+#   MAJOR      - the root device major number
+SET_UGID_QUOTA=set_ugid_quota.sh
+
+# This script is launched on the Hardware Node after the VE creation:
+#      vzctl create VEID
+#
+# The script is used to perform certain postcreate tasks.
+# The parameters are passed to the corresponding environment variables.
+# Required parameters:
+#   VE_ROOT    - the root path of the VE
+POST_CREATE=postcreate.sh
diff --git a/vz-pld.in b/vz-pld.in
new file mode 100644 (file)
index 0000000..2061631
--- /dev/null
+++ b/vz-pld.in
@@ -0,0 +1,507 @@
+#!/bin/sh
+#  Copyright (C) 2000-2009, 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
+#
+#
+# OpenVZ startup script, used for redhat and debian related distributions.
+
+###
+# chkconfig: 2345 96 88
+# description: OpenVZ startup script.
+###
+
+### BEGIN INIT INFO
+# Provides: vz
+# Required-start: $network $remote_fs $syslog
+# Required-stop:  $network $remote_fs $syslog
+# Should-Start:  sshd vzeventd
+# Should-Stop:  sshd vzeventd
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: OpenVZ startup script
+# Description: OpenVZ startup script.
+### END INIT INFO
+
+
+# This line is needed to cheat /etc/init.d/rc who expects action word
+
+. /etc/rc.d/init.d/functions
+. @VZLIBDIR@/initd-functions
+
+VZQUOTA=@SBINDIR@/vzquota
+CONFIG_DIR=@PKGCONFDIR@/conf
+LOCKFILE=/var/lock/subsys/vz_lock
+SUBSYS_VZ=/var/lock/subsys/vz
+VESTAT=/proc/vz/vestat
+VZDEV=venet0
+PRELOAD_MODULES=
+MODULES=
+MODULES_OTHER=
+NET_MODULES=
+IPT_MODULES=
+
+if [ "${MODULES_DISABLED}" != "yes" ]; then
+       PRELOAD_MODULES="af_packet"
+       MODULES="vzmon vzdquota vzdev"
+       CPT_MODULES="vzcpt vzrst"
+       MODULES_OTHER="vzcompat ${CPT_MODULES}"
+       VNET_MODULES="vznetdev vznet"
+       VETH_MODULES="vzethdev"
+       NET_MODULES="${VNET_MODULES} ${VETH_MODULES}"
+       if [ "${VZWDOG}" = "yes" ]; then
+               MODULES="${MODULES} vzwdog"
+       fi
+       IPT_MODULES="ip_tables ${IPTABLES} xt_tcpudp"
+       if [ "${IPV6}" = "yes" ]; then
+               IPT_MODULES="${IPT_MODULES} ${IP6TABLES}"
+       fi
+       VZFS_MODULES="simfs"
+fi
+
+
+VEINFO=""
+RETVAL=0
+# Number of the containers to stop in parallel.
+# In case of empty value the number of CTs is calculated as 'num_cpu * 4'
+PARALLEL=
+cd /
+
+check_kernel()
+{
+       if ! test -d /proc/vz ; then
+               fail
+               print_warning "Running kernel is not OpenVZ kernel."
+               exit 1
+       fi
+}
+
+get_kernel_version()
+{
+       [ ! -z "$KERNEL_MAJOR" ] && return
+
+       local ver=$(uname -r)
+       local kernel=$(echo $ver | sed s/[-+].*//)
+       KERNEL_MAJOR=$(echo $kernel | awk -F . '{print $1}')
+       KERNEL_MINOR=$(echo $kernel | awk -F . '{print $2}')
+       KERNEL_PATCHLEVEL=$(echo $kernel | awk -F . '{print $3}')
+}
+
+check_kernel_config()
+{
+       test -r /proc/config.gz || return 0
+
+       local conf opt err=0
+       local opt_must="SIM_FS VE VE_CALLS VZ_GENCALLS"
+       get_kernel_version
+       # For kernels >= 2.6.9 VZ_DEV must be set.
+       test "${KERNEL_MINOR}" -ge 6 &&
+               test "${KERNEL_PATCHLEVEL}" -gt 9 &&
+                       opt_must="${opt_must} VZ_DEV"
+#      local opt_rec="SCHED_VCPU FAIRSCHED VZ_QUOTA VZ_QUOTA_UGID VE_NETDEV VE_ETHDEV
+#                      VE_IPTABLES VZ_CHECKPOINT VZ_WDOG"
+
+       conf="`zcat /proc/config.gz 2>/dev/null | grep -E -v '^#|^$'`"
+
+       for opt in $opt_must; do
+               if ! echo "$conf" 2>/dev/null | grep -q "$opt="; then
+                       show "ERROR: Missing kernel config option: CONFIG_$opt"
+                       err=1
+               fi
+       done
+       if [ $err != 0 ]; then
+               fail
+               print_warning "Please recompile your kernel."
+               exit 1
+       fi
+}
+
+get_parallel()
+{
+       [ -n "${PARALLEL}" ] && return
+       PARALLEL=`awk '
+BEGIN { num=0; }
+$1 == "processor" { num++; }
+END { print num * 4; }' /proc/cpuinfo`
+}
+
+get_veinfo()
+{
+       if [ -f /proc/vz/veinfo ]; then
+               VEINFO=/proc/vz/veinfo
+       elif [ -f /proc/veinfo ]; then
+               VEINFO=/proc/veinfo
+       elif [ ! -f $VESTAT ]; then
+               return 1
+       fi
+       return 0
+}
+
+is_running()
+{
+       get_veinfo || return 1
+       [ -f $SUBSYS_VZ ] || return 1
+}
+
+status()
+{
+       check_kernel
+
+       if is_running; then
+               nls "OpenVZ is running..."
+               return 0
+       else
+               nls "OpenVZ is stopped."
+               return 3
+       fi
+}
+
+start_net()
+{
+       local mod
+
+       # load all kernel modules needed for containers networking
+       for mod in ${NET_MODULES}; do
+               modprobe ${mod} 2>/dev/null
+       done
+
+       if ip addr list | grep -q "venet0:.*UP" 2>/dev/null; then
+               return 0
+       fi
+
+       get_veinfo
+       if [ -z "$VEINFO" ]; then
+               return 0
+       fi
+       show "Bringing up interface $VZDEV"
+       busy
+       ok
+       ip link set $VZDEV up
+
+       ip addr add 0.0.0.0/0 dev $VZDEV
+       if [ "${IPV6}" = "yes" ]; then
+               ip -6 addr add fe80::1/128 dev $VZDEV
+       fi
+       sysctl -q -w net.ipv4.conf.$VZDEV.send_redirects=0
+       if [ "$(sysctl -n -e net.ipv4.ip_forward)" != "1" ]; then
+               print_warning "Warning ! IP forwarding is not enabled !"
+       fi
+}
+
+stop_net()
+{
+       local mod
+
+       if ip addr list | grep -q "venet0:.*UP" 2>/dev/null; then
+               show "Bringing down interface $VZDEV"
+               ip link set $VZDEV down
+               print_result
+       fi
+       for mod in ${NET_MODULES}; do
+               /sbin/modprobe -r ${mod} > /dev/null 2>&1
+       done
+}
+
+setup_ve0()
+{
+       if test -z "${VE0CPUUNITS}"; then
+               echo "Warning: VE0CPUUNITS is not set in ${VZCONF}; using value of 1000"
+               VE0CPUUNITS=1000
+       fi
+       msg=`${VZCTL} set 0 --cpuunits ${VE0CPUUNITS} 2>&1`
+       if [ $? -ne 0 ]; then
+               fail
+               print_warning "vzctl set 0 --cpuunits ${VE0CPUUNITS} failed: $msg"
+       fi
+
+       if ! test -f "${CONFIG_DIR}/0.conf"; then
+               return
+       fi
+       if ! grep -q '^ONBOOT=yes\|^ONBOOT=\"yes\"' ${CONFIG_DIR}/0.conf;
+       then
+               return
+       fi
+       show "Configure node UB resources: "
+       msg=`$VZCTL set 0 --reset_ub 2>&1`
+       print_result "$msg"
+}
+
+start_ves()
+{
+       local veid
+       local velist
+       local msg
+       local need_restart
+
+       need_restart=""
+       velist=$(vzlist -aH -octid,onboot -s-bootorder |
+               awk '$2 == "yes" {print $1}')
+       sysctl -q -w net.ipv4.route.src_check=0
+       for veid in $velist; do
+               [ "${veid}" = "0" ] && continue
+               show "Starting CT ${veid}"
+               if [ "x${VZFASTBOOT}" = "xyes" -a "x${DISK_QUOTA}" = "xyes" ];
+               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`
+               print_result "$msg"
+       done 
+       for veid in ${need_restart}; do
+               msg_stopping "CT ${veid}: "
+               busy
+               ok
+               $VZCTL stop ${veid} 2>&1 >/dev/null 2>&1
+               print_result
+               msg_starting "CT ${veid}: "
+               busy
+               ok
+               msg=`$VZCTL start ${veid} 2>&1`
+               print_result 
+       done
+}
+
+stop_ves()
+{
+       local veid
+       local velist
+       local msg
+       local m
+       local mounts
+       local fail
+       local iter
+       local quota
+       local pids
+
+       if get_veinfo; then
+               get_parallel
+               for i in 0 1 2; do
+                       iter=0;
+                       pids=
+                       velist=`awk '$1 != "VEID" && $1 != "Version:" {print $1}' ${VESTAT}`
+                       for veid in $velist; do
+                               msg_stopping "CT $veid"
+                               busy
+                               echo
+                               # Set fairsched parameters to maximum so
+                               # CT will stop fast
+                               $VZCTL set $veid --cpuunits 2000 --cpulimit 0 >/dev/null 2>&1
+                               $VZCTL --skiplock stop $veid >/dev/null 2>&1 &
+                               pids="$pids $!"
+                               iter=$(($iter+1))
+                               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 test $iter -lt 5 -a $fail -ne 0; do
+               fail=0
+               mounts=`awk '{if ($3=="simfs") print $2}' /proc/mounts`
+               for m in $mounts; do
+                       show "Unmounting CT area "
+                       echo -n $m
+                       msg=`umount $m 2>&1`
+                       if [ $? -eq 0 ]; then
+                               ok
+                       else
+                               fail
+                               print_warning "$msg"
+                               fail=$((fail+1))
+                               fuser -k -m ${m} > /dev/null 2>&1
+                       fi
+               done
+               iter=$(($iter+1))
+       done
+       # turn quota off
+       quota=`awk -F: '/^[0-9]+:/{print $1}' /proc/vz/vzquota 2>/dev/null`
+       for m in ${quota}; do
+               show "Turn quota off for CT "
+               echo -n $m
+               msg=`vzquota off ${m} 2>&1`
+               print_result "$msg"
+       done
+}
+
+lockfile()
+{
+       local TEMPFILE="${1}.$$"
+       local LOCKFILE="${1}"
+
+       trap -- "rm -f ${LOCKFILE} ${TEMPFILE}" EXIT
+
+       echo $$ > ${TEMPFILE} 2> /dev/null || {
+               echo "Can't write to ${TEMPFILE}"
+       }
+       ln ${TEMPFILE} ${LOCKFILE} >/dev/null 2>&1 && {
+               rm -f ${TEMPFILE};
+               return 0;
+       }
+       kill -0 `cat $LOCKFILE` >/dev/null 2>&1 && {
+               return 1;
+       }
+       ln ${TEMPFILE} ${LOCKFILE} >/dev/null 2>&1 && {
+               rm -f ${TEMPFILE};
+               return 0;
+       }
+       rm -f ${LOCKFILE}
+       echo $$ > ${LOCKFILE}
+       return 0
+}
+
+start()
+{
+       local veid
+       local velist
+       local msg
+       local mod
+
+       check_kernel
+       check_kernel_config
+
+       if ! lockfile $LOCKFILE; then
+               show "OpenVZ is locked"
+               fail
+               return 1
+       fi
+       if [ -f ${SUBSYS_VZ} ]; then
+               nls "OpenVZ already running"
+               return 1
+       fi
+       msg_starting "OpenVZ"
+       if [ "$?" = "0" ]; then
+               ok
+       else
+               fail
+       fi
+       load_modules "${IPT_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
+                       fail
+                       print_warning "failed to load module ${mod}"
+                       return $RETVAL
+               fi
+       done
+       load_modules "${MODULES_OTHER} ${VZFS_MODULES}"
+       show "loading OpenVZ modules"
+       ok
+
+       if [ ! -e /dev/vzctl ]; then
+               # On most modern distros udev will create a device for you,
+               # while on the old distros /dev/vzctl comes with vzctl rpm.
+               # So the below mknod call is probably not needed at all.
+               /bin/mknod -m 600 /dev/vzctl c 126 0 > /dev/null 2>&1
+               RETVAL=$?
+               if [ $RETVAL -ne 0 ]; then
+                       fail
+                       print_warning "creating /dev/vzctl"
+                       return $RETVAL
+               fi
+       fi
+
+       start_net
+       setup_ve0
+       start_ves
+
+       rm -f $LOCKFILE
+       touch $SUBSYS_VZ
+}
+
+stop()
+{
+       local mod
+
+       # Avoid stop action inside a CT, check we are in CT0
+       if ! egrep -q '^[[:space:]]*0:[[:space:]]' \
+                       /proc/user_beancounters; then
+               print_failure "Looks like we are inside a container!"
+               RETVAL=1
+               return 1
+       fi
+
+       if ! lockfile $LOCKFILE; then
+               show "OpenVZ is locked"
+               fail
+               RETVAL=1
+               return 1
+       fi
+
+       stop_ves
+       stop_net
+       msg_stopping "OpenVZ"
+       for mod in ${MODULES_OTHER} ${MODULES} ${PRELOAD_MODULES} ${IPT_MODULES} ${VZFS_MODULES}; do
+               /sbin/modprobe -r ${mod} > /dev/null 2>&1
+       done
+       rm -f $LOCKFILE
+       rm -f $SUBSYS_VZ
+       print_result
+}
+
+load_modules()
+{
+       local modules=$1
+       local mod
+
+       for mod in ${modules}; do
+               if /sbin/lsmod | grep -qw ${mod}; then
+                       continue
+               fi
+               /sbin/modprobe ${mod} >/dev/null 2>&1
+       done
+}
+
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
+       ;;
+  restart|force-reload)
+       stop
+       start
+       ;;
+  status)
+       status
+       RETVAL=$?
+       ;;
+  *)
+       echo "Usage: $0 {start|stop|status|restart|force-reload}"
+       exit 1
+esac
+
+exit $RETVAL
diff --git a/vzctl-pld.patch b/vzctl-pld.patch
new file mode 100644 (file)
index 0000000..db1b9f7
--- /dev/null
@@ -0,0 +1,229 @@
+diff -Nru vzctl-3.0.25.1.orig/bin/Makefile.am vzctl-3.0.25.1/bin/Makefile.am
+--- vzctl-3.0.25.1.orig/bin/Makefile.am        2010-12-24 12:45:38.000000000 +0100
++++ vzctl-3.0.25.1/bin/Makefile.am     2011-01-03 10:44:51.000000000 +0100
+@@ -48,6 +48,27 @@
+               echo " ***************************************************"; \
+               echo; \
+       fi
++install-pld-from-spec:
++
++install-pld:
++      @if [ ! -e "$(DESTDIR)/sbin/ifup-local" -a \
++                      ! -L "$(DESTDIR)/sbin/ifup-local" ]; then \
++              $(MKDIR_P) "$(DESTDIR)/sbin"; \
++              $(LN_S) "..$(sbindir)/vzifup-post" \
++                      "$(DESTDIR)/sbin/ifup-local"; \
++      elif readlink "$(DESTDIR)/sbin/ifup-local" | \
++                      fgrep -q vzifup-post; then \
++              true; \
++      else \
++              echo; \
++              echo " ***************************************************"; \
++              echo " WARNING: file $(DESTDIR)/sbin/ifup-local is present!"; \
++              echo " You have to manually edit the above file so that "; \
++              echo " it calls $(sbindir)/vzifup-post"; \
++              echo " ***************************************************"; \
++              echo; \
++      fi
++
+ install-suse:
+diff -Nru vzctl-3.0.25.1.orig/etc/dists/Makefile.am vzctl-3.0.25.1/etc/dists/Makefile.am
+--- vzctl-3.0.25.1.orig/etc/dists/Makefile.am  2010-12-24 12:45:35.000000000 +0100
++++ vzctl-3.0.25.1/etc/dists/Makefile.am       2011-01-03 10:44:51.000000000 +0100
+@@ -89,6 +89,9 @@
+       $(INSTALL_DATA) $(srcdir)/fedora-core.conf \
+               $(DESTDIR)$(distconfdir)/fedora.conf
++pld:
++      $(INSTALL_DATA) $(srcdir)/pld.conf $(DESTDIR)$(distconfdir)/pld.conf
++
+ gentoo:
+       $(INSTALL_DATA) $(srcdir)/gentoo.conf $(DESTDIR)$(distconfdir)/gentoo.conf
+@@ -169,6 +172,7 @@
+                    debian \
+                    fc \
+                    fedora \
++                   pld \
+                    gentoo \
+                    mandrake \
+                    owl \
+diff -Nru vzctl-3.0.25.1.orig/etc/init.d/initd-functions.in vzctl-3.0.25.1/etc/init.d/initd-functions.in
+--- vzctl-3.0.25.1.orig/etc/init.d/initd-functions.in  2010-12-24 12:45:35.000000000 +0100
++++ vzctl-3.0.25.1/etc/init.d/initd-functions.in       2011-01-05 16:17:46.000000000 +0100
+@@ -16,9 +16,12 @@
+ # Source function library.
+ if [ -r /etc/init.d/functions ]; then
+-      source /etc/init.d/functions
+       if [ -r /etc/redhat-release ] || [ -r /etc/centos-release ]; then
++              source /etc/init.d/functions
+               DISTR=redhat
++      elif [ -r /etc/pld-release ]; then
++              . /etc/init.d/functions
++              DISTR=pld
+       fi
+ elif [ -r /etc/rc.status ]; then
+       source /etc/rc.status
+@@ -34,6 +37,8 @@
+ {
+       if [ "$DISTR" = "redhat" ]; then
+               echo_success
++      elif [ "$DISTR" = "pld" ]; then
++              ok
+       else
+               echo -n "$rc_done"
+       fi
+@@ -42,9 +47,10 @@
+ print_failure()
+ {
+-      echo -n "$1"
+       if [ "$DISTR" = "redhat" ]; then
+               failure $"$1"
++      elif [ "$DISTR" = "pld" ]; then
++              fail
+       else
+               echo -n "$rc_failed"
+       fi
+@@ -56,6 +62,8 @@
+       if [ "$DISTR" = "redhat" ]; then
+               echo -n "$1"
+               warning $"$1"
++      elif [ "$DISTR" = "pld" ]; then
++              nls -n "$1"
+       else
+               echo -n "- Warning: $1 "
+       fi
+@@ -67,15 +75,23 @@
+ print_result()
+ {
+       if [ $? -eq 0 ] ; then
+-              print_success
++              if [ "$DISTR" = "pld" ]; then
++                      ok
++              else
++                      print_success
++              fi
+       else
+-              print_failure "$1"
++              if  [ "$DISTR" = "pld" ]; then
++                      fail
++              else
++                      print_failure "$1"
++              fi
+       fi
+ }
+ __echo()
+ {
+-      if [ "$DISTR" = "redhat" ]; then
++      if [ "$DISTR" = "redhat" ] || [ "$DISTR" = "pld" ]; then
+               echo -n $"$1"
+       else
+               echo -n "$1"
+@@ -85,7 +101,7 @@
+ vzdaemon_start()
+ {
+       case $DISTR in
+-         redhat)
++         redhat|pld)
+               daemon $*
+               ;;
+          suse)
+@@ -102,7 +118,7 @@
+ vzdaemon_stop()
+ {
+       case $DISTR in
+-         redhat|suse)
++         redhat|suse|pld)
+               killproc $*
+               ;;
+          debian)
+@@ -119,7 +135,7 @@
+       shift
+       case $DISTR in
+-         redhat|suse)
++         redhat|suse|pld)
+               status $p
+               ;;
+          debian)
+diff -Nru vzctl-3.0.25.1.orig/etc/init.d/Makefile.am vzctl-3.0.25.1/etc/init.d/Makefile.am
+--- vzctl-3.0.25.1.orig/etc/init.d/Makefile.am 2010-12-24 12:45:34.000000000 +0100
++++ vzctl-3.0.25.1/etc/init.d/Makefile.am      2011-01-03 10:46:14.000000000 +0100
+@@ -15,7 +15,7 @@
+ #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ #
+-INITSCRIPTS = vz-redhat vz-gentoo vzeventd-redhat vzeventd-gentoo
++INITSCRIPTS = vz-redhat vz-gentoo vz-pld vzeventd-pld vzeventd-redhat vzeventd-gentoo
+ vzlib_DATA = initd-functions
+ EXTRA_DIST = $(INITSCRIPTS:%=%.in) $(vzlib_DATA:%=%.in)
+@@ -29,6 +29,12 @@
+       $(INSTALL_SCRIPT) vz-redhat $(DESTDIR)$(initddir)/vz
+       $(INSTALL_SCRIPT) vzeventd-redhat $(DESTDIR)$(initddir)/vzeventd
++install-pld: vz-pld vzeventd-pld
++      $(mkinstalldirs) $(DESTDIR)$(initddir)
++      $(INSTALL_SCRIPT) vz-pld $(DESTDIR)$(initddir)/vz
++      $(INSTALL_SCRIPT) vzeventd-pld $(DESTDIR)$(initddir)/vzeventd
++
++
+ install-suse: install-redhat
+ install-debian: install-redhat
+diff -Nru vzctl-3.0.25.1.orig/etc/Makefile.am vzctl-3.0.25.1/etc/Makefile.am
+--- vzctl-3.0.25.1.orig/etc/Makefile.am        2010-12-24 12:45:34.000000000 +0100
++++ vzctl-3.0.25.1/etc/Makefile.am     2011-01-03 10:44:51.000000000 +0100
+@@ -34,6 +34,11 @@
+ install-data-local:
+       $(mkinstalldirs) $(DESTDIR)$(namesdir)
++install-pld-from-spec: install-pld
++install-pld:
++      $(MAKE) $(AM_MAKEFLAGS) -C init.d $@
++      $(MAKE) $(AM_MAKEFLAGS) -C network-scripts $@
++
+ install-redhat-from-spec: install-redhat
+ install-redhat:
+       $(MAKE) $(AM_MAKEFLAGS) -C init.d $@
+diff -Nru vzctl-3.0.25.1.orig/etc/network-scripts/Makefile.am vzctl-3.0.25.1/etc/network-scripts/Makefile.am
+--- vzctl-3.0.25.1.orig/etc/network-scripts/Makefile.am        2010-12-24 12:45:35.000000000 +0100
++++ vzctl-3.0.25.1/etc/network-scripts/Makefile.am     2011-01-03 10:44:51.000000000 +0100
+@@ -38,3 +38,11 @@
+       for file in $(NETSDATA); do \
+               $(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(netsdir)/$$file; \
+       done
++install-pld: $(NETSSCRIPTS)
++      $(mkinstalldirs) $(DESTDIR)$(netsdir)
++      for file in $(NETSSCRIPTS); do \
++              $(INSTALL_SCRIPT) $$file $(DESTDIR)$(netsdir)/$$file; \
++      done
++      for file in $(NETSDATA); do \
++              $(INSTALL_DATA) $(srcdir)/$$file $(DESTDIR)$(netsdir)/$$file; \
++      done
+diff -Nru vzctl-3.0.25.1.orig/Makefile.am vzctl-3.0.25.1/Makefile.am
+--- vzctl-3.0.25.1.orig/Makefile.am    2010-12-24 12:45:32.000000000 +0100
++++ vzctl-3.0.25.1/Makefile.am 2011-01-03 10:44:51.000000000 +0100
+@@ -46,6 +46,7 @@
+       $(mkinstalldirs) $(DESTDIR)$(modulesdir)
+ DISTRO_TARGETS = \
++      install-pld \
+       install-redhat \
+       install-gentoo \
+       install-suse \
+@@ -53,7 +54,8 @@
+ DISTRO_TARGETS_ALL = \
+       $(DISTRO_TARGETS) \
+-      install-redhat-from-spec
++      install-redhat-from-spec \
++      install-pld-from-spec
+ $(DISTRO_TARGETS_ALL):
+       $(MAKE) $(AM_MAKEFLAGS) -C etc $@
index b9e176b5b60fb1b2b76cb166f6cc87b4d97c2a04..bd394d2d717dd7ac65db04ea0ce505db88b56088 100644 (file)
@@ -7,7 +7,16 @@ License:       GPL
 Group:         Base/Kernel
 Source0:       http://download.openvz.org/utils/vzctl/%{version}/src/%{name}-%{version}.tar.bz2
 # Source0-md5: 5798ea88d06afff1d6d1bbbfc45899f1
+Source1:       pld.conf
+Source2:       pld-add_ip.sh
+Source3:       pld-del_ip.sh
+Source4:       pld-set_hostname.sh
+Source5:       vz-pld.in
+Source6:       vzeventd-pld.in
+Patch0:                %{name}-pld.patch
 URL:           http://openvz.org/
+BuildRequires: autoconf
+BuildRequires: automake
 Requires:      %{name}-lib = %{version}-%{release}
 Requires(post,preun):  /sbin/chkconfig
 Requires:      rc-scripts
@@ -48,8 +57,14 @@ OpenVZ containers control API library.
 
 %prep
 %setup -q
+%patch0 -p1
+install %{SOURCE1} etc/dists
+install %{SOURCE2} %{SOURCE3} %{SOURCE4} etc/dists/scripts
+install %{SOURCE5} %{SOURCE6} etc/init.d
 
 %build
+%{__aclocal}
+%{__automake}
 %configure \
        --enable-bashcomp \
        --enable-logrotate \
@@ -59,11 +74,15 @@ OpenVZ containers control API library.
 
 %install
 rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT/etc/cron.d
+install -d $RPM_BUILD_ROOT/etc/{cron.d,rc.d/init.d,sysconfig/interfaces}
 
-%{__make} install install-redhat \
+%{__make} install install-pld \
+       vpsconfdir=/etc/sysconfig/vz-scripts \
        DESTDIR=$RPM_BUILD_ROOT
 
+%{__mv} $RPM_BUILD_ROOT/etc/init.d/vz* $RPM_BUILD_ROOT/etc/rc.d/init.d
+%{__mv} $RPM_BUILD_ROOT/etc/sysconfig/{network-scripts,interfaces}/ifcfg-venet0
+
 ln -s ../sysconfig/vz-scripts $RPM_BUILD_ROOT%{_configdir}/conf
 ln -s ../vz/vz.conf $RPM_BUILD_ROOT/etc/sysconfig/vz
 
@@ -100,10 +119,9 @@ fi
 %doc ChangeLog
 %config(noreplace) /etc/bash_completion.d/%{name}.sh
 %attr(640,root,root) %ghost /etc/cron.d/vz
-#      %attr(754,root,root) /etc/rc.d/init.d/vz*
+%attr(754,root,root) /etc/rc.d/init.d/vz*
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/logrotate.d/%{name}
 %attr(755,root,root) /etc/sysconfig/network-scripts/if*-venet
-       %{_netdir}/ifcfg-venet0
 %attr(640,root,root) %config(noreplace,missingok) %verify(not md5 mtime size) /etc/sysconfig/interfaces/ifcfg-venet0
 %dir /etc/sysconfig/vz-scripts
 %config(missingok) /etc/sysconfig/vz-scripts/ve-*.conf-sample
@@ -114,12 +132,13 @@ fi
 %dir %{_distconfdir}
 %config(noreplace) %verify(not md5 mtime size) %{_distconfdir}/default
 %config(noreplace) %{_distconfdir}/distribution.conf-template
-%config(noreplace) %{_distconfdir}/*conf
+%config(noreplace) %{_distconfdir}/*.conf
 %dir %{_distscriptdir}
 %attr(755,root,root) %config(noreplace) %{_distscriptdir}/*.sh
 %config(noreplace) %{_distscriptdir}/functions
 %{_configdir}/names
-%config(noreplace) %verify(not md5 mtime size) %{_configdir}/*.conf
+%config(noreplace) %verify(not md5 mtime size) %{_configdir}/*conf
+%attr(755,root,root) /sbin/ifup-local
 %attr(755,root,root) %{_sbindir}/*send
 %attr(755,root,root) %{_sbindir}/vz*
 %dir /vz
diff --git a/vzeventd-pld.in b/vzeventd-pld.in
new file mode 100644 (file)
index 0000000..b506406
--- /dev/null
@@ -0,0 +1,106 @@
+#!/bin/bash
+#
+# vzeventd     This shell script takes care of starting and stopping
+#               vzeventd daemon for OpenVZ.
+#
+# chkconfig: 2345 95 89
+# description: vzeventd is OpenVZ events daemon. \
+# It takes care of events sent by the OpenVZ kernel and performs required \
+# actions associated with those events.
+
+### BEGIN INIT INFO
+# Provides: vzeventd
+# Required-start: $remote_fs
+# Required-stop: $remote_fs
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# X-Start-Before: vz
+# X-Stop-After: vz
+# Short-Description: start and stop vzeventd
+# Description: vzeventd is the OpenVZ events daemon.
+#              It takes care of events sent by the OpenVZ kernel
+#              and performs required actions associated with those events.
+### END INIT INFO
+
+. @VZLIBDIR@/initd-functions
+
+prog=vzeventd
+lockfile=$VARLOCK/$prog
+
+load_module() {
+       modprobe vzevent reboot_event=1
+}
+
+check() {
+       local param=/sys/module/vzevent/parameters/reboot_event
+
+       show "Checking vzevent kernel module"
+
+       if ! lsmod | fgrep -qw vzevent; then
+               fail
+               return 1
+       fi
+       if ! cat $param | fgrep -qw 1; then
+               fail
+               print_warning "vzevent module should be loaded with reboot_event=1 parameter"
+               return 1
+       fi
+       ok
+       return 0
+}
+
+start() {
+       [ "$EUID" != "0" ] && exit 4
+       [ -x @SBINDIR@/vzeventd ] || exit 5
+       [ -r /etc/sysconfig/vzeventd ] && . /etc/sysconfig/vzeventd
+       [ -r /etc/default/vzeventd ] && . /etc/default/vzeventd
+
+       [ -f $lockfile ] && exit 0 # Already running
+
+       load_module
+       check || exit 1
+
+       msg_starting "$prog"
+       vzdaemon_start $prog $OPTIONS
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch $lockfile
+       return $RETVAL
+}
+
+stop() {
+       [ "$EUID" != "0" ] && exit 4
+       msg_stopping "$prog"
+       vzdaemon_stop $prog
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && rm -f $lockfile
+       return $RETVAL
+}
+
+# See how we were called.
+case "$1" in
+   start)
+       start
+       ;;
+   stop)
+       stop
+       ;;
+   status)
+       vzdaemon_status $prog
+       ;;
+   restart|force-reload)
+       stop
+       start
+       ;;
+   try-restart|condrestart)
+       if vzdaemon_status $prog >/dev/null 2>&1; then
+               stop
+               start
+       fi
+       ;;
+   reload)
+       exit 3
+       ;;
+   *)
+       echo $"Usage: $0 {start|stop|status|restart|try-restart|force-reload}"
+       exit 2
+esac
This page took 0.13314 seconds and 4 git commands to generate.