# Check that we are run as root. # Return 0 if yes, or 1 if not or undeterminable. function is_root() { uid=$(id -u 2> /dev/null) if [ -n "$uid" ]; then if [ "$uid" != "0" ]; then echo "FAILED: You need root privileges to run this script."; echo return 1 fi else echo "Could not detect UID"; return 1 fi }