feat(hooks): add dstr.sh to fetch and run scripts dynamically
This commit is contained in:
parent
3155729dbd
commit
451e41552c
1 changed files with 25 additions and 0 deletions
25
hooks/dstr.sh
Normal file
25
hooks/dstr.sh
Normal 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 $?
|
Loading…
Add table
Add a link
Reference in a new issue