diff --git a/utils/centos6-vagrant-lxc/.gitignore b/utils/centos6-vagrant-lxc/.gitignore deleted file mode 100644 index 6cc6694..0000000 --- a/utils/centos6-vagrant-lxc/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -*.box -metadata.json -lxc.conf -rootfs* -.*-base diff --git a/utils/centos6-vagrant-lxc/Makefile b/utils/centos6-vagrant-lxc/Makefile deleted file mode 100644 index d783031..0000000 --- a/utils/centos6-vagrant-lxc/Makefile +++ /dev/null @@ -1,52 +0,0 @@ -BOX = centos6 -TEMPLATE_ARGS = -t centos -- --release 6.5 -LXC_PATH := $(shell sudo lxc-config lxc.lxcpath) - -all: $(BOX).box - -$(BOX).box: metadata.json lxc.conf lxc-template rootfs.tar.gz - $(RM) $@ - tar czf $@ $^ - -rootfs.tar.gz: rootfs - $(RM) $@ - sudo tar czfp $@ ./rootfs - -foo: .$(BOX)-base - cp -dR --preserve=mode,ownership /etc/vim foo - -rootfs: .$(BOX)-base - sudo cp -dR --preserve=mode,ownership $(LXC_PATH)/$(BOX)-base/rootfs rootfs - sudo ./vagrant-setup rootfs - -lxc.conf: .$(BOX)-base - sed -e '/^lxc.rootfs\s*=/d; s/lxc.autodev\s*=.*/lxc.autodev = 1/' $(LXC_PATH)/$(BOX)-base/config > $@ || ($(RM) $@; false) - -.$(BOX)-base: - sudo lxc-create -n $(BOX)-base $(TEMPLATE_ARGS) - touch $@ - -.PHONY: install uninstall clean - -metadata.json: metadata.json.in - ./metadata.json.in > $@ - -uninstall: - vagrant box remove $(BOX) || true - -install: $(BOX).box - vagrant box add $(BOX) $^ - -clean: - $(RM) $(BOX).box - -fullclean: clean - sudo $(RM) -r rootfs - sudo $(RM) rootfs.tar.gz - $(RM) .$(BOX)-base - $(RM) lxc.conf - $(RM) metadata.json - if sudo lxc-ls | grep $(BOX)-base; then sudo lxc-destroy -n $(BOX)-base; fi - -retry: clean uninstall all install - vagrant up diff --git a/utils/centos6-vagrant-lxc/Vagrantfile b/utils/centos6-vagrant-lxc/Vagrantfile deleted file mode 100644 index f06604f..0000000 --- a/utils/centos6-vagrant-lxc/Vagrantfile +++ /dev/null @@ -1,9 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -VAGRANTFILE_API_VERSION = "2" - -Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.box = "centos6" -end diff --git a/utils/centos6-vagrant-lxc/lxc-template b/utils/centos6-vagrant-lxc/lxc-template deleted file mode 100755 index 202d068..0000000 --- a/utils/centos6-vagrant-lxc/lxc-template +++ /dev/null @@ -1,226 +0,0 @@ -#!/bin/bash - -# This is a modified version of /usr/share/lxc/templates/lxc-ubuntu -# that comes with Ubuntu 13.04 changed to suit vagrant-lxc needs - -# -# template script for generating ubuntu container for LXC -# -# This script consolidates and extends the existing lxc ubuntu scripts -# - -# Copyright © 2011 Serge Hallyn -# Copyright © 2010 Wilhelm Meier -# Author: Wilhelm Meier -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2, as -# published by the Free Software Foundation. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -set -e - -if [ -r /etc/default/lxc ]; then - . /etc/default/lxc -fi - -extract_rootfs() -{ - tarball=$1 - arch=$2 - rootfs=$3 - - echo "Extracting $tarball ..." - mkdir -p $rootfs - (cd $rootfs && tar xfz $tarball --strip-components=2) - return 0 -} - -install_ubuntu() -{ - rootfs=$1 - release=$2 - tarball=$3 - mkdir -p /var/lock/subsys/ - - ( - flock -x 200 - if [ $? -ne 0 ]; then - echo "Cache repository is busy." - return 1 - fi - - extract_rootfs $tarball $arch $rootfs - if [ $? -ne 0 ]; then - echo "Failed to copy rootfs" - return 1 - fi - - return 0 - - ) 200>/var/lock/subsys/lxc - - return $? -} - -copy_configuration() -{ - path=$1 - rootfs=$2 - name=$3 - - grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config - - # if there is exactly one veth network entry, make sure it has an - # associated hwaddr. - nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l` - if [ $nics -eq 1 ]; then - grep -q "^lxc.network.hwaddr" $path/config || sed -i -e "/^lxc\.network\.type[ \t]*=[ \t]*veth/a lxc.network.hwaddr = 00:16:3e:$(openssl rand -hex 3| sed 's/\(..\)/\1:/g; s/.$//')" $path/config - fi - - if [ $? -ne 0 ]; then - echo "Failed to add configuration" - return 1 - fi - - return 0 -} - -post_process() -{ - rootfs=$1 - - # rmdir /dev/shm for containers that have /run/shm - # I'm afraid of doing rm -rf $rootfs/dev/shm, in case it did - # get bind mounted to the host's /run/shm. So try to rmdir - # it, and in case that fails move it out of the way. - if [ ! -L $rootfs/dev/shm ] && [ -d $rootfs/run/shm ] && [ -e $rootfs/dev/shm ]; then - mv $rootfs/dev/shm $rootfs/dev/shm.bak - ln -s /run/shm $rootfs/dev/shm - fi -} - -usage() -{ - cat <] [-T|--tarball -arch: the container architecture (e.g. amd64): defaults to host arch -EOF - return 0 -} - -options=$(getopt -o a:b:hp:r:xn:FS:d:C -l arch:,help,path:,release:,trim,name:,flush-cache,auth-key:,debug:,tarball:,rootfs: -- "$@") -if [ $? -ne 0 ]; then - usage $(basename $0) - exit 1 -fi -eval set -- "$options" - -release=precise # Default to the last Ubuntu LTS release for non-Ubuntu systems -if [ -f /etc/lsb-release ]; then - . /etc/lsb-release - if [ "$DISTRIB_ID" = "Ubuntu" ]; then - release=$DISTRIB_CODENAME - fi -fi - -arch=$(uname -m) - -# Code taken from debootstrap -if [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-architecture >/dev/null 2>&1; then - arch=`/usr/bin/dpkg --print-architecture` -elif type udpkg >/dev/null 2>&1 && udpkg --print-architecture >/dev/null 2>&1; then - arch=`/usr/bin/udpkg --print-architecture` -else - arch=$(uname -m) - if [ "$arch" = "i686" ]; then - arch="i386" - elif [ "$arch" = "x86_64" ]; then - arch="amd64" - elif [ "$arch" = "armv7l" ]; then - arch="armel" - fi -fi - -debug=0 -trim_container=0 -hostarch=$arch -while true -do - case "$1" in - -h|--help) usage $0 && exit 0;; - --rootfs) rootfs=$2; shift 2;; - -p|--path) path=$2; shift 2;; - -n|--name) name=$2; shift 2;; - -T|--tarball) tarball=$2; shift 2;; - -a|--arch) arch=$2; shift 2;; - -S|--auth-key) auth_key=$2; shift 2;; - -d|--debug) debug=1; shift 1;; - --) shift 1; break ;; - *) break ;; - esac -done - -if [ $debug -eq 1 ]; then - set -x -fi - -if [ "$arch" == "i686" ]; then - arch=i386 -fi - -if [ $hostarch = "i386" -a $arch = "amd64" ]; then - echo "can't create amd64 container on i386" - exit 1 -fi - -if [ -z "$path" ]; then - echo "'path' parameter is required" - exit 1 -fi - -if [ "$(id -u)" != "0" ]; then - echo "This script should be run as 'root'" - exit 1 -fi - -# detect rootfs -config="$path/config" -# if $rootfs exists here, it was passed in with --rootfs -if [ -z "$rootfs" ]; then - if grep -q '^lxc.rootfs' $config 2>/dev/null ; then - rootfs=`grep 'lxc.rootfs =' $config | awk -F= '{ print $2 }'` - else - rootfs=$path/rootfs - fi -fi - -install_ubuntu $rootfs $release $tarball -if [ $? -ne 0 ]; then - echo "failed to install ubuntu $release" - exit 1 -fi - -copy_configuration $path $rootfs $name $arch -if [ $? -ne 0 ]; then - echo "failed write configuration file" - exit 1 -fi - -post_process $rootfs $release $trim_container - -echo "" -echo "##" -echo "# The default user is 'vagrant' with password 'vagrant'!" -echo "# Use the 'sudo' command to run tasks as root in the container." -echo "##" -echo "" diff --git a/utils/centos6-vagrant-lxc/metadata.json.in b/utils/centos6-vagrant-lxc/metadata.json.in deleted file mode 100755 index 1b3380f..0000000 --- a/utils/centos6-vagrant-lxc/metadata.json.in +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e - -export LANG=C - -cat < $fs/root/.ssh/authorized_keys << EOF -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key -EOF -chmod 600 $fs/root/.ssh/authorized_keys - -mkdir -p $fs/home/vagrant/.ssh -chmod 700 $fs/home/vagrant/.ssh -cat > $fs/home/vagrant/.ssh/authorized_keys << EOF -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key -EOF -chmod 600 $fs/home/vagrant/.ssh/authorized_keys -chroot $fs chown -R vagrant:vagrant /home/vagrant/.ssh - -# vagrant needs passwordless sudo -if [ -x $fs/usr/bin/apt-get ]; then - chroot $fs apt-get install -qy sudo -fi -if [ -x $fs/usr/bin/yum ]; then - chroot $fs yum install -y sudo -fi -cat > $fs/etc/sudoers.d/vagrant <