scripts/hooks/dstr.sh

25 lines
705 B
Bash

#!/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 $?