scripts/hooks/dstr.sh

27 lines
718 B
Bash

#!/bin/bash
# URL to the raw script file
SCRIPT_URL="https://git.kjan.de/jank/scripts/raw/branch/main/hooks/pre-recieve.sh"
# Temporary file for the downloaded script (necessary to execute it properly)
TEMP_SCRIPT=$(mktemp)
trap 'rm -f "$TEMP_SCRIPT"' EXIT
# Download the script (try curl, fall back to wget)
if command -v curl &>/dev/null; then
curl -s -o "$TEMP_SCRIPT" "$SCRIPT_URL"
else
wget -q -O "$TEMP_SCRIPT" "$SCRIPT_URL"
fi
if [ ! -s "$TEMP_SCRIPT" ]; then
echo "Error: Could not download validation script from $SCRIPT_URL"
exit 1
fi
# Make the script executable
chmod +x "$TEMP_SCRIPT"
# Pass all input to the downloaded script and preserve its exit code
cat | "$TEMP_SCRIPT"
exit $?