forked from milos85vasic/Server-Factory-Utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
disable_iptables_for_avahi_mdns.sh
executable file
·44 lines (30 loc) · 1.11 KB
/
disable_iptables_for_avahi_mdns.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
stop_ip_tables="$1"
if systemctl is-active --quiet avahi-daemon; then
echo "Avahi Daemon is running, stop_ip_tables: '$stop_ip_tables'"
if systemctl is-active --quiet iptables; then
if [ "$stop_ip_tables" = "true" ]; then
if systemctl stop iptables && systemctl disable iptables >/dev/null 2>&1; then
echo "Iptables service is disabled for Avahi mDNS"
systemctl restart avahi-daemon.service >/dev/null 2>&1
fi
else
echo "Iptables service Avahi mDNS will not be stopped"
fi
else
echo "Iptables service is not running for Avahi mDNS"
fi
if systemctl is-active --quiet firewalld; then
if [ "$stop_ip_tables" = "true" ]; then
if firewall-cmd --add-service=mdns >/dev/null 2>&1 && \
firewall-cmd --permanent --add-service=mdns >/dev/null 2>&1; then
echo "Firewalld service is ready for Avahi mDNS"
systemctl restart avahi-daemon.service >/dev/null 2>&1;
fi
else
echo "Firewalld service will not be modified for Avahi mDNS"
fi
else
echo "Firewalld service is not running for Avahi mDNS"
fi
fi