homarr-dashboard/deploy.sh

111 lines
3.2 KiB
Bash

#!/bin/bash
#======================================================================#
# Homarr Quick Deployment Script #
#======================================================================#
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE} Homarr Dashboard Deployment Script ${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# Check if running as root
if [ "$EUID" -eq 0 ]; then
echo -e "${YELLOW}⚠️ Warning: Running as root. Continuing...${NC}"
fi
# Check Docker
if ! command -v docker &> /dev/null; then
echo -e "${RED}❌ Docker is not installed!${NC}"
echo "Install Docker first: https://docs.docker.com/get-docker/"
exit 1
fi
if ! command -v docker-compose &> /dev/null && ! docker compose version &> /dev/null; then
echo -e "${RED}❌ Docker Compose is not installed!${NC}"
exit 1
fi
echo -e "${GREEN}✅ Docker is installed${NC}"
# Generate encryption key
echo ""
echo -e "${BLUE}🔐 Generating encryption key...${NC}"
if command -v openssl &> /dev/null; then
ENCRYPTION_KEY=$(openssl rand -hex 32)
else
ENCRYPTION_KEY=$(head -c 32 /dev/urandom | xxd -p | tr -d '\n')
fi
echo -e "${GREEN}✅ Encryption key generated${NC}"
# Setup environment file
if [ ! -f .env ]; then
echo ""
echo -e "${BLUE}📄 Creating .env file...${NC}"
cp .env.example .env
sed -i "s/SECRET_ENCRYPTION_KEY=.*/SECRET_ENCRYPTION_KEY=$ENCRYPTION_KEY/" .env
echo -e "${GREEN}✅ .env file created${NC}"
echo -e "${YELLOW}⚠️ Please edit .env with your domain and settings${NC}"
else
echo -e "${YELLOW}⚠️ .env file already exists, skipping...${NC}"
fi
# Create directories
echo ""
echo -e "${BLUE}📁 Creating directories...${NC}"
mkdir -p homarr/appdata dash traefik/letsencrypt
echo -e "${GREEN}✅ Directories created${NC}"
# Start services
echo ""
echo -e "${BLUE}🚀 Starting services...${NC}"
if docker compose version &> /dev/null; then
docker compose up -d
else
docker-compose up -d
fi
echo -e "${GREEN}✅ Services started${NC}"
# Wait for services
echo ""
echo -e "${BLUE}⏳ Waiting for services to be ready...${NC}"
sleep 5
# Check status
echo ""
echo -e "${BLUE}📊 Service Status:${NC}"
if docker compose version &> /dev/null; then
docker compose ps
else
docker-compose ps
fi
# Get IP
IP=$(hostname -I | awk '{print $1}')
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} 🎉 Deployment Complete! ${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo -e "Access your dashboard at:"
echo -e " ${BLUE}• Homarr:${NC} http://$IP:7575"
echo -e " ${BLUE}• Dash.:${NC} http://$IP:3001"
echo -e " ${BLUE}• Traefik:${NC} http://$IP:8080"
echo ""
echo -e "${YELLOW}Next Steps:${NC}"
echo -e " 1. Complete the onboarding at http://$IP:7575"
echo -e " 2. Create your first board"
echo -e " 3. Configure your apps and widgets"
echo -e " 4. See DEPLOYMENT.md for detailed configuration"
echo ""
echo -e "${GREEN}Happy Homelabbing! 🏠${NC}"