Skip to content

Instantly share code, notes, and snippets.

@ewired
Last active June 23, 2025 18:19
Show Gist options
  • Save ewired/8a1c22434d34271b1aa958cfd4592688 to your computer and use it in GitHub Desktop.
Save ewired/8a1c22434d34271b1aa958cfd4592688 to your computer and use it in GitHub Desktop.
Quadlet post-receive hook
#!/bin/bash
set -e
# Get current username and hostname
USERNAME=$(whoami)
HOSTNAME=$(hostname)
DIR_NAME="${USERNAME}-at-${HOSTNAME}"
# Define target directories
WORK_TREE="$HOME/${DIR_NAME}"
QUADLET_DIR="$HOME/.config/containers/systemd"
# Make sure target directories exist
mkdir -p "$WORK_TREE" "$QUADLET_DIR"
# Checkout the latest code to the work tree
git --work-tree="$WORK_TREE" --git-dir="$HOME/${DIR_NAME}.git" checkout -f main
# Create symbolic links for Quadlet files
echo "Updating Quadlet container units..."
find "$QUADLET_DIR" -type l -delete # Remove old symlinks
ln -sf "$WORK_TREE/containers/"* "$QUADLET_DIR/" 2>/dev/null || true
# Reload systemd to recognize changes
echo "Reloading systemd daemon..."
systemctl --user daemon-reload
echo "Deployment complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment