Spotify-tracker/deploy.sh
RTSDA 3c37d91bc4 Add complete runit service configuration and deployment scripts
- Add runit service files for spotify-tracker daemon
- Include log service configuration with svlogd
- Create automated deploy.sh script for server setup
- Add comprehensive deployment documentation
- Service runs as dedicated spotify-tracker user
- Includes service management commands and troubleshooting guide
2025-08-20 09:26:24 -04:00

68 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
set -e
# Spotify Tracker Deployment Script
echo "🎵 Deploying Spotify Tracker..."
# Configuration
SERVICE_NAME="spotify-tracker"
INSTALL_DIR="/opt/spotify-tracker"
SERVICE_DIR="/etc/sv/spotify-tracker"
USER="spotify-tracker"
GROUP="spotify-tracker"
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
# Create user if it doesn't exist
if ! id "$USER" &>/dev/null; then
echo "Creating user: $USER"
useradd -r -s /bin/false -d "$INSTALL_DIR" "$USER"
fi
# Create directories
echo "Creating directories..."
mkdir -p "$INSTALL_DIR"
mkdir -p "/var/log/$SERVICE_NAME"
mkdir -p "$SERVICE_DIR"
mkdir -p "$SERVICE_DIR/log"
# Build the application
echo "Building Spotify Tracker..."
cd "$INSTALL_DIR"
cargo build --release
# Set ownership
echo "Setting permissions..."
chown -R "$USER:$GROUP" "$INSTALL_DIR"
chown -R "$USER:$GROUP" "/var/log/$SERVICE_NAME"
# Copy runit service files
echo "Installing runit service..."
cp runit/spotify-tracker/run "$SERVICE_DIR/run"
cp runit/spotify-tracker/log/run "$SERVICE_DIR/log/run"
# Make scripts executable
chmod +x "$SERVICE_DIR/run"
chmod +x "$SERVICE_DIR/log/run"
# Enable and start service
echo "Starting service..."
ln -sf "$SERVICE_DIR" /var/service/
echo "✅ Deployment complete!"
echo ""
echo "Service commands:"
echo " sv status spotify-tracker - Check status"
echo " sv start spotify-tracker - Start service"
echo " sv stop spotify-tracker - Stop service"
echo " sv restart spotify-tracker - Restart service"
echo " tail -f /var/log/spotify-tracker/current - View logs"
echo ""
echo "Configure Caddy with:"
echo " spotify.tougie.live {"
echo " reverse_proxy localhost:8888"
echo " }"