diskimage-builder/elements/ironic-agent/post-install.d/80-ironic-agent
stephane dd7648277f ironic-agent postinst fails on systemd with no iptables
Where the base install for the image uses systemd but
the iptables service is not present, the postinstall
script for the ironic-agent element can fail. This is
due to 'systemctl disable iptables.service' returning
an error status when the service isn't present. Check
whether the service is enabled using 'systemctl
list-unit-files'.

Change-Id: I8069b062a27caead4097747d7aeae24a5262e117
2016-03-21 19:27:57 -07:00

33 lines
697 B
Bash
Executable File

#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
install-packages -e git cloud-init
rm -rf /tmp/ironic-python-agent
case "$DIB_INIT_SYSTEM" in
upstart)
if [ -f /etc/init/ufw.conf ]; then
mv /etc/init/ufw.conf /etc/init/ufw.conf.disabled
fi
;;
systemd)
if [[ $(systemctl --no-pager list-unit-files iptables) =~ 'enabled' ]]; then
systemctl disable iptables.service
fi
systemctl enable $(svc-map ironic-python-agent).service
;;
sysv)
update-rc.d iptables disable
;;
*)
echo "Unsupported init system"
exit 1
;;
esac