diff options
author | Loïc Hoguin <[email protected]> | 2018-04-18 00:27:06 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-04-18 11:06:34 +0200 |
commit | e5311de35216cc541978c10a8f2cf8204acc7b94 (patch) | |
tree | 2346f74a488585a77fd1680cc1c827ee549bb9e0 /ci.d/lxc | |
download | ci-e5311de35216cc541978c10a8f2cf8204acc7b94.tar.gz ci-e5311de35216cc541978c10a8f2cf8204acc7b94.tar.bz2 ci-e5311de35216cc541978c10a8f2cf8204acc7b94.zip |
Initial commit
Sets up LXC containers for CI for Alpine, Arch Linux,
CentOS, Debian and Ubuntu. Currently only tested against
Cowlib, it's likely that more packages need to be installed
for the other projects.
Diffstat (limited to 'ci.d/lxc')
-rw-r--r-- | ci.d/lxc | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/ci.d/lxc b/ci.d/lxc new file mode 100644 index 0000000..c0c5ed2 --- /dev/null +++ b/ci.d/lxc @@ -0,0 +1,44 @@ +#!/usr/bin/env sh + +# $NAME must be set to the name of the container. +if [ -z "$NAME" ]; then + echo 'Error: $NAME is empty or not set.' 1>&2 + exit 1 +fi + +# lxc_create dist release arch +lxc_create() { + lxc-create -n $NAME -t download -B btrfs -- --dist $1 --release $2 --arch $3 + echo "lxc.start.auto = 1" >> /home/lxc/$NAME/config + echo "lxc.environment = HOME=/root" >> /home/lxc/$NAME/config + lxc-start -n $NAME + lxc-wait -n $NAME -s RUNNING +} + +# lxc_destroy +lxc_destroy() { + lxc-stop -n $NAME -k || true + lxc-destroy -n $NAME || true +} + +# lxc_do +lxc_do() { + lxc-attach -n $NAME --clear-env -- "$@" +} + +# lxc_restart +lxc_restart() { + lxc-stop -n $NAME + lxc-start -n $NAME + lxc_wait_for_ip + lxc-ls -f $NAME +} + +# lxc_wait_for_ip +lxc_wait_for_ip() { + until lxc-info -n $NAME -i | grep IP: + do + echo -n . + sleep 1 + done +} |