Skip to content

Commit 0a34e0c

Browse files
committed
Add firewalld support to apply-lib.sh
1 parent a492ea5 commit 0a34e0c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

bigbluebutton-config/bin/apply-lib.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,51 @@ enableUFWRules() {
123123
ufw --force enable
124124
}
125125

126+
#
127+
# Enable firewalld rules to open only
128+
#
129+
enableFirewalldRules() {
130+
echo " - Enable Firewalld and opening 22/tcp, 80/tcp, 443/tcp and 16384:32768/udp"
131+
132+
if ! which firewall-cmd > /dev/null; then
133+
apt-get install -y firewalld
134+
fi
135+
136+
# Ensure firewalld is running
137+
systemctl enable firewalld
138+
systemctl start firewalld
139+
140+
# Use existing firewalld services and direct port commands
141+
firewall-cmd --permanent --add-service=ssh
142+
firewall-cmd --permanent --add-service=http
143+
firewall-cmd --permanent --add-service=https
144+
firewall-cmd --permanent --add-port=16384-32768/udp
145+
146+
# Check if haproxy is running and open port 3478
147+
if systemctl is-enabled haproxy > /dev/null 2>&1; then
148+
if systemctl -q is-active haproxy; then
149+
echo " - Local haproxy detected and running -- opening port 3478"
150+
firewall-cmd --permanent --add-port=3478/tcp
151+
firewall-cmd --permanent --add-port=3478/udp
152+
else
153+
if firewall-cmd --list-ports | grep -q "3478/tcp\|3478/udp"; then
154+
echo " - Local haproxy not running -- closing port 3478"
155+
firewall-cmd --permanent --remove-port=3478/tcp
156+
firewall-cmd --permanent --remove-port=3478/udp
157+
fi
158+
fi
159+
else
160+
if firewall-cmd --list-ports | grep -q "3478/tcp\|3478/udp"; then
161+
echo " - Local haproxy not running -- closing port 3478"
162+
firewall-cmd --permanent --remove-port=3478/tcp
163+
firewall-cmd --permanent --remove-port=3478/udp
164+
fi
165+
fi
166+
167+
# Reload firewalld to apply changes
168+
firewall-cmd --reload
169+
}
170+
126171

127172
notCalled() {
128173
#
@@ -145,6 +190,7 @@ source /etc/bigbluebutton/bbb-conf/apply-lib.sh
145190
146191
#enableHTML5ClientLog
147192
#enableUFWRules
193+
#enableFirewalldRules
148194
149195
150196
# Shorten the FreeSWITCH "you have been muted" and "you have been unmuted" prompts

0 commit comments

Comments
 (0)