stremio/deploy/node/install.sh
Jos Vooges | STH a5c6fd5fe4 Initial commit: Distributed Stremio Media Cluster V1
Master API, Admin UI, Go media-node, Docker/Dokploy deploy configs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 00:17:04 +02:00

63 lines
1.7 KiB
Bash

#!/usr/bin/env bash
set -euo pipefail
VERSION="${MEDIA_NODE_VERSION:-1.0.0}"
ARCH="${MEDIA_NODE_ARCH:-$(uname -m)}"
INSTALL_DIR="/usr/local/bin"
CONFIG_DIR="/etc/media-node"
DATA_DIR="/var/lib/media-node"
SERVICE_USER="media-node"
case "$ARCH" in
x86_64) GOARCH="amd64" ;;
aarch64) GOARCH="arm64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
BINARY="media-node-linux-${GOARCH}"
DOWNLOAD_URL="${MEDIA_NODE_DOWNLOAD_URL:-https://releases.example.com/media-node/${VERSION}/${BINARY}}"
echo "=== STH Media Node Installer ==="
echo "Version: $VERSION"
echo "Architecture: $GOARCH"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root (sudo)"
exit 1
fi
# Create service user
if ! id "$SERVICE_USER" &>/dev/null; then
useradd --system --no-create-home --shell /usr/sbin/nologin "$SERVICE_USER"
echo "Created user: $SERVICE_USER"
fi
# Create directories
mkdir -p "$CONFIG_DIR/credentials" "$DATA_DIR"
chmod 750 "$CONFIG_DIR" "$DATA_DIR"
chown -R "$SERVICE_USER:$SERVICE_USER" "$DATA_DIR"
chown -R root:"$SERVICE_USER" "$CONFIG_DIR"
chmod 750 "$CONFIG_DIR/credentials"
# Download binary (or use local if building)
if [[ -f "./${BINARY}" ]]; then
cp "./${BINARY}" "$INSTALL_DIR/media-node"
else
echo "Downloading from $DOWNLOAD_URL..."
curl -fsSL "$DOWNLOAD_URL" -o "$INSTALL_DIR/media-node"
fi
chmod 755 "$INSTALL_DIR/media-node"
# Install systemd service
cp deploy/node/media-node.service /etc/systemd/system/media-node.service
systemctl daemon-reload
# Run interactive setup
"$INSTALL_DIR/media-node" install
systemctl enable media-node
systemctl start media-node
echo ""
echo "Media Node installed and started!"
echo "Check status: systemctl status media-node"