vagrant-lxc 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BOXES.md +55 -0
- data/CHANGELOG.md +14 -0
- data/CONTRIBUTING.md +20 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +4 -3
- data/README.md +16 -19
- data/boxes/build-debian-box.sh +167 -0
- data/boxes/build-ubuntu-box.sh +151 -0
- data/boxes/common/install-babushka +4 -3
- data/boxes/common/install-chef +3 -2
- data/boxes/common/install-puppet +3 -2
- data/boxes/common/install-salt +3 -2
- data/boxes/common/lxc-template +10 -13
- data/boxes/common/metadata.json +2 -1
- data/development/Vagrantfile +4 -4
- data/development/site.pp +31 -6
- data/lib/vagrant-lxc/action.rb +44 -40
- data/lib/vagrant-lxc/action/clear_forwarded_ports.rb +4 -0
- data/lib/vagrant-lxc/action/fetch_ip_from_dnsmasq_leases.rb +1 -1
- data/lib/vagrant-lxc/action/fetch_ip_with_lxc_attach.rb +4 -7
- data/lib/vagrant-lxc/action/message.rb +1 -0
- data/lib/vagrant-lxc/action/setup_package_files.rb +1 -0
- data/lib/vagrant-lxc/action/wait_for_communicator.rb +9 -14
- data/lib/vagrant-lxc/driver.rb +10 -7
- data/lib/vagrant-lxc/driver/cli.rb +7 -1
- data/lib/vagrant-lxc/errors.rb +5 -0
- data/lib/vagrant-lxc/version.rb +1 -1
- data/locales/en.yml +8 -2
- data/spec/Vagrantfile +7 -2
- data/spec/unit/driver/cli_spec.rb +8 -0
- metadata +8 -18
- data/boxes/debian/download +0 -156
- data/boxes/debian/finalize +0 -195
- data/boxes/debian/lxc-template +0 -367
- data/boxes/debian/metadata.json.template +0 -9
- data/boxes/ubuntu/download +0 -113
- data/boxes/ubuntu/finalize +0 -374
- data/boxes/ubuntu/lxc-template +0 -559
- data/boxes/ubuntu/metadata.json.template +0 -9
- data/development/shell-provisioning/upgrade-kernel +0 -14
- data/example/Vagrantfile +0 -46
- data/example/cookbooks/hello-world/recipes/default.rb +0 -4
- data/example/puppet/manifests/site.pp +0 -5
- data/example/puppet/modules/hello_world/manifests/init.pp +0 -3
- data/tasks/boxes.rake +0 -115
- data/tasks/boxes.v2.rake +0 -188
data/boxes/ubuntu/download
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# This is the code extracted from /usr/share/lxc/templates/lxc-ubuntu
|
4
|
-
# that comes with Ubuntu 12.10 which is responsible for downloading the
|
5
|
-
# rootfs files / packages
|
6
|
-
|
7
|
-
set -e
|
8
|
-
|
9
|
-
suggest_flush()
|
10
|
-
{
|
11
|
-
echo "Container upgrade failed. The container cache may be out of date,"
|
12
|
-
echo "in which case flushing the case (see -F in the hep output) may help."
|
13
|
-
}
|
14
|
-
|
15
|
-
cleanup()
|
16
|
-
{
|
17
|
-
rm -rf $cache/partial
|
18
|
-
rm -rf $cache/rootfs
|
19
|
-
}
|
20
|
-
|
21
|
-
write_sourceslist()
|
22
|
-
{
|
23
|
-
# $1 => path to the rootfs
|
24
|
-
|
25
|
-
MIRROR=${MIRROR:-http://archive.ubuntu.com/ubuntu}
|
26
|
-
SECURITY_MIRROR=${SECURITY_MIRROR:-http://security.ubuntu.com/ubuntu}
|
27
|
-
|
28
|
-
cat >> "$1/etc/apt/sources.list" << EOF
|
29
|
-
deb $MIRROR ${release} main restricted universe multiverse
|
30
|
-
deb $MIRROR ${release}-updates main restricted universe multiverse
|
31
|
-
deb $SECURITY_MIRROR ${release}-security main restricted universe multiverse
|
32
|
-
EOF
|
33
|
-
}
|
34
|
-
|
35
|
-
download_ubuntu()
|
36
|
-
{
|
37
|
-
packages=vim,ssh,curl,wget,bash-completion,manpages,man-db,psmisc
|
38
|
-
|
39
|
-
# Try to guess a list of langpacks to install
|
40
|
-
langpacks="language-pack-en"
|
41
|
-
|
42
|
-
if which dpkg >/dev/null 2>&1; then
|
43
|
-
langpacks=`(echo $langpacks &&
|
44
|
-
dpkg -l | grep -E "^ii language-pack-[a-z]* " |
|
45
|
-
cut -d ' ' -f3) | sort -u`
|
46
|
-
fi
|
47
|
-
packages="$packages,$(echo $langpacks | sed 's/ /,/g')"
|
48
|
-
|
49
|
-
echo "installing packages: $packages"
|
50
|
-
|
51
|
-
trap cleanup EXIT SIGHUP SIGINT SIGTERM
|
52
|
-
# check the mini ubuntu was not already downloaded
|
53
|
-
mkdir -p "$cache/partial"
|
54
|
-
if [ $? -ne 0 ]; then
|
55
|
-
echo "Failed to create '$cache/partial' directory"
|
56
|
-
return 1
|
57
|
-
fi
|
58
|
-
|
59
|
-
# download a mini ubuntu into a cache
|
60
|
-
echo "Downloading ubuntu $release minimal ..."
|
61
|
-
if [ -n "$(which qemu-debootstrap)" ]; then
|
62
|
-
qemu-debootstrap --verbose --components=main,universe --arch=$arch --include=$packages $release $cache/partial $MIRROR
|
63
|
-
else
|
64
|
-
debootstrap --verbose --components=main,universe --arch=$arch --include=$packages $release $cache/partial $MIRROR
|
65
|
-
fi
|
66
|
-
|
67
|
-
if [ $? -ne 0 ]; then
|
68
|
-
echo "Failed to download the rootfs, aborting."
|
69
|
-
return 1
|
70
|
-
fi
|
71
|
-
|
72
|
-
# Serge isn't sure whether we should avoid doing this when
|
73
|
-
# $release == `distro-info -d`
|
74
|
-
echo "Installing updates"
|
75
|
-
> $cache/partial/etc/apt/sources.list
|
76
|
-
write_sourceslist $cache/partial/ $arch
|
77
|
-
|
78
|
-
chroot "$1/partial" apt-get update
|
79
|
-
if [ $? -ne 0 ]; then
|
80
|
-
echo "Failed to update the apt cache"
|
81
|
-
return 1
|
82
|
-
fi
|
83
|
-
cat > "$1/partial"/usr/sbin/policy-rc.d << EOF
|
84
|
-
#!/bin/sh
|
85
|
-
exit 101
|
86
|
-
EOF
|
87
|
-
chmod +x "$1/partial"/usr/sbin/policy-rc.d
|
88
|
-
|
89
|
-
lxc-unshare -s MOUNT -- chroot "$1/partial" apt-get dist-upgrade -y || { suggest_flush; false; }
|
90
|
-
|
91
|
-
rm -f "$1/partial"/usr/sbin/policy-rc.d
|
92
|
-
|
93
|
-
chroot "$1/partial" apt-get clean
|
94
|
-
|
95
|
-
mv "$1/partial" "$1/rootfs"
|
96
|
-
trap EXIT
|
97
|
-
trap SIGINT
|
98
|
-
trap SIGTERM
|
99
|
-
trap SIGHUP
|
100
|
-
echo "Download complete"
|
101
|
-
return 0
|
102
|
-
}
|
103
|
-
|
104
|
-
declare cache=`readlink -f .` \
|
105
|
-
arch=$1 \
|
106
|
-
release=$2
|
107
|
-
|
108
|
-
if [ -d "${cache}/rootfs" ]; then
|
109
|
-
echo 'The rootfs cache has been built already, please remove it if you want to update'
|
110
|
-
exit 1
|
111
|
-
fi
|
112
|
-
|
113
|
-
download_ubuntu $cache $arch $release
|
data/boxes/ubuntu/finalize
DELETED
@@ -1,374 +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
|
-
configure_ubuntu()
|
37
|
-
{
|
38
|
-
rootfs=$1
|
39
|
-
release=$2
|
40
|
-
hostname=$2
|
41
|
-
|
42
|
-
# configure the network using the dhcp
|
43
|
-
cat <<EOF > $rootfs/etc/network/interfaces
|
44
|
-
# This file describes the network interfaces available on your system
|
45
|
-
# and how to activate them. For more information, see interfaces(5).
|
46
|
-
|
47
|
-
# The loopback network interface
|
48
|
-
auto lo
|
49
|
-
iface lo inet loopback
|
50
|
-
|
51
|
-
auto eth0
|
52
|
-
iface eth0 inet dhcp
|
53
|
-
EOF
|
54
|
-
|
55
|
-
# set the hostname
|
56
|
-
cat <<EOF > $rootfs/etc/hostname
|
57
|
-
$hostname
|
58
|
-
EOF
|
59
|
-
# set minimal hosts
|
60
|
-
cat <<EOF > $rootfs/etc/hosts
|
61
|
-
127.0.0.1 localhost
|
62
|
-
127.0.1.1 $hostname
|
63
|
-
|
64
|
-
# The following lines are desirable for IPv6 capable hosts
|
65
|
-
::1 ip6-localhost ip6-loopback
|
66
|
-
fe00::0 ip6-localnet
|
67
|
-
ff00::0 ip6-mcastprefix
|
68
|
-
ff02::1 ip6-allnodes
|
69
|
-
ff02::2 ip6-allrouters
|
70
|
-
ff02::3 ip6-allhosts
|
71
|
-
EOF
|
72
|
-
|
73
|
-
if [ ! -f $rootfs/etc/init/container-detect.conf ]; then
|
74
|
-
# suppress log level output for udev
|
75
|
-
sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf
|
76
|
-
|
77
|
-
# remove jobs for consoles 5 and 6 since we only create 4 consoles in
|
78
|
-
# this template
|
79
|
-
rm -f $rootfs/etc/init/tty{5,6}.conf
|
80
|
-
fi
|
81
|
-
|
82
|
-
if ! (grep -q vagrant $rootfs/etc/passwd); then
|
83
|
-
chroot $rootfs useradd --create-home -s /bin/bash vagrant
|
84
|
-
echo "vagrant:vagrant" | chroot $rootfs chpasswd
|
85
|
-
fi
|
86
|
-
|
87
|
-
# make sure we have the current locale defined in the container
|
88
|
-
chroot $rootfs locale-gen en_US.UTF-8
|
89
|
-
chroot $rootfs update-locale LANG=en_US.UTF-8
|
90
|
-
|
91
|
-
return 0
|
92
|
-
}
|
93
|
-
|
94
|
-
# finish setting up the user in the container by injecting ssh key and
|
95
|
-
# adding sudo group membership.
|
96
|
-
# passed-in user is 'vagrant'
|
97
|
-
finalize_user()
|
98
|
-
{
|
99
|
-
user=$1
|
100
|
-
|
101
|
-
sudo_version=$(chroot $rootfs dpkg-query -W -f='${Version}' sudo)
|
102
|
-
|
103
|
-
if chroot $rootfs dpkg --compare-versions $sudo_version gt "1.8.3p1-1"; then
|
104
|
-
groups="sudo"
|
105
|
-
else
|
106
|
-
groups="sudo admin"
|
107
|
-
fi
|
108
|
-
|
109
|
-
for group in $groups; do
|
110
|
-
chroot $rootfs groupadd --system $group >/dev/null 2>&1 || true
|
111
|
-
chroot $rootfs adduser ${user} $group >/dev/null 2>&1 || true
|
112
|
-
done
|
113
|
-
|
114
|
-
chroot $rootfs cp /etc/sudoers /etc/sudoers.orig >/dev/null 2>&1 || true
|
115
|
-
chroot $rootfs sed -i -e 's/%sudo\s\+ALL=(ALL:ALL)\s\+ALL/%sudo ALL=NOPASSWD:ALL/g' /etc/sudoers >/dev/null 2>&1 || true
|
116
|
-
|
117
|
-
if [ -n "$auth_key" -a -f "$auth_key" ]; then
|
118
|
-
u_path="/home/${user}/.ssh"
|
119
|
-
root_u_path="$rootfs/$u_path"
|
120
|
-
|
121
|
-
mkdir -p $root_u_path
|
122
|
-
cp $auth_key "$root_u_path/authorized_keys"
|
123
|
-
chroot $rootfs chown -R ${user}: "$u_path"
|
124
|
-
|
125
|
-
echo "Inserted SSH public key from $auth_key into /home/${user}/.ssh/authorized_keys"
|
126
|
-
fi
|
127
|
-
return 0
|
128
|
-
}
|
129
|
-
|
130
|
-
write_sourceslist()
|
131
|
-
{
|
132
|
-
# $1 => path to the rootfs
|
133
|
-
# $2 => architecture we want to add
|
134
|
-
# $3 => whether to use the multi-arch syntax or not
|
135
|
-
|
136
|
-
case $2 in
|
137
|
-
amd64|i386)
|
138
|
-
MIRROR=${MIRROR:-http://archive.ubuntu.com/ubuntu}
|
139
|
-
SECURITY_MIRROR=${SECURITY_MIRROR:-http://security.ubuntu.com/ubuntu}
|
140
|
-
;;
|
141
|
-
*)
|
142
|
-
MIRROR=${MIRROR:-http://ports.ubuntu.com/ubuntu-ports}
|
143
|
-
SECURITY_MIRROR=${SECURITY_MIRROR:-http://ports.ubuntu.com/ubuntu-ports}
|
144
|
-
;;
|
145
|
-
esac
|
146
|
-
if [ -n "$3" ]; then
|
147
|
-
cat >> "$1/etc/apt/sources.list" << EOF
|
148
|
-
deb [arch=$2] $MIRROR ${release} main restricted universe multiverse
|
149
|
-
deb [arch=$2] $MIRROR ${release}-updates main restricted universe multiverse
|
150
|
-
deb [arch=$2] $SECURITY_MIRROR ${release}-security main restricted universe multiverse
|
151
|
-
deb-src [arch=$2] $MIRROR ${release} main restricted universe multiverse
|
152
|
-
deb-src [arch=$2] $MIRROR ${release}-updates main restricted universe multiverse
|
153
|
-
deb-src [arch=$2] $SECURITY_MIRROR ${release}-security main restricted universe multiverse
|
154
|
-
EOF
|
155
|
-
else
|
156
|
-
cat >> "$1/etc/apt/sources.list" << EOF
|
157
|
-
deb $MIRROR ${release} main restricted universe multiverse
|
158
|
-
deb $MIRROR ${release}-updates main restricted universe multiverse
|
159
|
-
deb $SECURITY_MIRROR ${release}-security main restricted universe multiverse
|
160
|
-
deb-src $MIRROR ${release} main restricted universe multiverse
|
161
|
-
deb-src $MIRROR ${release}-updates main restricted universe multiverse
|
162
|
-
deb-src $SECURITY_MIRROR ${release}-security main restricted universe multiverse
|
163
|
-
EOF
|
164
|
-
fi
|
165
|
-
}
|
166
|
-
|
167
|
-
trim()
|
168
|
-
{
|
169
|
-
rootfs=$1
|
170
|
-
release=$2
|
171
|
-
|
172
|
-
# provide the lxc service
|
173
|
-
cat <<EOF > $rootfs/etc/init/lxc.conf
|
174
|
-
# fake some events needed for correct startup other services
|
175
|
-
|
176
|
-
description "Container Upstart"
|
177
|
-
|
178
|
-
start on startup
|
179
|
-
|
180
|
-
script
|
181
|
-
rm -rf /var/run/*.pid
|
182
|
-
rm -rf /var/run/network/*
|
183
|
-
/sbin/initctl emit stopped JOB=udevtrigger --no-wait
|
184
|
-
/sbin/initctl emit started JOB=udev --no-wait
|
185
|
-
end script
|
186
|
-
EOF
|
187
|
-
|
188
|
-
# fix buggus runlevel with sshd
|
189
|
-
cat <<EOF > $rootfs/etc/init/ssh.conf
|
190
|
-
# ssh - OpenBSD Secure Shell server
|
191
|
-
#
|
192
|
-
# The OpenSSH server provides secure shell access to the system.
|
193
|
-
|
194
|
-
description "OpenSSH server"
|
195
|
-
|
196
|
-
start on filesystem
|
197
|
-
stop on runlevel [!2345]
|
198
|
-
|
199
|
-
expect fork
|
200
|
-
respawn
|
201
|
-
respawn limit 10 5
|
202
|
-
umask 022
|
203
|
-
# replaces SSHD_OOM_ADJUST in /etc/default/ssh
|
204
|
-
oom never
|
205
|
-
|
206
|
-
pre-start script
|
207
|
-
test -x /usr/sbin/sshd || { stop; exit 0; }
|
208
|
-
test -e /etc/ssh/sshd_not_to_be_run && { stop; exit 0; }
|
209
|
-
test -c /dev/null || { stop; exit 0; }
|
210
|
-
|
211
|
-
mkdir -p -m0755 /var/run/sshd
|
212
|
-
end script
|
213
|
-
|
214
|
-
# if you used to set SSHD_OPTS in /etc/default/ssh, you can change the
|
215
|
-
# 'exec' line here instead
|
216
|
-
exec /usr/sbin/sshd
|
217
|
-
EOF
|
218
|
-
|
219
|
-
cat <<EOF > $rootfs/etc/init/console.conf
|
220
|
-
# console - getty
|
221
|
-
#
|
222
|
-
# This service maintains a console on tty1 from the point the system is
|
223
|
-
# started until it is shut down again.
|
224
|
-
|
225
|
-
start on stopped rc RUNLEVEL=[2345]
|
226
|
-
stop on runlevel [!2345]
|
227
|
-
|
228
|
-
respawn
|
229
|
-
exec /sbin/getty -8 38400 /dev/console
|
230
|
-
EOF
|
231
|
-
|
232
|
-
cat <<EOF > $rootfs/lib/init/fstab
|
233
|
-
# /lib/init/fstab: cleared out for bare-bones lxc
|
234
|
-
EOF
|
235
|
-
|
236
|
-
# remove pointless services in a container
|
237
|
-
chroot $rootfs /usr/sbin/update-rc.d -f ondemand remove
|
238
|
-
|
239
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls u*.conf); do mv $f $f.orig; done'
|
240
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls tty[2-9].conf); do mv $f $f.orig; done'
|
241
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls plymouth*.conf); do mv $f $f.orig; done'
|
242
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls hwclock*.conf); do mv $f $f.orig; done'
|
243
|
-
chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls module*.conf); do mv $f $f.orig; done'
|
244
|
-
|
245
|
-
# if this isn't lucid, then we need to twiddle the network upstart bits :(
|
246
|
-
if [ $release != "lucid" ]; then
|
247
|
-
sed -i 's/^.*emission handled.*$/echo Emitting lo/' $rootfs/etc/network/if-up.d/upstart
|
248
|
-
fi
|
249
|
-
}
|
250
|
-
|
251
|
-
post_process()
|
252
|
-
{
|
253
|
-
rootfs=$1
|
254
|
-
release=$2
|
255
|
-
trim_container=$3
|
256
|
-
|
257
|
-
if [[ $trim_container -eq 1 ]]; then
|
258
|
-
trim $rootfs $release
|
259
|
-
elif [ ! -f $rootfs/etc/init/container-detect.conf ]; then
|
260
|
-
# Make sure we have a working resolv.conf
|
261
|
-
cresolvonf="${rootfs}/etc/resolv.conf"
|
262
|
-
mv $cresolvonf ${cresolvonf}.lxcbak
|
263
|
-
cat /etc/resolv.conf > ${cresolvonf}
|
264
|
-
|
265
|
-
# for lucid, if not trimming, then add the ubuntu-virt
|
266
|
-
# ppa and install lxcguest
|
267
|
-
if [ $release = "lucid" ]; then
|
268
|
-
chroot $rootfs apt-get update
|
269
|
-
chroot $rootfs apt-get install --force-yes -y python-software-properties
|
270
|
-
chroot $rootfs add-apt-repository ppa:ubuntu-virt/ppa
|
271
|
-
fi
|
272
|
-
|
273
|
-
chroot $rootfs apt-get update
|
274
|
-
chroot $rootfs apt-get install --force-yes -y lxcguest
|
275
|
-
|
276
|
-
# Restore old resolv.conf
|
277
|
-
rm -f ${cresolvonf}
|
278
|
-
mv ${cresolvonf}.lxcbak ${cresolvonf}
|
279
|
-
fi
|
280
|
-
|
281
|
-
# If the container isn't running a native architecture, setup multiarch
|
282
|
-
if [ -x "$(ls -1 ${rootfs}/usr/bin/qemu-*-static 2>/dev/null)" ]; then
|
283
|
-
dpkg_version=$(chroot $rootfs dpkg-query -W -f='${Version}' dpkg)
|
284
|
-
if chroot $rootfs dpkg --compare-versions $dpkg_version ge "1.16.2"; then
|
285
|
-
chroot $rootfs dpkg --add-architecture ${hostarch}
|
286
|
-
else
|
287
|
-
mkdir -p ${rootfs}/etc/dpkg/dpkg.cfg.d
|
288
|
-
echo "foreign-architecture ${hostarch}" > ${rootfs}/etc/dpkg/dpkg.cfg.d/lxc-multiarch
|
289
|
-
fi
|
290
|
-
|
291
|
-
# Save existing value of MIRROR and SECURITY_MIRROR
|
292
|
-
DEFAULT_MIRROR=$MIRROR
|
293
|
-
DEFAULT_SECURITY_MIRROR=$SECURITY_MIRROR
|
294
|
-
|
295
|
-
# Write a new sources.list containing both native and multiarch entries
|
296
|
-
> ${rootfs}/etc/apt/sources.list
|
297
|
-
write_sourceslist $rootfs $arch "native"
|
298
|
-
|
299
|
-
MIRROR=$DEFAULT_MIRROR
|
300
|
-
SECURITY_MIRROR=$DEFAULT_SECURITY_MIRROR
|
301
|
-
write_sourceslist $rootfs $hostarch "multiarch"
|
302
|
-
|
303
|
-
# Finally update the lists and install upstart using the host architecture
|
304
|
-
chroot $rootfs apt-get update
|
305
|
-
chroot $rootfs apt-get install --force-yes -y --no-install-recommends upstart:${hostarch} mountall:${hostarch} iproute:${hostarch} isc-dhcp-client:${hostarch}
|
306
|
-
fi
|
307
|
-
|
308
|
-
# rmdir /dev/shm for containers that have /run/shm
|
309
|
-
# I'm afraid of doing rm -rf $rootfs/dev/shm, in case it did
|
310
|
-
# get bind mounted to the host's /run/shm. So try to rmdir
|
311
|
-
# it, and in case that fails move it out of the way.
|
312
|
-
if [ ! -L $rootfs/dev/shm ] && [ -d $rootfs/run/shm ] && [ -e $rootfs/dev/shm ]; then
|
313
|
-
mv $rootfs/dev/shm $rootfs/dev/shm.bak
|
314
|
-
ln -s /run/shm $rootfs/dev/shm
|
315
|
-
fi
|
316
|
-
}
|
317
|
-
|
318
|
-
release=precise # Default to the last Ubuntu LTS release for non-Ubuntu systems
|
319
|
-
if [ -f /etc/lsb-release ]; then
|
320
|
-
. /etc/lsb-release
|
321
|
-
if [ "$DISTRIB_ID" = "Ubuntu" ]; then
|
322
|
-
release=$DISTRIB_CODENAME
|
323
|
-
fi
|
324
|
-
fi
|
325
|
-
|
326
|
-
arch=$(uname -m)
|
327
|
-
|
328
|
-
# Code taken from debootstrap
|
329
|
-
if [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-architecture >/dev/null 2>&1; then
|
330
|
-
arch=`/usr/bin/dpkg --print-architecture`
|
331
|
-
elif type udpkg >/dev/null 2>&1 && udpkg --print-architecture >/dev/null 2>&1; then
|
332
|
-
arch=`/usr/bin/udpkg --print-architecture`
|
333
|
-
else
|
334
|
-
arch=$(uname -m)
|
335
|
-
if [ "$arch" = "i686" ]; then
|
336
|
-
arch="i386"
|
337
|
-
elif [ "$arch" = "x86_64" ]; then
|
338
|
-
arch="amd64"
|
339
|
-
elif [ "$arch" = "armv7l" ]; then
|
340
|
-
arch="armel"
|
341
|
-
fi
|
342
|
-
fi
|
343
|
-
|
344
|
-
|
345
|
-
if [ "$(id -u)" != "0" ]; then
|
346
|
-
echo "This script should be run as 'root'"
|
347
|
-
exit 1
|
348
|
-
fi
|
349
|
-
|
350
|
-
declare cache=`readlink -f .` \
|
351
|
-
arch=$1 \
|
352
|
-
release=$2 \
|
353
|
-
auth_key=$3
|
354
|
-
|
355
|
-
# detect rootfs
|
356
|
-
cache=`readlink -f .`
|
357
|
-
rootfs="${cache}/rootfs"
|
358
|
-
|
359
|
-
configure_ubuntu $rootfs $release
|
360
|
-
if [ $? -ne 0 ]; then
|
361
|
-
echo "failed to configure ubuntu $release for a container"
|
362
|
-
exit 1
|
363
|
-
fi
|
364
|
-
|
365
|
-
post_process $rootfs $release $trim_container
|
366
|
-
|
367
|
-
finalize_user vagrant
|
368
|
-
|
369
|
-
echo ""
|
370
|
-
echo "##"
|
371
|
-
echo "# The default user is 'vagrant' with password 'vagrant'!"
|
372
|
-
echo "# Use the 'sudo' command to run tasks as root in the container."
|
373
|
-
echo "##"
|
374
|
-
echo ""
|