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 NETFILE=/etc/sysconfig/network
27 function setup6_network
29 [ "${IPV6}" != "yes" ] && return 0
31 if ! grep -q 'IPV6INIT="yes"' ${IFCFG}; then
32 put_param ${IFCFG} IPV6INIT yes
34 if ! grep -q 'IPV6_NETWORKING=yes' ${NETFILE}; then
35 put_param ${NETFILE} IPV6_NETWORKING yes
36 put_param ${NETFILE} IPV6_GLOBALROUTEDEV ${VENET_DEV}
41 function get_aliases()
45 [ -f ${IFCFG} ] || return
46 IFNUMLIST=`grep -e "^IPADDR" ${IFCFG} | sed 's/^IPADDR\(.*\)=.*/\1/'`
49 function init_config()
57 NETMASK=255.255.255.255
58 IPADDR=127.0.0.1" > ${IFCFG} ||
59 error "Can't write to file ${IFCFG}" ${VZ_FS_NO_DISK_SPACE}
61 put_param $NETFILE NETWORKING yes
62 put_param $NETFILE GATEWAY ${FAKEGATEWAY}
68 if [ ! -f ${HOSTFILE} ]; then
69 echo "127.0.0.1 localhost.localdomain localhost" > $HOSTFILE
74 function create_config()
79 #LABEL_${ifnum}=${ifnum}" >> ${IFCFG} ||
80 echo "IPADDR${ifnum}=${ip}" >> ${IFCFG} || error "Can't write to file ${IFCFG}" ${VZ_FS_NO_DISK_SPACE}
89 if [ "x${VE_STATE}" = "xstarting" ]; then
90 if [ -n "${IP_ADDR}" ]; then
92 elif grep -q "^IPADDR" ${IFCFG}; then
95 elif [ "x${IPDELALL}" = "xyes" ]; then
97 elif [ ! -f "${IFCFG}" ]; then
102 for ipm in ${IP_ADDR}; do
105 if grep -q -w "${_IP}" ${IFCFG}; then
108 while test -z ${found}; do
110 if ! echo "${IFNUMLIST}" | grep -w -q "${ifnum}"; then
114 if echo ${_IP} | grep -q ':' ; then
117 create_config ${_IP} ${ifnum}
119 if [ "x${VE_STATE}" = "xrunning" ]; then
120 ifdown $VENET_DEV >/dev/null 2>&1
121 ifup $VENET_DEV >/dev/null 2>&1