From 5e6a9dec93d1db390432d65677003911af963598 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Fri, 23 Aug 2019 06:44:16 +0000 Subject: [PATCH] Add rootfs generator for Ubuntu 14.04 --- tools/qemu-debian-img/14.04/Dockerfile | 34 ++++++++++++++++++++++++++ tools/qemu-debian-img/14.04/setup.sh | 17 +++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 tools/qemu-debian-img/14.04/Dockerfile create mode 100755 tools/qemu-debian-img/14.04/setup.sh diff --git a/tools/qemu-debian-img/14.04/Dockerfile b/tools/qemu-debian-img/14.04/Dockerfile new file mode 100644 index 0000000..8bb6f23 --- /dev/null +++ b/tools/qemu-debian-img/14.04/Dockerfile @@ -0,0 +1,34 @@ +# Copyright 2018 Mikhail Klementev. All rights reserved. +# Use of this source code is governed by a AGPLv3 license +# (or later) that can be found in the LICENSE file. +# +# Usage: +# +# $ docker build -t gen-ubuntu1404-image . +# $ docker run --privileged -v $(pwd):/shared -t gen-ubuntu1404-image +# +# ubuntu1404.img will be created in current directory. You can change $(pwd) to +# different directory to use different destination for image. +# +FROM ubuntu:14.04 + +ENV DEBIAN_FRONTEND=noninteractive +RUN apt-get update +RUN apt-get install -y debootstrap qemu + +ENV TMPDIR=/tmp/ubuntu +ENV IMAGEDIR=/tmp/image +ENV IMAGE=/shared/out_of_tree_ubuntu_14__04.img +ENV REPOSITORY=http://archive.ubuntu.com/ubuntu +ENV RELEASE=trusty + +RUN mkdir $IMAGEDIR + +# Must be executed with --privileged because of /dev/loop +CMD debootstrap --include=openssh-server $RELEASE $TMPDIR $REPOSITORY && \ + /shared/setup.sh $TMPDIR && \ + qemu-img create $IMAGE 2G && \ + mkfs.ext4 -F $IMAGE && \ + mount -o loop $IMAGE $IMAGEDIR && \ + cp -a $TMPDIR/* $IMAGEDIR/ && \ + umount $IMAGEDIR diff --git a/tools/qemu-debian-img/14.04/setup.sh b/tools/qemu-debian-img/14.04/setup.sh new file mode 100755 index 0000000..0575a78 --- /dev/null +++ b/tools/qemu-debian-img/14.04/setup.sh @@ -0,0 +1,17 @@ +#!/bin/sh -eux +# Copyright 2018 Mikhail Klementev. All rights reserved. +# Use of this source code is governed by a AGPLv3 license +# (or later) that can be found in the LICENSE file. +TMPDIR=$1 +chroot $TMPDIR /bin/sh -c 'useradd -m user' +sed -i 's/root:\*:/root::/' $TMPDIR/etc/shadow +sed -i 's/user:!!:/user::/' $TMPDIR/etc/shadow +echo auth sufficient pam_permit.so > $TMPDIR/etc/pam.d/sshd +sed -i '/PermitEmptyPasswords/d' $TMPDIR/etc/ssh/sshd_config +echo PermitEmptyPasswords yes >> $TMPDIR/etc/ssh/sshd_config +sed -i '/PermitRootLogin/d' $TMPDIR/etc/ssh/sshd_config +echo PermitRootLogin yes >> $TMPDIR/etc/ssh/sshd_config + +echo '#!/bin/sh' > $TMPDIR/etc/rc.local +echo 'dhclient eth0' >> $TMPDIR/etc/rc.local +chmod +x $TMPDIR/etc/rc.local