Skip to content

Instantly share code, notes, and snippets.

@sdr01810
Created October 26, 2017 16:47
Show Gist options
  • Save sdr01810/d507b94cad9980beaf609bfdea060993 to your computer and use it in GitHub Desktop.
Save sdr01810/d507b94cad9980beaf609bfdea060993 to your computer and use it in GitHub Desktop.
Shell function check_user_is_root_or_devops() and friends.
function check_user_is_root_or_devops() {
if ! user_is_root_or_devops ; then
post_delayed_exit 2 "You must be root or devops to execute this command; aborting."
fi
}
function user_is_root_or_devops() {
[ "$(id -u)" -eq 0 -o "$(id -un)" = "devops" ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment