From 7cb4ca9db6167a53eeac30425ebfcb90881c9b77 Mon Sep 17 00:00:00 2001 From: Joe Rayhawk Date: Tue, 19 Oct 2010 17:49:56 -0700 Subject: Adding some networking stuff and cleaning up some. --- notes/lxc_setup.sh.txt | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'notes') diff --git a/notes/lxc_setup.sh.txt b/notes/lxc_setup.sh.txt index eff8d96..819e09e 100644 --- a/notes/lxc_setup.sh.txt +++ b/notes/lxc_setup.sh.txt @@ -27,16 +27,16 @@ while cat /srv/lxc/*/config | grep -q 'lxc\.network\.ipv4 = 192\.168\.1\.'$addr; addr=$(($addr+1)) done -echo >> /srv/lxc/$container/config -echo '# networking' >> /srv/lxc/$container/config -echo lxc.utsname = $container >> /srv/lxc/$container/config -echo lxc.network.type = veth >> /srv/lxc/$container/config -echo lxc.network.flags = up >> /srv/lxc/$container/config -echo lxc.network.link = br0 >> /srv/lxc/$container/config -echo lxc.network.ipv4 = 192.168.1.$addr/24 >> /srv/lxc/$container/config -echo lxc.network.hwaddr = 00:16:53:00:01:$addr >> /srv/lxc/$container/config - -lxc-create -n $container -f /srv/lxc/$container/config +( + echo + echo '# networking' + echo lxc.utsname = $container + echo lxc.network.type = veth + echo lxc.network.flags = up + echo lxc.network.link = br0 + echo lxc.network.ipv4 = 192.168.1.$addr/24 + echo lxc.network.hwaddr = 00:16:53:00:01:$addr +) >> /srv/lxc/$container/config echo > /srv/lxc/$container/rootfs/etc/network/interfaces @@ -55,6 +55,21 @@ for newuser in "${users[@]}"; do tar -cvvC /home/$newuser/ .ssh | chroot /srv/lxc/$container/rootfs/ tar -xvvC /home/$newuser/ done -( grep -v PermitRootLogin\\\|PasswordAuthentication /srv/lxc/$container/rootfs/etc/ssh/sshd_config -echo "PermitRootLogin no" -echo "PasswordAuthentication no" ) | sponge /srv/lxc/$container/rootfs/etc/ssh/sshd_config +( + grep -v PermitRootLogin\\\|PasswordAuthentication /srv/lxc/$container/rootfs/etc/ssh/sshd_config + echo PermitRootLogin no + echo PasswordAuthentication no +) | sponge /srv/lxc/$container/rootfs/etc/ssh/sshd_config + +( + grep -v ^exit /srv/lxc/$container/rootfs/etc/rc.local + echo ip route add default via 192.168.1.1 +) | sponge /srv/lxc/$container/rootfs/etc/rc.local + +( + echo 127.0.0.1 localhost + echo 192.168.1.$addr $container +) > /srv/lxc/$container/rootfs/etc/hosts + +lxc-create -n $container -f /srv/lxc/$container/config + -- cgit v1.2.3