wok-next annotate vzctl/stuff/slitaz-add_ip.sh @ rev 14051
catfish: fix build and force it to work with SliTaz
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue Feb 19 17:14:33 2013 +0000 (2013-02-19) |
parents | |
children |
rev | line source |
---|---|
erjo@8056 | 1 #!/bin/bash |
erjo@8056 | 2 # Adds IP address(es) in a container running Slitaz. |
erjo@8056 | 3 # |
erjo@8056 | 4 # This program is free software; you can redistribute it and/or modify |
erjo@8056 | 5 # it under the terms of the GNU General Public License as published by |
erjo@8056 | 6 # the Free Software Foundation; either version 2 of the License, or |
erjo@8056 | 7 # (at your option) any later version. |
erjo@8056 | 8 # |
erjo@8056 | 9 # This program is distributed in the hope that it will be useful, |
erjo@8056 | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
erjo@8056 | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
erjo@8056 | 12 # GNU General Public License for more details. |
erjo@8056 | 13 # |
erjo@8056 | 14 # You should have received a copy of the GNU General Public License |
erjo@8056 | 15 # along with this program; if not, write to the Free Software |
erjo@8056 | 16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
erjo@8056 | 17 # |
erjo@8056 | 18 # Copyright (C) 2011 Eric Joseph-Alexandre <erjo@slitaz.org> |
erjo@8056 | 19 # |
erjo@8056 | 20 |
erjo@8056 | 21 VENET_DEV=eth0 |
erjo@8056 | 22 CFGFILE=/etc/network.conf |
erjo@8056 | 23 |
erjo@8056 | 24 function add_ip() |
erjo@8056 | 25 { |
erjo@8056 | 26 if ! grep -q venet0 ${CFGFILE}; then |
erjo@8056 | 27 sed -i "s/^INTERFACE.*/INTERFACE=\"${VENET_DEV}\"/" ${CFGFILE} |
erjo@8056 | 28 fi |
erjo@8056 | 29 |
erjo@8056 | 30 if [ ! -z ${IP_ADDR} ]; then |
erjo@8056 | 31 sed -i 's/DHCP=.*/DHCP="no"/' ${CFGFILE} |
erjo@8056 | 32 sed -i 's/STATIC=.*/STATIC="yes"/' ${CFGFILE} |
erjo@8056 | 33 sed -i -e "s/IP=".*"/IP=\"${IP_ADDR}\"/" ${CFGFILE} |
erjo@8056 | 34 sed -i -e "s/NETMASK=".*"/NETMASK=\"255.255.255.255\"/" ${CFGFILE} |
erjo@8056 | 35 fi |
erjo@8056 | 36 |
erjo@8056 | 37 # Starting the network |
erjo@8056 | 38 /etc/init.d/network.sh |
erjo@8056 | 39 |
erjo@8056 | 40 # Add default route |
erjo@8056 | 41 /sbin/route add default ${VENET_DEV} |
erjo@8056 | 42 } |
erjo@8056 | 43 |
erjo@8056 | 44 add_ip |
erjo@8056 | 45 |
erjo@8056 | 46 exit 0 |