#!/bin/bash NAME=$1 ALIAS=$2 ALIAS=${ALIAS:=xenial} lxc image show $ALIAS >/dev/null 2>&1 if [ ! $? = 0 ]; then echo lxc image copy images:ubuntu/xenial/amd64 local: --alias xenial exit 0 fi if [ ! -f /etc/apt/apt.conf.d/proxy.conf ]; then sudo apt install apt-cacher-ng PROXY=$( lxc network show lxdbr0 | sed -n 's/\s\+ipv4.address: \([0-9\.]\+\).*/\1/p' ) echo "Acquire::http::Proxy \"http://$PROXY:3142\";" | sudo tee /etc/apt/apt.conf.d/proxy.conf echo "PfilePattern = .*" | sudo tee -a /etc/apt-cacher-ng/acng.conf echo "PassThroughPattern: .*" | sudo tee -a /etc/apt-cacher-ng/acng.conf systemctl restart apt-cacher-ng fi lxc info $NAME >/dev/null 2>&1 if [ ! $? = 0 ]; then lxc launch $ALIAS $NAME fi if [ -f /etc/apt/apt.conf.d/proxy.conf ]; then lxc file push /etc/apt/apt.conf.d/proxy.conf $NAME/etc/apt/apt.conf.d/ fi lxc file push /etc/inputrc $NAME/etc/