]> git.pld-linux.org Git - packages/vzctl.git/blame - pld-del_ip.sh
- libtoolize?
[packages/vzctl.git] / pld-del_ip.sh
CommitLineData
88d20d00
TP
1#!/bin/bash
2# Copyright (C) 2000-2007 SWsoft. All rights reserved.
3#
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.
8#
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.
13#
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
17#
18#
19# This script deletes IP alias(es) inside VE for RedHat like systems.
20#
21# Parameters are passed in environment variables.
22# Required parameters:
23# IP_ADDR - IPs to delete, several addresses should be divided by space
24# Optional parameters:
25# IPDELALL - delete all ip addresses
26VENET_DEV=venet0
27VENET_DEV_CFG=ifcfg-${VENET_DEV}
28IFCFG_DIR=/etc/sysconfig/interfaces/
29IFCFG=${IFCFG_DIR}${VENET_DEV_CFG}
30
31# Function to delete IP address for PLD like systems
32function del_ip
33{
34 local ip
35 local filetodel
36 local file
37 local aliasid
38
39 [ -d ${IFCFG_DIR} ] || return 0
40 cd ${IFCFG_DIR} || return 0
41 if [ "x${IPDELALL}" = "xyes" ]; then
42 ifdown ${VENET_DEV} >/dev/null 2>&1
43 rm -f ${VENET_DEV_CFG} ${VENET_DEV_CFG}:* 2>/dev/null
44 del_param ${IFCFG} IPV6ADDR_SECONDARIES ""
45 return 0;
46 fi
47 for ip in ${IP_ADDR}; do
48 # IPV6 processing
49 if [ "${ip#*:}" != "${ip}" ]; then
50 del_param ${IFCFG} IPV6ADDR_SECONDARIES "${ip}\\/128"
51 ifconfig ${VENET_DEV} del ${ip}/128
52 continue
53 fi
54 # find and delete a file with this alias
55 filetodel=`grep -l "IPADDR=${ip}$" \
56 ${VENET_DEV_CFG}:* 2>/dev/null`
57 for file in ${filetodel}; do
58 rm -f "${file}"
59 aliasid=`echo ${file} | sed s/.*://g`
60 if [ -n "${aliasid}" ]; then
61 ifconfig ${VENET_DEV}:${aliasid} down >/dev/null 2>&1
62 fi
63 done
64 done
65}
66
67del_ip
68exit 0
69# end of script
This page took 0.077084 seconds and 4 git commands to generate.