tweaks to cache warming, and better comments
This commit is contained in:
parent
1f81db6909
commit
40203cb1c4
1 changed files with 9 additions and 5 deletions
14
build_lxc.sh
14
build_lxc.sh
|
@ -10,16 +10,19 @@ NAMESERVER=${NAMESERVER:-192.168.1.1}
|
||||||
COPYENV=${COPYENV:-1}
|
COPYENV=${COPYENV:-1}
|
||||||
WARMCACHE=${WARMCACHE:-0}
|
WARMCACHE=${WARMCACHE:-0}
|
||||||
|
|
||||||
# Destroy any existing container
|
# Shutdown any existing container
|
||||||
lxc-stop -n $CONTAINER
|
lxc-stop -n $CONTAINER
|
||||||
sleep 1
|
sleep 1
|
||||||
|
# This prevents zombie containers
|
||||||
cgdelete -r cpu,net_cls:$CONTAINER
|
cgdelete -r cpu,net_cls:$CONTAINER
|
||||||
sleep 1
|
sleep 1
|
||||||
|
# Destroy the old container
|
||||||
lxc-destroy -n $CONTAINER
|
lxc-destroy -n $CONTAINER
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
# Warm the base image on first run or when WARMCACHE=1
|
||||||
CACHEDIR=/var/cache/lxc/natty/rootfs-amd64
|
CACHEDIR=/var/cache/lxc/natty/rootfs-amd64
|
||||||
if [ "$WARMCACHE" = "1" ]; then
|
if [ "$WARMCACHE" = "1" ] || [ ! -d $CACHEDIR ]; then
|
||||||
if [ -d $CACHEDIR ]; then
|
if [ -d $CACHEDIR ]; then
|
||||||
# Pre-cache files
|
# Pre-cache files
|
||||||
chroot $CACHEDIR apt-get update
|
chroot $CACHEDIR apt-get update
|
||||||
|
@ -29,17 +32,18 @@ if [ "$WARMCACHE" = "1" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create network configuration
|
# Create network configuration
|
||||||
NET_CONF=/tmp/net.conf
|
LXC_CONF=/tmp/net.conf
|
||||||
cat > $NET_CONF <<EOF
|
cat > $LXC_CONF <<EOF
|
||||||
lxc.network.type = veth
|
lxc.network.type = veth
|
||||||
lxc.network.link = $BRIDGE
|
lxc.network.link = $BRIDGE
|
||||||
lxc.network.flags = up
|
lxc.network.flags = up
|
||||||
lxc.network.ipv4 = $CONTAINER_CIDR
|
lxc.network.ipv4 = $CONTAINER_CIDR
|
||||||
|
# allow tap/tun devices
|
||||||
lxc.cgroup.devices.allow = c 10:200 rwm
|
lxc.cgroup.devices.allow = c 10:200 rwm
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Configure the network
|
# Configure the network
|
||||||
lxc-create -n $CONTAINER -t natty -f $NET_CONF
|
lxc-create -n $CONTAINER -t natty -f $LXC_CONF
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
||||||
# Where our container lives
|
# Where our container lives
|
||||||
|
|
Loading…
Reference in a new issue