-
Notifications
You must be signed in to change notification settings - Fork 0
/
genlxcbox-debian-jessie.sh
executable file
·51 lines (43 loc) · 1.42 KB
/
genlxcbox-debian-jessie.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# genlxcbox-debian-jessie.sh
# lxc.conf
cat << EOF > lxc.conf
lxc.network.type = empty
EOF
# lxc-template
sed -e 's/,release:,clean/,release:,clean:,tarball:,auth-key/' \
-e 's/ dhcp/ manual/' \
-e '146i\ ' \
-e "146i\ chroot \$rootfs sed -i -e '/127.0.0.1/s/localhost/localhost '\$hostname'/' /etc/hosts" \
-e '147i\ #setup vagrant user' \
-e '147i\ chroot $rootfs adduser --disabled-password --gecos Vagrant vagrant' \
-e '147i\ chroot $rootfs adduser vagrant sudo' \
-e '147i\ echo "vagrant ALL=(ALL) NOPASSWD: ALL" | chroot $rootfs tee -a /etc/sudoers.d/vagrant' \
-e '147i\ chroot --userspec=vagrant:vagrant $rootfs mkdir -p /home/vagrant/.ssh/' \
-e '147i\ echo "vagrant:vagrant" | chroot $rootfs chpasswd' \
-e '147i\ echo "'"$(cat /usr/share/vagrant/keys/vagrant.pub)"'" | sudo chroot --userspec=vagrant:vagrant $rootfs tee -a "/home/vagrant/.ssh/authorized_keys"' \
-e '147i\ ' \
-e '170i sudo,\\' \
/usr/share/lxc/templates/lxc-debian \
> lxc-template
# metadata.json
cat << EOF > metadata.json
{
"provider": "lxc",
"version": "3",
"built-on": "$(date)",
"template-opts": {
"--release": "jessie"
}
}
EOF
# rootfs.tar.gz
mkdir rootfs \
&& tar -cf rootfs.tar.gz rootfs \
&& rmdir rootfs
# jessie.box
tar -czf jessie.box ./
# install
# scp jessie.box webserver:www/
# vagrant box remove jessie lxc
# vagrant box add jessie http://webserver.local/jessie.box --provider lxc