#!/bin/bash
set -eux
# If NEUTRON_VENV_DIR is set, then need to fix up the dhcp.filters rootwrap file to allow dhcp-agent to
# kill processes when networks are deleted.
if [ -n "${NEUTRON_VENV_DIR}" ]
then
    sed -i "s, python, ${NEUTRON_VENV_DIR}/bin/python," /etc/neutron/rootwrap.d/dhcp.filters
fi

install-packages dnsmasq dnsmasq-utils

os-svc-daemon -i "$NEUTRON_VENV_DIR" -n neutron-dhcp-agent -u neutron -c neutron-dhcp-agent -- --config-file /etc/neutron/dhcp_agent.ini --config-dir /etc/neutron
