Created
August 4, 2024 06:36
-
-
Save rameshvarun/f559d0a32859fc55522c54b084d9543f to your computer and use it in GitHub Desktop.
Load remote bash scripts with sha256sum verification.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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