---
name: deploy-config
description: Set up symlinks from system config locations to this repo. Use when setting up on a new machine, or when a config file is found to be a real file instead of a symlink (config drift). Not for routine config changes — just edit the repo file directly.
disable-model-invocation: true
allowed-tools: Write, Bash(chmod *), Bash(diff *), Bash(ls *)
---

All system configs should be symlinked to this repo. Editing the repo file IS editing the live config.

## Symlink Map

| System location | Repo source |
|---|---|
| `/etc/nginx/sites-available/homelab` | `config/nginx/homelab.conf` |
| `/var/www/homelab/index.html` | `config/www/index.html` |
| `/etc/systemd/system/copyparty.service` | `config/systemd/copyparty.service` |
| `/etc/systemd/system/glances-web.service` | `config/systemd/glances-web.service` |
| `/etc/systemd/system/ssh-honeypot.service` | `config/systemd/ssh-honeypot.service` |
| `/opt/docker/<service>/docker-compose.yml` | `config/docker/<service>/docker-compose.yml` |

## When to use this skill

- **New machine setup**: Create all symlinks from scratch
- **Drift detected**: A system file is a real file instead of a symlink — replace it with a symlink
- **New config added to repo**: Create the initial symlink for it

## How to create/fix a symlink

Generate a script in `scripts/tmp/symlink-<name>.sh`:

```bash
#!/bin/bash
set -e
REPO="/home/hoborg/homelab/<repo-path>"
SYSTEM="<system-path>"

# Back up if it's a real file (not already a symlink)
[ ! -L "$SYSTEM" ] && cp "$SYSTEM" "${SYSTEM}.backup.$(date +%Y%m%d)" && echo "Backup created"

ln -sf "$REPO" "$SYSTEM" && echo "Symlink created"
# Add post-link steps here (e.g. nginx -t && systemctl reload nginx, systemctl daemon-reload)
```

Tell the user to run: `sudo bash ~/homelab/scripts/tmp/symlink-<name>.sh`

## Routine config changes

Just edit `config/<path>` in the repo. The symlink means it's already live. Then:
- Nginx: `sudo nginx -t && sudo systemctl reload nginx`
- Systemd unit: `sudo systemctl daemon-reload && sudo systemctl restart <service>`
- Docker: `cd /opt/docker/<service> && docker compose restart`
- www/index.html: no action needed (served directly)
