bootstrap-freebsd.sh 1016 Bytes
Newer Older
1 2
#!/bin/sh

Oliver Pinter committed
3
export LOGLEVEL=DEBUG
Oliver Pinter committed
4

Oliver Pinter committed
5
pkg install -y devel/git lang/python devel/py-pip sysutils/screen editors/vim-lite security/sudo
6

7 8 9 10 11 12 13 14 15
grep "^cloud:" /etc/passwd > /dev/null
ret=$?
if [ $ret -ne 0 ]
then
	# create the required backdoor user
	pw user add cloud -m
	pw group mod wheel -m cloud
fi

Oliver Pinter committed
16 17
sed -i '.orig' -e 's/# \(%wheel ALL=(ALL) ALL\)/\1/g' /usr/local/etc/sudoers

18 19 20 21 22 23 24 25
if [ ! -d /usr/ports ]
then
	git clone https://github.com/HardenedBSD/freebsd-ports.git /usr/ports
fi

if [ ! -d /root/agent ]
then
	cd /root
Oliver Pinter committed
26
	git clone https://github.com/opntr/bme-cloud-circle-agent.git agent
27 28
fi

29 30 31 32 33 34 35
grep "If a service" /etc/rc.subr
ret=$?
if [ $ret -eq 0 ]
then
	echo "patching /etc/rc.subr ..."
	(
	cd /etc
Oliver Pinter committed
36
	patch -p0 < /root/agent/bootstrap/freebsd/fix-rc.subr.diff
37 38 39
	)
fi

40 41 42 43 44 45 46 47 48 49 50 51
cd /root/agent
if [ -d /usr/local/etc/rc.d ]
then
	cp bootstrap/freebsd/rc.d/circle_agent /usr/local/etc/rc.d
fi

if [ ! -f /etc/rc.conf.d/circle_agent ]
then
	echo 'circle_agent_enable="YES"' > /etc/rc.conf.d/circle_agent
fi

service circle_agent start