Author: gotar Date: Fri Jan 28 01:07:00 2011 GMT Module: packages Tag: HEAD ---- Log message: - added PLD resources from Ĺukasz Chrustek <[email protected]>
---- Files affected: packages/vzctl: vzctl.spec (1.8 -> 1.9) , pld-add_ip.sh (NONE -> 1.1) (NEW), pld-del_ip.sh (NONE -> 1.1) (NEW), pld-set_hostname.sh (NONE -> 1.1) (NEW), pld.conf (NONE -> 1.1) (NEW), vz-pld.in (NONE -> 1.1) (NEW), vzctl-pld.patch (NONE -> 1.1) (NEW), vzeventd-pld.in (NONE -> 1.1) (NEW) ---- Diffs: ================================================================ Index: packages/vzctl/vzctl.spec diff -u packages/vzctl/vzctl.spec:1.8 packages/vzctl/vzctl.spec:1.9 --- packages/vzctl/vzctl.spec:1.8 Fri Jan 28 01:19:35 2011 +++ packages/vzctl/vzctl.spec Fri Jan 28 02:06:54 2011 @@ -8,7 +8,16 @@ 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 @@ -49,8 +58,14 @@ %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 \ @@ -60,11 +75,15 @@ %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 @@ -101,10 +120,9 @@ %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 @@ -115,12 +133,13 @@ %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 @@ -141,6 +160,9 @@ All persons listed below can be reached at <cvs_login>@pld-linux.org $Log$ +Revision 1.9 2011/01/28 01:06:54 gotar +- added PLD resources from Ĺukasz Chrustek <[email protected]> + Revision 1.8 2011/01/28 00:19:35 gotar - more %config and %verify flags ================================================================ Index: packages/vzctl/pld-add_ip.sh diff -u /dev/null packages/vzctl/pld-add_ip.sh:1.1 --- /dev/null Fri Jan 28 02:07:00 2011 +++ packages/vzctl/pld-add_ip.sh Fri Jan 28 02:06:54 2011 @@ -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 ================================================================ Index: packages/vzctl/pld-del_ip.sh diff -u /dev/null packages/vzctl/pld-del_ip.sh:1.1 --- /dev/null Fri Jan 28 02:07:00 2011 +++ packages/vzctl/pld-del_ip.sh Fri Jan 28 02:06:54 2011 @@ -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 ================================================================ Index: packages/vzctl/pld-set_hostname.sh diff -u /dev/null packages/vzctl/pld-set_hostname.sh:1.1 --- /dev/null Fri Jan 28 02:07:00 2011 +++ packages/vzctl/pld-set_hostname.sh Fri Jan 28 02:06:54 2011 @@ -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 + ================================================================ Index: packages/vzctl/pld.conf diff -u /dev/null packages/vzctl/pld.conf:1.1 --- /dev/null Fri Jan 28 02:07:00 2011 +++ packages/vzctl/pld.conf Fri Jan 28 02:06:54 2011 @@ -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 ================================================================ Index: packages/vzctl/vz-pld.in diff -u /dev/null packages/vzctl/vz-pld.in:1.1 --- /dev/null Fri Jan 28 02:07:00 2011 +++ packages/vzctl/vz-pld.in Fri Jan 28 02:06:54 2011 @@ -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 <<Diff was trimmed, longer than 597 lines>> ---- CVS-web: http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/vzctl/vzctl.spec?r1=1.8&r2=1.9&f=u _______________________________________________ pld-cvs-commit mailing list [email protected] http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit
