#!/bin/bash -e

. ../../xi-sys.cfg

chown "$apacheuser:$nagiosgroup" /etc/nagios-mod-gearman/*.conf
chmod 664 /etc/nagios-mod-gearman/*.conf

if [ "$distro" == "Debian" ] || [ "$distro" == "Ubuntu" ]; then
    sed -i 's/--listen=[^[:space:]]*[[:space:]]*\\//g' /etc/default/gearman-job-server
    systemctl enable gearman-job-server
    systemctl restart gearman-job-server
else
    systemctl enable gearmand
fi

set +e
if [ `command -v firewall-cmd` ]; then
    firewall-cmd --zone=public --add-port=4730/tcp --permanent
    firewall-cmd --reload
else
    iptables -A INPUT -p tcp --dport 4730 -j ACCEPT
fi
set -e
