tweaks after migration of narada
[sysadmin-cookbook] / recepies / ganeti / migrate-lxc / B-ganeti-network-interfaces.sh
1 #!/bin/sh -xe
2
3 . ./0-host.sh
4 . ./0-lxc.sh
5 . ./0-ganeti.sh
6
7 ssh_lxc cat /var/lib/lxc/$host/config | grep ipv4 | tee $host/ipv4
8 public_ip=`grep 193.198 $host/ipv4 | cut -d= -f2 | cut -d/ -f1 | sed 's/ *//'`
9 local_ip=` grep 10.60   $host/ipv4 | cut -d= -f2 | cut -d/ -f1 | sed 's/ *//'`
10
11 tee /tmp/network-interfaces-$host << __INTERFACES__
12 auto eth0 eth1 lo
13
14 iface lo inet loopback
15
16 iface eth0 inet static
17         address $public_ip
18         netmask 255.255.254.0
19         gateway 193.198.212.1
20
21 iface eth1 inet static
22         address $local_ip
23         netmask 255.255.254.0
24 __INTERFACES__
25
26 # this will backup file on original machine which is still running!
27 ping -c 1 $host && ssh_master chroot /tmp/$host bak add,commit /etc/network/interfaces
28
29 scp /tmp/network-interfaces-$host root@$master:/tmp/
30
31 ssh_master mv -v /tmp/network-interfaces-$host /tmp/$host/etc/network/interfaces