Skip to content

Instantly share code, notes, and snippets.

@rameshvarun
Created August 4, 2024 06:36
Show Gist options
  • Select an option

  • Save rameshvarun/f559d0a32859fc55522c54b084d9543f to your computer and use it in GitHub Desktop.

Select an option

Save rameshvarun/f559d0a32859fc55522c54b084d9543f to your computer and use it in GitHub Desktop.
Load remote bash scripts with sha256sum verification.
#!/usr/bin/env bash
# Remotely load bash scripts with sha256sum verification.
# USAGE: bash_import [URL] [SHA256SUM]
function bash_import() {
TMPFILE=$(mktemp)
curl -sSL $1 -o $TMPFILE
if echo "$2 $TMPFILE" | sha256sum -c -; then
source $TMPFILE
else
echo "Checksum for $1 failed!"
exit
fi
}
# As an example, load https://github.com/rameshvarun/job.sh,
# a simple job manager for bash scripts.
bash_import \
"https://raw.githubusercontent.com/rameshvarun/job.sh/v0.1.0/job.sh" \
"ea8d799002e4e35c710c61684d2d1b251acd592cd8d89504b295f9f9d54361a4"
job_submit sleep 5
job_submit sleep 10
job_wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment