#!/usr/bin/env bash # Configurable params BRIDGE=${BRIDGE:-br0} CONTAINER=${CONTAINER:-STACK} CONTAINER_IP=${CONTAINER_IP:-192.168.1.50} CONTAINER_CIDR=${CONTAINER_CIDR:-$CONTAINER_IP/24} CONTAINER_NETMASK=${CONTAINER_NETMASK:-255.255.255.0} CONTAINER_GATEWAY=${CONTAINER_GATEWAY:-192.168.1.1} NAMESERVER=${NAMESERVER:-192.168.1.1} COPYENV=${COPYENV:-1} # Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova" STACKSH_PARAMS=${STACKSH_PARAMS:-} # Install cgroup-bin if we don't have it yet if ! which cgdelete | grep -q cgdelete; then apt-get install cgroup-bin fi # Create lxc configuration LXC_CONF=/tmp/$CONTAINER.conf cat > $LXC_CONF <> $ROOTFS/etc/sudoers # Gracefully cp only if source file/dir exists function cp_it { if [ -e $1 ] || [ -d $1 ]; then cp -pr $1 $2 fi } # Copy over your ssh keys and env if desired if [ "$COPYENV" = "1" ]; then cp_it ~/.ssh $ROOTFS/opt/.ssh cp_it ~/.ssh/id_rsa.pub $ROOTFS/opt/.ssh/authorized_keys cp_it ~/.gitconfig $ROOTFS/opt/.gitconfig cp_it ~/.vimrc $ROOTFS/opt/.vimrc cp_it ~/.bashrc $ROOTFS/opt/.bashrc fi # Give stack ownership over /opt so it may do the work needed chroot $ROOTFS chown -R stack /opt # Configure instance network INTERFACES=$ROOTFS/etc/network/interfaces cat > $INTERFACES < $RUN_SH < $RC_LOCAL <