django-orchestra-test/scripts/container/create.sh

47 lines
1.0 KiB
Bash
Raw Normal View History

2014-05-08 16:59:35 +00:00
#!/bin/bash
# This is a helper script for creating a basic LXC container with some convenient packages
# ./create.sh [container_name]
2015-04-04 17:44:07 +00:00
2014-05-08 16:59:35 +00:00
set -u
NAME=${1:-orchestra}
CONTAINER="/var/lib/lxc/$NAME/rootfs"
PASSWORD=$NAME
2015-04-29 10:38:41 +00:00
export SUITE="jessie"
2014-05-08 16:59:35 +00:00
[ $(whoami) != 'root' ] && {
echo -e "\nErr. This script should run as root\n" >&2
exit 1
}
lxc-create -h &> /dev/null || {
echo -e "\nErr. It seems like LXC is not installed, run apt-get install lxc\n" >&2
exit 1
}
lxc-create -n $NAME -t debian
mount --bind /dev $CONTAINER/dev
mount -t sysfs none $CONTAINER/sys
trap "umount $CONTAINER/{dev,sys}; exit 1;"INT TERM EXIT
sed -i "s/\tlocalhost$/\tlocalhost $NAME/" $CONTAINER/etc/hosts
sed -i "s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/" $CONTAINER/etc/locale.gen
chroot $CONTAINER locale-gen
chroot $CONTAINER apt-get install -y --force-yes \
2015-04-04 17:44:07 +00:00
nano git screen sudo iputils-ping python3 python3-pip wget curl dnsutils rsyslog
2014-05-08 16:59:35 +00:00
chroot $CONTAINER apt-get clean
sleep 0.1
umount $CONTAINER/{dev,sys}
trap - INT TERM EXIT