2
# Copyright (C) 2000-2007 SWsoft. All rights reserved.
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
VZCONF=@PKGCONFDIR@/vz.conf
21
VEINFO=/proc/vz/veinfo
22
PROC_PROXY_TR=/proc/proxy/targets
27
test -f ${VZCONF} || exit 1
28
test -f @PKGLIBDIR@/scripts/vps-functions || exit 1
30
. @PKGLIBDIR@/scripts/vps-functions
34
# Get currently running VEs list
38
VE_RUN=`echo "${VES_INFO}" | awk '{if ($1 != 0) print $1}'`
42
# Get list of started VEs by vzctl
44
function get_prev_ve()
46
[ -d "${VE_STATE_DIR}" ] || return
47
VE_PREV=`ls ${VE_STATE_DIR} | grep -w -e "[0-9]*" 2>/dev/null`
52
# Get list of stopped VEs
54
function get_stopped_ve()
59
if [ -z "${VE_RUN}" ]; then
60
VE_STOPPED="${VE_PREV}"
62
VE_STOPPED=`echo -e "${VE_PREV}" | grep -w -v "${VE_RUN}"`
66
function get_ip_list()
71
[ -z "${veid}" ] && return
72
[ -f "${VE_STATE_DIR}/${veid}" ] || return
73
IP_ADDR=`cat ${VE_STATE_DIR}/${veid}`
76
function clear_ve_net()
81
[ -z "${VEID}" ] && return
84
[ -z "${LOGFILE}" ] || echo "`date --iso-8601=seconds` venetclean : VE $VEID : VE died, clear IPs: ${IP_ADDR}" >> ${LOGFILE}
85
for ip in ${IP_ADDR}; do
86
# clear IP if not used
87
if ! echo -e "${VES_INFO}" | grep -w "${ip}" >/dev/null 2>&1;
95
# If VZ is not running -- do nothing
96
# Fix for OpenVZ bug #107
97
test -f ${VEINFO} || exit 0
99
VES_INFO=`cat ${VEINFO} 2>/dev/null` || exit
101
for ve in ${VE_STOPPED}
104
rm -f ${VE_STATE_DIR}/${ve} >/dev/null 2>&1