2 # Copyright (C) 2000-2008, Parallels, Inc. 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
19 # Adds IP address(es) in a container running SuSE.
22 IFCFG_DIR=/etc/sysconfig/interfaces/
23 IFCFG=${IFCFG_DIR}/ifcfg-${VENET_DEV}
24 #ROUTES=${IFCFG_DIR}/ifroute-${VENET_DEV}
27 function get_aliases()
31 [ -f ${IFCFG} ] || return
32 IFNUMLIST=`grep -e "^IPADDR" ${IFCFG} | sed 's/^IPADDR\(.*\)=.*/\1/'`
35 function init_config()
43 NETMASK=255.255.255.255
44 IPADDR=127.0.0.1" > ${IFCFG} ||
45 error "Can't write to file ${IFCFG}" ${VZ_FS_NO_DISK_SPACE}
48 if [ ! -f ${HOSTFILE} ]; then
49 echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE
53 function create_config()
58 #LABEL_${ifnum}=${ifnum}" >> ${IFCFG} ||
59 echo "IPADDR${ifnum}=${ip}" >> ${IFCFG} || error "Can't write to file ${IFCFG}" ${VZ_FS_NO_DISK_SPACE}
68 if [ "x${VE_STATE}" = "xstarting" ]; then
69 if [ -n "${IP_ADDR}" ]; then
71 elif grep -q "^IPADDR" ${IFCFG}; then
74 elif [ "x${IPDELALL}" = "xyes" ]; then
76 elif [ ! -f "${IFCFG}" ]; then
81 for ipm in ${IP_ADDR}; do
84 if grep -q -w "${_IP}" ${IFCFG}; then
87 while test -z ${found}; do
89 if ! echo "${IFNUMLIST}" | grep -w -q "${ifnum}"; then
93 create_config ${_IP} ${ifnum}
95 if [ "x${VE_STATE}" = "xrunning" ]; then
96 ifdown $VENET_DEV >/dev/null 2>&1
97 ifup $VENET_DEV >/dev/null 2>&1