feat(hooks): add dstr.sh to fetch and run scripts dynamically

This commit is contained in:
Jan K9f 2025-04-07 18:53:18 +02:00
parent 3155729dbd
commit 451e41552c
Signed by: jank
GPG key ID: B9F475106B20F144

25
hooks/dstr.sh Normal file
View file

@ -0,0 +1,25 @@
#!/bin/bash
# Configuration - where to fetch the full script from
SCRIPT_REPO="https://git.kjan.de/jank/scripts.git"
SCRIPT_PATH="hooks/pre-recieve.sh"
BRANCH="main"
# Temporary directory
TEMP_DIR=$(mktemp -d)
trap 'rm -rf "$TEMP_DIR"' EXIT
# Clone only the needed branch and specific file for efficiency
git clone --depth 1 --branch "$BRANCH" --single-branch "$SCRIPT_REPO" "$TEMP_DIR" >/dev/null 2>&1
if [ ! -f "$TEMP_DIR/$SCRIPT_PATH" ]; then
echo "Error: Could not fetch validation script from repository"
exit 1
fi
# Make the script executable
chmod +x "$TEMP_DIR/$SCRIPT_PATH"
# Pass all input to the downloaded script and preserve its exit code
cat | "$TEMP_DIR/$SCRIPT_PATH"
exit $?