summaryrefslogtreecommitdiff
path: root/tools/build-on-freebsd
blob: 7d19f44ca5dc16baa24db86428ae0901e23b7fb1 (plain)
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
#!/bin/sh
# Since there is no official FreeBSD port yet, we need some way of building and
# installing cloud-init. This script takes care of building and installing. It
# will optionally make a first run at the end.

# Since there is no python by default, create a symlink for convenience sake:
ln -sf /usr/local/bin/python2.7 /usr/local/bin/python

# Check dependencies:
[ ! -f /tmp/c-i.dependencieschecked ] && pkg install py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six py27-boto gpart sudo dmidecode
touch /tmp/c-i.dependencieschecked

# Required but unavailable port/pkg: py27-jsonpatch py27-jsonpointer
# Luckily, the install step will take care of this by installing it from pypi...

# Build the code and install in /usr/local/:
python setup.py build
python setup.py install -O1 --skip-build --prefix /usr/local/ --init-system sysvinit_freebsd

# Move the configdir to /usr/local/ and use freebsd.cfg:
[ -d /usr/local/etc/cloud ] && rm -rf /usr/local/etc/cloud
mv /etc/cloud /usr/local/etc/
mv /usr/local/etc/cloud/cloud.freebsd.cfg /usr/local/etc/cloud/cloud.cfg

# Enable cloud-init in /etc/rc.conf:
sed -i.bak -e "/cloudinit_enable=.*/d" /etc/rc.conf
echo 'cloudinit_enable="YES"' >> /etc/rc.conf

echo "Installation completed."

if [ "$1" = "run" ]
then
	echo "Ok, now let's see if it works."

	# Backup SSH keys
	mv /etc/ssh/ssh_host_* /tmp/

	# Remove old metadata
	rm -rf /var/lib/cloud

	# Just log everything, quick&dirty
	rm /usr/local/etc/cloud/cloud.cfg.d/05_logging.cfg 

	# Start:
	/usr/local/etc/rc.d/cloudinit start

	# Restore SSH keys
	mv /tmp/ssh_host_* /etc/ssh/
fi