From 213261db336ccbdd09019fa45f16c5ede83f8bdb Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 7 Aug 2014 22:08:59 +0200 Subject: [PATCH] lxc: lxc-void: add openssh-server; setup timezone, dhcpcd and sshd. --- srcpkgs/lxc/files/lxc-void | 18 ++++++++++++++++-- srcpkgs/lxc/template | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/srcpkgs/lxc/files/lxc-void b/srcpkgs/lxc/files/lxc-void index 2e80da1be2..32f0b78c67 100755 --- a/srcpkgs/lxc/files/lxc-void +++ b/srcpkgs/lxc/files/lxc-void @@ -42,8 +42,8 @@ arch=$(uname -m) default_path="/var/lib/lxc" LXC_TEMPLATE_CONFIG="/usr/share/lxc/config" -# Install 'base-voidstrap' by default -base_packages=('base-voidstrap') +# Install 'base-voidstrap' and 'openssh-server' by default +base_packages=('base-voidstrap' 'openssh-server') declare -a additional_packages # split comma-separated string into an array @@ -65,6 +65,13 @@ copy_configuration() { hostname=$3 arch=$4 + # if there is exactly one veth network entry, make sure it has an + # associated hwaddr. + nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l` + if [ $nics -eq 1 ]; then + grep -q "^lxc.network.hwaddr" $path/config || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config + fi + ## Add all the includes echo "" >> $path/config echo "# Common configuration" >> $path/config @@ -159,6 +166,13 @@ EOF grep nameserver /etc/resolv.conf > "${rootfs}/etc/resolv.conf" # Enable agetty on /dev/console ln -s /etc/sv/agetty-console $rootfs/etc/runit/runsvdir/default/ + # Enable dhcpcd and sshd. + ln -s /etc/sv/dhcpcd $rootfs/etc/runit/runsvdir/default/ + ln -s /etc/sv/sshd $rootfs/etc/runit/runsvdir/default/ + # Copy host /etc/localtime + if [ -f /etc/localtime ]; then + cat /etc/localtime > $rootfs/etc/localtime + fi echo "root:root" | chroot ${rootfs} chpasswd -c SHA512 echo diff --git a/srcpkgs/lxc/template b/srcpkgs/lxc/template index 7f32598433..c851537691 100644 --- a/srcpkgs/lxc/template +++ b/srcpkgs/lxc/template @@ -3,7 +3,7 @@ _desc="Linux Containers" pkgname=lxc version=1.0.5 -revision=4 +revision=5 build_style=gnu-configure configure_args="--enable-doc --enable-seccomp --disable-apparmor --with-distro=none --with-rootfs-path=/var/lxc/containers --with-log-path=/var/lxc/log"