summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--notes/lxc_setup.sh.txt41
1 files changed, 28 insertions, 13 deletions
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
+