Created
November 7, 2023 15:44
-
-
Save ConnerWill/d30b33953a290a5edbe513ff946c9fa8 to your computer and use it in GitHub Desktop.
Bash Script Template
This file contains 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 | |
die() { | |
echo "[-] Error: $1" >&2 | |
exit 1 | |
} | |
PROGRAM="${0##*/}" | |
ARGS=( "$@" ) | |
SELF="${BASH_SOURCE[0]}" | |
[[ $SELF == */* ]] || SELF="./$SELF" | |
SELF="$(cd "${SELF%/*}" && pwd -P)/${SELF##*/}" | |
[[ ${BASH_VERSINFO[0]} -ge 4 ]] || die "bash ${BASH_VERSINFO[0]} detected, when bash 4+ required" | |
[[ $UID == 0 ]] || exec sudo -p "[?] $PROGRAM must be run as root. Please enter the password for %u to continue: " -- "$BASH" -- "$SELF" "${ARGS[@]}" | |
type curl >/dev/null || die "Please install curl and then try again." | |
type jq >/dev/null || die "Please install jq and then try again." | |
set -e | |
read -p "[?] Please enter XXXXXXXXX: " -r VAR | |
printf "this:\t%s\n" "${VAR}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment