Skip to content

Instantly share code, notes, and snippets.

@nojima
Last active August 29, 2015 14:02
Show Gist options
  • Save nojima/8783596bafe8498a139e to your computer and use it in GitHub Desktop.
Save nojima/8783596bafe8498a139e to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: create-container NAME" 1>&2
exit 1
fi
name=$1
ipaddr=$(sed -e 's/#.*$//' /etc/hosts | awk "\$2~/^${name}\$/ { print \$1 }")
if [ -z "$ipaddr" ]; then
echo "ERROR: IP address of ${name} was not found in /etc/hosts." 1>&2
exit 1
fi
set -xe
lxc-create -t ubuntu-nojima -n $name -- --user=nojima --password=secret --auth-key=/home/nojima/.ssh/id_rsa.pub --mirror="http://ftp.jaist.ac.jp/ubuntu"
service dnsmasq force-reload
lxc-start -d -n $name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment