From 3a558beef68ba20ec2f1fa7e8b8f341f7fc96182 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Tue, 29 Aug 2017 20:10:00 +0200 Subject: [PATCH] Set up Travis CI to build example image --- .travis.yml | 27 +++++++++++++++++++++++++++ example/configure.sh | 34 ++++++++++++++++++++++++++++++++++ example/packages | 6 ++++++ example/repositories | 2 ++ 4 files changed, 69 insertions(+) create mode 100644 .travis.yml create mode 100755 example/configure.sh create mode 100644 example/packages create mode 100644 example/repositories diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..993d404 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +dist: trusty +sudo: required +language: minimal +before_install: + - "wget 'https://raw.githubusercontent.com/alpinelinux/alpine-chroot-install/v0.6.0/alpine-chroot-install' \ + && echo 'a827a4ba3d0817e7c88bae17fe34e50204983d1e alpine-chroot-install' | sha1sum -c || exit 1" +install: + - sudo sh alpine-chroot-install -b v3.6 +before_script: + - sudo modprobe nbd +script: + - /alpine/enter-chroot ./alpine-make-vm-image + --image-format qcow2 + --image-size 2G + --repositories-file example/repositories + --packages "$(cat example/packages)" + --script-chroot + alpine-virthardened-$(date +%Y-%m-%d).qcow2 -- ./example/configure.sh +#deploy: +# provider: releases +# api_key: +# secure: +# file: "*.qcow2" +# file_glob: true +# skip_cleanup: true +# on: +# tags: true diff --git a/example/configure.sh b/example/configure.sh new file mode 100755 index 0000000..b1bdd0d --- /dev/null +++ b/example/configure.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +_step_counter=0 +step() { + _step_counter=$(( _step_counter + 1 )) + printf '\n\033[1;36m%d) %s\033[0m\n' $_step_counter "$@" >&2 # bold cyan +} + + +step 'Set up timezone' +setup-timezone -z Europe/Prague + +step 'Set up networking' +cat > /etc/network/interfaces <<-EOF + iface lo inet loopback + iface eth0 inet dhcp +EOF +ln -s networking /etc/init.d/net.lo +ln -s networking /etc/init.d/net.eth0 + +step 'Adjust rc.conf' +sed -Ei \ + -e 's/^[# ](rc_depend_strict)=.*/\1=NO/' \ + -e 's/^[# ](rc_logger)=.*/\1=YES/' \ + -e 's/^[# ](unicode)=.*/\1=YES/' \ + /etc/rc.conf + +step 'Enable services' +rc-update add acpid default +rc-update add chronyd default +rc-update add crond default +rc-update add net.eth0 default +rc-update add net.lo boot +rc-update add termencoding boot diff --git a/example/packages b/example/packages new file mode 100644 index 0000000..21c2737 --- /dev/null +++ b/example/packages @@ -0,0 +1,6 @@ +chrony +less +logrotate +openssh +ssmtp +sudo diff --git a/example/repositories b/example/repositories new file mode 100644 index 0000000..b2377c3 --- /dev/null +++ b/example/repositories @@ -0,0 +1,2 @@ +https://nl.alpinelinux.org/alpine/v3.6/main +https://nl.alpinelinux.org/alpine/v3.6/community