forked from paraisospelosul/Streamswitch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
141 lines (125 loc) · 3.74 KB
/
Copy pathinstall.sh
File metadata and controls
141 lines (125 loc) · 3.74 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
set -e
# Make sure the script is run as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root (sudo ./install.sh)"
exit 1
fi
echo "==========================================="
echo " Installing StreamSwitch + Belabox Receiver"
echo "==========================================="
echo ""
echo "Please set up a username and password to protect the Web Panel:"
read -p "Username (default: belabox): " WEB_USER
WEB_USER=${WEB_USER:-belabox}
read -s -p "Password (default: belabox): " WEB_PASS
echo ""
WEB_PASS=${WEB_PASS:-belabox}
# Update and install dependencies
echo "[1/6] Installing system dependencies..."
apt-get update
apt-get install -y ffmpeg curl wget git jq net-tools
# Install Docker if not present
if ! command -v docker &> /dev/null; then
echo "[2/6] Installing Docker..."
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
rm get-docker.sh
else
echo "[2/6] Docker already installed, skipping..."
fi
# Install Go if not present
if ! command -v go &> /dev/null; then
echo "[3/6] Installing Go..."
wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz
rm -rf /usr/local/go
tar -C /usr/local -xzf go1.22.2.linux-amd64.tar.gz
rm go1.22.2.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile
else
echo "[3/6] Go already installed, skipping..."
fi
# Create directory structure
echo "[4/6] Setting up directories..."
mkdir -p /opt/streamswitch
cd /opt/streamswitch
# Setup Belabox Receiver initial files
echo "[5/6] Setting up Belabox Receiver (Docker)..."
cat << 'EOF' > docker-compose.yml
services:
bbox:
image: datagutt/belabox-receiver:latest
container_name: bbox
restart: unless-stopped
ports:
- "5000:5000/udp"
- "8282:8282/udp"
- "8181:8181/tcp"
- "3000:3000/tcp"
volumes:
- ./config.json:/app/config.json:ro
security_opt:
- no-new-privileges:true
tmpfs:
- /tmp:size=64m,noexec,nosuid,nodev
- /var/log:size=64m,noexec,nosuid,nodev
pids_limit: 256
mem_limit: 1g
cpus: "2.0"
logging:
driver: json-file
options:
max-size: "10m"
EOF
cat << 'EOF' > config.json
{
"auth": [
{
"user": "belabox",
"key": "belabox"
}
]
}
EOF
# Build and start StreamSwitch
echo "[6/6] Building and configuring StreamSwitch..."
# Check if source code exists locally, otherwise git clone (assuming local copy for now)
if [ -f "main.go" ]; then
$(command -v go) build -o streamswitch_final .
mv streamswitch_final streamswitch
chmod +x streamswitch
else
echo "Warning: Source files not found in /opt/streamswitch. Make sure to copy them before running the service."
fi
# Create systemd service
cat << 'EOF' > /etc/systemd/system/streamswitch.service
[Unit]
Description=StreamSwitch Server
After=network.target docker.service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/streamswitch
Environment="WEB_USER=${WEB_USER}"
Environment="WEB_PASS=${WEB_PASS}"
ExecStart=/opt/streamswitch/streamswitch
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable streamswitch
# Don't start automatically yet, user might need to copy files first if they are not there
# systemctl start streamswitch
echo "==========================================="
echo " Installation Complete!"
echo " "
echo " Next steps:"
echo " 1. Make sure all .go files and the 'web' folder are in /opt/streamswitch"
echo " 2. Compile: cd /opt/streamswitch && go build -o streamswitch ."
echo " 3. Start service: sudo systemctl start streamswitch"
echo " 4. StreamSwitch Web UI will be on port 80"
echo " 5. Bbox receiver Web UI will be on port 8181"
echo "==========================================="