foo.sh (Source)

#!/bin/bash
(( EUID == 0 )) || { echo "Script must be run as root" ; exit 1 }