#!/bin/sh

pidof pluto >/dev/null && ipsec setup stop 2> /dev/null

cd /source

# we use /tmp because it is on tmpfs and compiles much faster, even faster
# than using ccache on the regular disk image files.
make OBJDIR=/tmp/lsw_build install 2>&1 >> compile-log.txt

make module_install 2>&1 >> compile-log.txt

# ensure selinux bits
restorecon /usr/local/sbin -Rv
restorecon /usr/local/libexec/ipsec -Rv
# disable autostarting via service or systemd
if [ -x /usr/bin/systemctl -o -x /usr/sbin/systemctl -o -x /sbin/systemctl ] ; then
	sed -i "s/Restart=always/Restart=no/" /lib/systemd/system/ipsec.service
	systemctl disable ipsec.service
	systemctl daemon-reload
else
	service ipsec disable
fi
