Last active
June 23, 2025 18:19
-
-
Save ewired/8a1c22434d34271b1aa958cfd4592688 to your computer and use it in GitHub Desktop.
Quadlet post-receive hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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