Files
beStream/scripts/open-ports.sh
2025-12-14 12:57:37 +01:00

82 lines
2.3 KiB
Bash

#!/bin/bash
###############################################################################
# beStream - Open Firewall Ports for *Arr Services
#
# This script opens the required ports for:
# - Radarr (Movies) - Port 7878
# - Sonarr (TV Shows) - Port 8989
# - Lidarr (Music) - Port 8686
# - beStream Backend (optional) - Port 3001
#
# Usage: sudo bash open-ports.sh
###############################################################################
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Ports
RADARR_PORT=7878
SONARR_PORT=8989
LIDARR_PORT=8686
BESTREAM_PORT=3001
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE} Opening Firewall Ports${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo -e "${RED}Please run as root (use sudo)${NC}"
exit 1
fi
# Check if UFW is installed
if ! command -v ufw &> /dev/null; then
echo -e "${YELLOW}UFW is not installed. Installing...${NC}"
apt update
apt install -y ufw
fi
# Enable UFW if not already enabled
if ! ufw status | grep -q "Status: active"; then
echo -e "${YELLOW}UFW is not active. Enabling...${NC}"
ufw --force enable
fi
# Open ports
echo -e "${GREEN}Opening ports...${NC}"
ufw allow $RADARR_PORT/tcp comment 'Radarr - Movies'
ufw allow $SONARR_PORT/tcp comment 'Sonarr - TV Shows'
ufw allow $LIDARR_PORT/tcp comment 'Lidarr - Music'
ufw allow $BESTREAM_PORT/tcp comment 'beStream Backend'
echo ""
echo -e "${GREEN}Ports opened successfully!${NC}"
echo ""
echo -e "${BLUE}Opened Ports:${NC}"
echo -e " ${GREEN}${NC} $RADARR_PORT/tcp - Radarr (Movies)"
echo -e " ${GREEN}${NC} $SONARR_PORT/tcp - Sonarr (TV Shows)"
echo -e " ${GREEN}${NC} $LIDARR_PORT/tcp - Lidarr (Music)"
echo -e " ${GREEN}${NC} $BESTREAM_PORT/tcp - beStream Backend"
echo ""
# Show firewall status
echo -e "${BLUE}Current Firewall Status:${NC}"
ufw status numbered
echo ""
echo -e "${YELLOW}Note: If you're accessing from a remote network, make sure:${NC}"
echo " 1. Your router forwards these ports (if needed)"
echo " 2. Your cloud provider's firewall allows these ports"
echo " 3. You're using the correct server IP address"
echo ""