Tecadmin published a quick tutorial about adding a check if a script is running as root user in Linux.
Check if a script is running as root user in Linux
Sometimes the shell scripts are required to run as the root user to perform some tasks with administrator privileges. Generally, that tasks can be achieved with the Sudo commands. If in some cases you still need to force the user to run the script as the root user, you can add code to your script.