Add Docker configuration symlink setup script
- Automates symlinking of docker-compose.yml files from repo to /opt/docker - Includes Gitea, Jellyfin, qBittorrent, Portainer - Symlinks daemon.json to /etc/docker - Creates timestamped backups before replacing files - Eliminates need for manual config copying
This commit is contained in:
100
scripts/setup-docker-symlinks.sh
Executable file
100
scripts/setup-docker-symlinks.sh
Executable file
@@ -0,0 +1,100 @@
|
||||
#!/bin/bash
|
||||
# Set up symlinks for Docker configurations to avoid manual copying
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
echo "==================================================================="
|
||||
echo "Docker Configuration Symlink Setup"
|
||||
echo "==================================================================="
|
||||
echo ""
|
||||
|
||||
REPO_ROOT="/home/hoborg/homelab"
|
||||
|
||||
# Function to create symlink with backup
|
||||
create_symlink() {
|
||||
local service=$1
|
||||
local target=$2
|
||||
local link=$3
|
||||
|
||||
echo "-------------------------------------------------------------------"
|
||||
echo "Setting up: $service"
|
||||
echo "-------------------------------------------------------------------"
|
||||
echo "Target: $target"
|
||||
echo "Link: $link"
|
||||
echo ""
|
||||
|
||||
# Check if target exists
|
||||
if [ ! -f "$target" ]; then
|
||||
echo "ERROR: Target file does not exist: $target"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Backup existing file if it's not already a symlink
|
||||
if [ -f "$link" ] && [ ! -L "$link" ]; then
|
||||
backup="${link}.backup.$(date +%Y%m%d_%H%M%S)"
|
||||
echo "Backing up existing file to: $backup"
|
||||
cp "$link" "$backup"
|
||||
rm "$link"
|
||||
elif [ -L "$link" ]; then
|
||||
echo "Removing existing symlink"
|
||||
rm "$link"
|
||||
fi
|
||||
|
||||
# Create symlink
|
||||
ln -s "$target" "$link"
|
||||
|
||||
if [ -L "$link" ]; then
|
||||
echo "✓ Symlink created successfully"
|
||||
else
|
||||
echo "✗ Failed to create symlink"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Gitea docker-compose.yml
|
||||
create_symlink "Gitea docker-compose" \
|
||||
"$REPO_ROOT/config/docker/gitea/docker-compose.yml" \
|
||||
"/opt/docker/gitea/docker-compose.yml"
|
||||
|
||||
# Jellyfin docker-compose.yml
|
||||
create_symlink "Jellyfin docker-compose" \
|
||||
"$REPO_ROOT/config/docker/jellyfin/docker-compose.yml" \
|
||||
"/opt/docker/jellyfin/docker-compose.yml"
|
||||
|
||||
# qBittorrent docker-compose.yml
|
||||
create_symlink "qBittorrent docker-compose" \
|
||||
"$REPO_ROOT/config/docker/qbittorrent/docker-compose.yml" \
|
||||
"/opt/docker/qbittorrent/docker-compose.yml"
|
||||
|
||||
# Portainer docker-compose.yml
|
||||
create_symlink "Portainer docker-compose" \
|
||||
"$REPO_ROOT/config/docker/portainer/docker-compose.yml" \
|
||||
"/opt/docker/portainer/docker-compose.yml"
|
||||
|
||||
# Docker daemon config
|
||||
create_symlink "Docker daemon config" \
|
||||
"$REPO_ROOT/config/docker/daemon.json" \
|
||||
"/etc/docker/daemon.json"
|
||||
|
||||
echo "==================================================================="
|
||||
echo "Summary"
|
||||
echo "==================================================================="
|
||||
echo ""
|
||||
echo "✓ All symlinks created successfully!"
|
||||
echo ""
|
||||
echo "Notes:"
|
||||
echo " - Original files backed up with timestamp"
|
||||
echo " - Edit files in $REPO_ROOT/config/docker/"
|
||||
echo " - Changes take effect immediately (no copying needed)"
|
||||
echo " - For daemon.json: restart docker after changes"
|
||||
echo " - For docker-compose: restart containers after changes"
|
||||
echo ""
|
||||
echo "Verify symlinks:"
|
||||
echo " ls -l /opt/docker/gitea/docker-compose.yml"
|
||||
echo " ls -l /opt/docker/jellyfin/docker-compose.yml"
|
||||
echo " ls -l /opt/docker/qbittorrent/docker-compose.yml"
|
||||
echo " ls -l /opt/docker/portainer/docker-compose.yml"
|
||||
echo " ls -l /etc/docker/daemon.json"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user