~ubuntu-branches/ubuntu/karmic/vzctl/karmic

« back to all changes in this revision

Viewing changes to etc/dists/scripts/redhat-del_ip.sh

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2007-04-10 18:08:16 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070410180816-0uuzj9fnna7gmzxv
Tags: 3.0.16-4
Etch has been released which means that this version can be uploaded
to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
 
#  Copyright (C) 2000-2006 SWsoft. All rights reserved.
 
2
#  Copyright (C) 2000-2007 SWsoft. All rights reserved.
3
3
#
4
4
#  This program is free software; you can redistribute it and/or modify
5
5
#  it under the terms of the GNU General Public License as published by
22
22
# Required parameters:
23
23
#   IP_ADDR       - IPs to delete, several addresses should be divided by space
24
24
# Optional parameters:
25
 
#   IPDELALL      - deleet all ip addresses
 
25
#   IPDELALL      - delete all ip addresses
26
26
VENET_DEV=venet0
27
27
VENET_DEV_CFG=ifcfg-${VENET_DEV}
28
28
IFCFG_DIR=/etc/sysconfig/network-scripts/
 
29
IFCFG=${IFCFG_DIR}${VENET_DEV_CFG}
29
30
 
30
31
# Function to delete IP address for RedHat like systems
31
32
function del_ip()
38
39
        [ -d ${IFCFG_DIR} ] || return 0
39
40
        cd ${IFCFG_DIR} || return 0
40
41
        if [ "x${IPDELALL}" = "xyes" ]; then
41
 
                ifdown ${VENET_DEV}
42
 
                rm -rf ${VENET_DEV_CFG}:* >/dev/null 2>&1
43
 
                ifup ${VENET_DEV}
 
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 ""
44
45
                return 0;
45
46
        fi
46
47
        for ip in ${IP_ADDR}; do
 
48
                # IPV6 processing
 
49
                if [ "${ip#*:}" != "${ip}" ]; then
 
50
                        del_param ${IFCFG} IPV6ADDR_SECONDARIES "${ip}\\/128"
 
51
                        continue
 
52
                fi
47
53
                # find and delete a file with this alias
48
54
                filetodel=`grep -l "IPADDR=${ip}$" \
49
55
                        ${VENET_DEV_CFG}:* 2>/dev/null`
51
57
                        rm -f "${file}"
52
58
                        aliasid=`echo ${file} | sed s/.*://g`
53
59
                        if [ -n "${aliasid}" ]; then
54
 
                                ifconfig  ${VENET_DEV}:${aliasid} down >/dev/null 2>&1
 
60
                                ifconfig ${VENET_DEV}:${aliasid} down >/dev/null 2>&1
55
61
                        fi
56
62
                done
57
63
        done