Skip to content

Instantly share code, notes, and snippets.

@brianoflan
Last active December 16, 2016 17:40
Show Gist options
  • Save brianoflan/d6a76cfb742ce0dd66b8df7909b47bf3 to your computer and use it in GitHub Desktop.
Save brianoflan/d6a76cfb742ce0dd66b8df7909b47bf3 to your computer and use it in GitHub Desktop.
Fail unless run by root (id, forceRoot, exit)
#!/bin/bash
forceRoot() {
[[ "$(id -u)" == "0" ]] || { echo "ERROR: Must run $0 as root." ; exit 1 ; }
}
forceRoot ;
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment