Code:
[ $(whoami) == "root" ]
will return 1 (yes) if you are logged in as root and 0 (no) if you are not. The spaces after the open bracket and before the close bracket are necessary because it is actually an alternate of the test statement. If you want to learn more about test (and its alternate [ ]) you can `man test`.
Code:
if [ $(whoami) == "root" ]; then
execute root commands
else
warn user
fi
It's a rudimentary implementation but that'll get the job done. I would also consider extrasolar's comment that if it's important that only root execute something then it should be owned and executed by root exclusively. In which case you could chown root.root and chmod 744 the file. I have some that are 700 only but I'm anal with that stuff.
A good compromise if you want to have a script for a user with optional root commands, you could use that if statement and instead of warning a user that you aren't root then you could actually make a separate script with the root commands and call it from that script with `su -c "rootscript"` that way it would ask for a password. It seems crude but it'll work. There are certainly better solutions but I'm not an expert.
Good luck!