Commit 408c0c3d5297b5bcefeffe2f4b43fef7b0efa4c9
1 parent
3758cbe4
Exists in
master
and in
90 other branches
Remove centos vagrant-lxc stuff
I'll maintain that on a separate place
Showing
6 changed files
with
0 additions
and
346 deletions
Show diff stats
utils/centos6-vagrant-lxc/.gitignore
utils/centos6-vagrant-lxc/Makefile
... | ... | @@ -1,52 +0,0 @@ |
1 | -BOX = centos6 | |
2 | -TEMPLATE_ARGS = -t centos -- --release 6.5 | |
3 | -LXC_PATH := $(shell sudo lxc-config lxc.lxcpath) | |
4 | - | |
5 | -all: $(BOX).box | |
6 | - | |
7 | -$(BOX).box: metadata.json lxc.conf lxc-template rootfs.tar.gz | |
8 | - $(RM) $@ | |
9 | - tar czf $@ $^ | |
10 | - | |
11 | -rootfs.tar.gz: rootfs | |
12 | - $(RM) $@ | |
13 | - sudo tar czfp $@ ./rootfs | |
14 | - | |
15 | -foo: .$(BOX)-base | |
16 | - cp -dR --preserve=mode,ownership /etc/vim foo | |
17 | - | |
18 | -rootfs: .$(BOX)-base | |
19 | - sudo cp -dR --preserve=mode,ownership $(LXC_PATH)/$(BOX)-base/rootfs rootfs | |
20 | - sudo ./vagrant-setup rootfs | |
21 | - | |
22 | -lxc.conf: .$(BOX)-base | |
23 | - sed -e '/^lxc.rootfs\s*=/d; s/lxc.autodev\s*=.*/lxc.autodev = 1/' $(LXC_PATH)/$(BOX)-base/config > $@ || ($(RM) $@; false) | |
24 | - | |
25 | -.$(BOX)-base: | |
26 | - sudo lxc-create -n $(BOX)-base $(TEMPLATE_ARGS) | |
27 | - touch $@ | |
28 | - | |
29 | -.PHONY: install uninstall clean | |
30 | - | |
31 | -metadata.json: metadata.json.in | |
32 | - ./metadata.json.in > $@ | |
33 | - | |
34 | -uninstall: | |
35 | - vagrant box remove $(BOX) || true | |
36 | - | |
37 | -install: $(BOX).box | |
38 | - vagrant box add $(BOX) $^ | |
39 | - | |
40 | -clean: | |
41 | - $(RM) $(BOX).box | |
42 | - | |
43 | -fullclean: clean | |
44 | - sudo $(RM) -r rootfs | |
45 | - sudo $(RM) rootfs.tar.gz | |
46 | - $(RM) .$(BOX)-base | |
47 | - $(RM) lxc.conf | |
48 | - $(RM) metadata.json | |
49 | - if sudo lxc-ls | grep $(BOX)-base; then sudo lxc-destroy -n $(BOX)-base; fi | |
50 | - | |
51 | -retry: clean uninstall all install | |
52 | - vagrant up |
utils/centos6-vagrant-lxc/Vagrantfile
utils/centos6-vagrant-lxc/lxc-template
... | ... | @@ -1,226 +0,0 @@ |
1 | -#!/bin/bash | |
2 | - | |
3 | -# This is a modified version of /usr/share/lxc/templates/lxc-ubuntu | |
4 | -# that comes with Ubuntu 13.04 changed to suit vagrant-lxc needs | |
5 | - | |
6 | -# | |
7 | -# template script for generating ubuntu container for LXC | |
8 | -# | |
9 | -# This script consolidates and extends the existing lxc ubuntu scripts | |
10 | -# | |
11 | - | |
12 | -# Copyright © 2011 Serge Hallyn <serge.hallyn@canonical.com> | |
13 | -# Copyright © 2010 Wilhelm Meier | |
14 | -# Author: Wilhelm Meier <wilhelm.meier@fh-kl.de> | |
15 | -# | |
16 | -# This program is free software; you can redistribute it and/or modify | |
17 | -# it under the terms of the GNU General Public License version 2, as | |
18 | -# published by the Free Software Foundation. | |
19 | - | |
20 | -# This program is distributed in the hope that it will be useful, | |
21 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
23 | -# GNU General Public License for more details. | |
24 | - | |
25 | -# You should have received a copy of the GNU General Public License along | |
26 | -# with this program; if not, write to the Free Software Foundation, Inc., | |
27 | -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
28 | -# | |
29 | - | |
30 | -set -e | |
31 | - | |
32 | -if [ -r /etc/default/lxc ]; then | |
33 | - . /etc/default/lxc | |
34 | -fi | |
35 | - | |
36 | -extract_rootfs() | |
37 | -{ | |
38 | - tarball=$1 | |
39 | - arch=$2 | |
40 | - rootfs=$3 | |
41 | - | |
42 | - echo "Extracting $tarball ..." | |
43 | - mkdir -p $rootfs | |
44 | - (cd $rootfs && tar xfz $tarball --strip-components=2) | |
45 | - return 0 | |
46 | -} | |
47 | - | |
48 | -install_ubuntu() | |
49 | -{ | |
50 | - rootfs=$1 | |
51 | - release=$2 | |
52 | - tarball=$3 | |
53 | - mkdir -p /var/lock/subsys/ | |
54 | - | |
55 | - ( | |
56 | - flock -x 200 | |
57 | - if [ $? -ne 0 ]; then | |
58 | - echo "Cache repository is busy." | |
59 | - return 1 | |
60 | - fi | |
61 | - | |
62 | - extract_rootfs $tarball $arch $rootfs | |
63 | - if [ $? -ne 0 ]; then | |
64 | - echo "Failed to copy rootfs" | |
65 | - return 1 | |
66 | - fi | |
67 | - | |
68 | - return 0 | |
69 | - | |
70 | - ) 200>/var/lock/subsys/lxc | |
71 | - | |
72 | - return $? | |
73 | -} | |
74 | - | |
75 | -copy_configuration() | |
76 | -{ | |
77 | - path=$1 | |
78 | - rootfs=$2 | |
79 | - name=$3 | |
80 | - | |
81 | - grep -q "^lxc.rootfs" $path/config 2>/dev/null || echo "lxc.rootfs = $rootfs" >> $path/config | |
82 | - | |
83 | - # if there is exactly one veth network entry, make sure it has an | |
84 | - # associated hwaddr. | |
85 | - nics=`grep -e '^lxc\.network\.type[ \t]*=[ \t]*veth' $path/config | wc -l` | |
86 | - if [ $nics -eq 1 ]; then | |
87 | - 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 | |
88 | - fi | |
89 | - | |
90 | - if [ $? -ne 0 ]; then | |
91 | - echo "Failed to add configuration" | |
92 | - return 1 | |
93 | - fi | |
94 | - | |
95 | - return 0 | |
96 | -} | |
97 | - | |
98 | -post_process() | |
99 | -{ | |
100 | - rootfs=$1 | |
101 | - | |
102 | - # rmdir /dev/shm for containers that have /run/shm | |
103 | - # I'm afraid of doing rm -rf $rootfs/dev/shm, in case it did | |
104 | - # get bind mounted to the host's /run/shm. So try to rmdir | |
105 | - # it, and in case that fails move it out of the way. | |
106 | - if [ ! -L $rootfs/dev/shm ] && [ -d $rootfs/run/shm ] && [ -e $rootfs/dev/shm ]; then | |
107 | - mv $rootfs/dev/shm $rootfs/dev/shm.bak | |
108 | - ln -s /run/shm $rootfs/dev/shm | |
109 | - fi | |
110 | -} | |
111 | - | |
112 | -usage() | |
113 | -{ | |
114 | - cat <<EOF | |
115 | -$1 -h|--help [-a|--arch] [--trim] [-d|--debug] [--rootfs <rootfs>] [-T|--tarball <rootfs-tarball> | |
116 | -arch: the container architecture (e.g. amd64): defaults to host arch | |
117 | -EOF | |
118 | - return 0 | |
119 | -} | |
120 | - | |
121 | -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: -- "$@") | |
122 | -if [ $? -ne 0 ]; then | |
123 | - usage $(basename $0) | |
124 | - exit 1 | |
125 | -fi | |
126 | -eval set -- "$options" | |
127 | - | |
128 | -release=precise # Default to the last Ubuntu LTS release for non-Ubuntu systems | |
129 | -if [ -f /etc/lsb-release ]; then | |
130 | - . /etc/lsb-release | |
131 | - if [ "$DISTRIB_ID" = "Ubuntu" ]; then | |
132 | - release=$DISTRIB_CODENAME | |
133 | - fi | |
134 | -fi | |
135 | - | |
136 | -arch=$(uname -m) | |
137 | - | |
138 | -# Code taken from debootstrap | |
139 | -if [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-architecture >/dev/null 2>&1; then | |
140 | - arch=`/usr/bin/dpkg --print-architecture` | |
141 | -elif type udpkg >/dev/null 2>&1 && udpkg --print-architecture >/dev/null 2>&1; then | |
142 | - arch=`/usr/bin/udpkg --print-architecture` | |
143 | -else | |
144 | - arch=$(uname -m) | |
145 | - if [ "$arch" = "i686" ]; then | |
146 | - arch="i386" | |
147 | - elif [ "$arch" = "x86_64" ]; then | |
148 | - arch="amd64" | |
149 | - elif [ "$arch" = "armv7l" ]; then | |
150 | - arch="armel" | |
151 | - fi | |
152 | -fi | |
153 | - | |
154 | -debug=0 | |
155 | -trim_container=0 | |
156 | -hostarch=$arch | |
157 | -while true | |
158 | -do | |
159 | - case "$1" in | |
160 | - -h|--help) usage $0 && exit 0;; | |
161 | - --rootfs) rootfs=$2; shift 2;; | |
162 | - -p|--path) path=$2; shift 2;; | |
163 | - -n|--name) name=$2; shift 2;; | |
164 | - -T|--tarball) tarball=$2; shift 2;; | |
165 | - -a|--arch) arch=$2; shift 2;; | |
166 | - -S|--auth-key) auth_key=$2; shift 2;; | |
167 | - -d|--debug) debug=1; shift 1;; | |
168 | - --) shift 1; break ;; | |
169 | - *) break ;; | |
170 | - esac | |
171 | -done | |
172 | - | |
173 | -if [ $debug -eq 1 ]; then | |
174 | - set -x | |
175 | -fi | |
176 | - | |
177 | -if [ "$arch" == "i686" ]; then | |
178 | - arch=i386 | |
179 | -fi | |
180 | - | |
181 | -if [ $hostarch = "i386" -a $arch = "amd64" ]; then | |
182 | - echo "can't create amd64 container on i386" | |
183 | - exit 1 | |
184 | -fi | |
185 | - | |
186 | -if [ -z "$path" ]; then | |
187 | - echo "'path' parameter is required" | |
188 | - exit 1 | |
189 | -fi | |
190 | - | |
191 | -if [ "$(id -u)" != "0" ]; then | |
192 | - echo "This script should be run as 'root'" | |
193 | - exit 1 | |
194 | -fi | |
195 | - | |
196 | -# detect rootfs | |
197 | -config="$path/config" | |
198 | -# if $rootfs exists here, it was passed in with --rootfs | |
199 | -if [ -z "$rootfs" ]; then | |
200 | - if grep -q '^lxc.rootfs' $config 2>/dev/null ; then | |
201 | - rootfs=`grep 'lxc.rootfs =' $config | awk -F= '{ print $2 }'` | |
202 | - else | |
203 | - rootfs=$path/rootfs | |
204 | - fi | |
205 | -fi | |
206 | - | |
207 | -install_ubuntu $rootfs $release $tarball | |
208 | -if [ $? -ne 0 ]; then | |
209 | - echo "failed to install ubuntu $release" | |
210 | - exit 1 | |
211 | -fi | |
212 | - | |
213 | -copy_configuration $path $rootfs $name $arch | |
214 | -if [ $? -ne 0 ]; then | |
215 | - echo "failed write configuration file" | |
216 | - exit 1 | |
217 | -fi | |
218 | - | |
219 | -post_process $rootfs $release $trim_container | |
220 | - | |
221 | -echo "" | |
222 | -echo "##" | |
223 | -echo "# The default user is 'vagrant' with password 'vagrant'!" | |
224 | -echo "# Use the 'sudo' command to run tasks as root in the container." | |
225 | -echo "##" | |
226 | -echo "" |
utils/centos6-vagrant-lxc/metadata.json.in
utils/centos6-vagrant-lxc/vagrant-setup
... | ... | @@ -1,41 +0,0 @@ |
1 | -#!/bin/sh | |
2 | - | |
3 | -set -ex | |
4 | - | |
5 | -fs="$1" | |
6 | -if [ -z "$fs" ]; then | |
7 | - echo "usage: $0 ROOTFS" | |
8 | - exit 1 | |
9 | -fi | |
10 | - | |
11 | -chroot $fs useradd --uid 1000 vagrant | |
12 | -mkdir -p $fs/home/vagrant | |
13 | -chroot $fs chown vagrant:vagrant /home/vagrant | |
14 | - | |
15 | -mkdir -p $fs/root/.ssh | |
16 | -chmod 700 $fs/root/.ssh | |
17 | -cat > $fs/root/.ssh/authorized_keys << EOF | |
18 | -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key | |
19 | -EOF | |
20 | -chmod 600 $fs/root/.ssh/authorized_keys | |
21 | - | |
22 | -mkdir -p $fs/home/vagrant/.ssh | |
23 | -chmod 700 $fs/home/vagrant/.ssh | |
24 | -cat > $fs/home/vagrant/.ssh/authorized_keys << EOF | |
25 | -ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key | |
26 | -EOF | |
27 | -chmod 600 $fs/home/vagrant/.ssh/authorized_keys | |
28 | -chroot $fs chown -R vagrant:vagrant /home/vagrant/.ssh | |
29 | - | |
30 | -# vagrant needs passwordless sudo | |
31 | -if [ -x $fs/usr/bin/apt-get ]; then | |
32 | - chroot $fs apt-get install -qy sudo | |
33 | -fi | |
34 | -if [ -x $fs/usr/bin/yum ]; then | |
35 | - chroot $fs yum install -y sudo | |
36 | -fi | |
37 | -cat > $fs/etc/sudoers.d/vagrant <<EOF | |
38 | -vagrant ALL=(ALL) NOPASSWD:ALL | |
39 | -EOF | |
40 | -chmod 0440 $fs/etc/sudoers.d/vagrant | |
41 | -sed -i -e '/Defaults\s*requiretty/ d' $fs/etc/sudoers |