Initial commit of Docker files
This commit is contained in:
205
setup.sh
Executable file
205
setup.sh
Executable file
@@ -0,0 +1,205 @@
|
||||
#!/bin/bash
|
||||
# ===========================================
|
||||
# Docker Media Stack Setup Script
|
||||
# ===========================================
|
||||
|
||||
set -e # Exit on any error
|
||||
|
||||
echo "🚀 Setting up Docker Media & Utility Stack..."
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print colored output
|
||||
print_status() {
|
||||
echo -e "${GREEN}[INFO]${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}[ERROR]${NC} $1"
|
||||
}
|
||||
|
||||
# Check if Docker and Docker Compose are installed
|
||||
check_dependencies() {
|
||||
print_status "Checking dependencies..."
|
||||
|
||||
if ! command -v docker &> /dev/null; then
|
||||
print_error "Docker is not installed. Please install Docker first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! command -v docker compose &> /dev/null; then
|
||||
print_error "Docker Compose is not installed. Please install Docker Compose first."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
print_status "Dependencies check passed ✓"
|
||||
}
|
||||
|
||||
# Create necessary directories
|
||||
create_directories() {
|
||||
print_status "Creating directory structure..."
|
||||
|
||||
# Main data directories
|
||||
sudo mkdir -p /data/{movies,tv,music,torrents}
|
||||
|
||||
# Docker config directories
|
||||
mkdir -p ../docker-local/{Arrs/{Sonarr,Radarr,Lidarr,Bazarr,Prowlarr,Jellyfin,Jellyseerr}/config,speedtest-tracker/{data,db},rustdesk/data,gramps,syncthing,obsidian/{vaults,config}}
|
||||
|
||||
# Application specific directories
|
||||
mkdir -p {qBittorrent,Homepage,filebrowser,maloja,scrobble,stirling/latest,paperless,gramps,racknerd-converter}/config
|
||||
mkdir -p {Homepage/config/{images,icons},filebrowser/data,maloja/{data,logs},stirling/latest/{data,config,logs},paperless/{data,media,export,consume},racknerd-converter/{data,logs}}
|
||||
|
||||
print_status "Directories created ✓"
|
||||
}
|
||||
|
||||
# Set proper permissions
|
||||
set_permissions() {
|
||||
print_status "Setting permissions..."
|
||||
|
||||
# Get current user ID and group ID
|
||||
CURRENT_UID=$(id -u)
|
||||
CURRENT_GID=$(id -g)
|
||||
|
||||
# Set ownership for data directories
|
||||
if [ -d "/data" ]; then
|
||||
sudo chown -R $CURRENT_UID:$CURRENT_GID /data
|
||||
fi
|
||||
|
||||
# Set ownership for config directories
|
||||
if [ -d "../docker-local" ]; then
|
||||
chown -R $CURRENT_UID:$CURRENT_GID ../docker-local
|
||||
fi
|
||||
|
||||
# Set ownership for local directories
|
||||
chown -R $CURRENT_UID:$CURRENT_GID .
|
||||
|
||||
print_status "Permissions set ✓"
|
||||
}
|
||||
|
||||
# Validate environment file
|
||||
validate_environment() {
|
||||
print_status "Validating environment configuration..."
|
||||
|
||||
if [ ! -f ".env" ]; then
|
||||
print_error ".env file not found. Please ensure it exists."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for required variables
|
||||
required_vars=("TZ" "PUID" "PGID" "DOMAIN" "DATA_ROOT")
|
||||
|
||||
for var in "${required_vars[@]}"; do
|
||||
if ! grep -q "^${var}=" .env; then
|
||||
print_error "Required environment variable $var not found in .env"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
print_status "Environment validation passed ✓"
|
||||
}
|
||||
|
||||
# Pull latest images
|
||||
pull_images() {
|
||||
print_status "Pulling latest Docker images..."
|
||||
|
||||
docker compose pull
|
||||
|
||||
print_status "Images pulled ✓"
|
||||
}
|
||||
|
||||
# Start services
|
||||
start_services() {
|
||||
print_status "Starting services..."
|
||||
|
||||
# Create networks first
|
||||
docker network create arr_network --subnet=172.20.0.0/16 2>/dev/null || true
|
||||
docker network create database_network --subnet=172.21.0.0/16 2>/dev/null || true
|
||||
|
||||
# Start all services
|
||||
docker compose up -d
|
||||
|
||||
print_status "Services started ✓"
|
||||
}
|
||||
|
||||
# Display service URLs
|
||||
show_services() {
|
||||
echo
|
||||
print_status "🎉 Setup complete! Your services are available at:"
|
||||
echo
|
||||
echo -e "${BLUE}📊 Dashboard & Management:${NC}"
|
||||
echo " • Homepage (Dashboard): http://localhost:7575"
|
||||
echo " • FileBrowser: http://localhost:6633"
|
||||
echo
|
||||
echo -e "${BLUE}🎬 Media Services:${NC}"
|
||||
echo " • Jellyfin (Media Server): http://localhost:8096"
|
||||
echo " • Jellyseerr (Requests): http://localhost:5055"
|
||||
echo " • Sonarr (TV Shows): http://localhost:8989"
|
||||
echo " • Radarr (Movies): http://localhost:7878"
|
||||
echo " • Lidarr (Music): http://localhost:8686"
|
||||
echo " • Bazarr (Subtitles): http://localhost:6767"
|
||||
echo " • Prowlarr (Indexers): http://localhost:9696"
|
||||
echo " • qBittorrent: http://localhost:7070"
|
||||
echo
|
||||
echo -e "${BLUE}📄 Document Management:${NC}"
|
||||
echo " • Paperless NGX: http://localhost:8100"
|
||||
echo " • Paperless AI: http://localhost:3040"
|
||||
echo " • Stirling PDF: http://localhost:8090"
|
||||
echo
|
||||
echo -e "${BLUE}🛠️ Utilities:${NC}"
|
||||
echo " • Speedtest Tracker: http://localhost:8180"
|
||||
echo " • Syncthing: http://localhost:8384"
|
||||
echo " • Obsidian Remote: http://localhost:8181"
|
||||
echo " • Gramps (Genealogy): http://localhost:5511"
|
||||
echo
|
||||
echo -e "${BLUE}🎵 Music Services:${NC}"
|
||||
echo " • Multi-Scrobbler: http://localhost:9078"
|
||||
echo " • Maloja: http://localhost:42010"
|
||||
echo
|
||||
echo -e "${BLUE}🖥️ Server Monitoring:${NC}"
|
||||
echo " • RackNerd API: http://localhost:5000"
|
||||
echo
|
||||
print_warning "Some services may take a few minutes to fully initialize."
|
||||
echo
|
||||
echo -e "${GREEN}💡 Useful commands:${NC}"
|
||||
echo " • View status: docker compose ps"
|
||||
echo " • View logs: docker compose logs [service]"
|
||||
echo " • Stop all: docker compose down"
|
||||
echo " • Update services: docker compose pull && docker compose up -d"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
echo -e "${BLUE}"
|
||||
echo "╔══════════════════════════════════════════════════╗"
|
||||
echo "║ Docker Media Stack Setup ║"
|
||||
echo "║ ║"
|
||||
echo "║ This script will set up your complete ║"
|
||||
echo "║ media and utility stack with Docker Compose ║"
|
||||
echo "╚══════════════════════════════════════════════════╝"
|
||||
echo -e "${NC}"
|
||||
|
||||
check_dependencies
|
||||
validate_environment
|
||||
create_directories
|
||||
set_permissions
|
||||
pull_images
|
||||
start_services
|
||||
show_services
|
||||
|
||||
echo
|
||||
print_status "🎯 Setup completed successfully!"
|
||||
print_warning "Remember to configure your services through their web interfaces."
|
||||
echo
|
||||
}
|
||||
|
||||
# Run main function
|
||||
main "$@"
|
Reference in New Issue
Block a user