#!/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 echo "lxc.prlimit.nofile = 64000" >> /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 }