Files
AstraDeploy/lib/firewall.sh

31 lines
703 B
Bash

#!/usr/bin/env bash
open_firewall_port() {
local port="$1"
local proto="$2"
if [[ "$FIREWALL" != "yes" ]]; then
info "$(t firewall_skip)"
return 0
fi
emit_step "firewall_start" "$port/$proto"
if command -v ufw >/dev/null 2>&1; then
run_cmd ufw allow "$port/$proto" || true
run_cmd ufw --force enable || true
emit_step "firewall_done" "ufw"
return 0
fi
if command -v firewall-cmd >/dev/null 2>&1; then
run_cmd firewall-cmd --permanent --add-port="$port/$proto"
run_cmd firewall-cmd --reload
emit_step "firewall_done" "firewalld"
return 0
fi
warn "$(t firewall_manual_open "$port" "$proto")"
emit_step "firewall_manual" "$port/$proto"
}