thers a similar question out there How can I determine whether a shell-script runs as root or not?
I have the same doubt with different result
Is it possible to, within the BASH script prior to everything being run, check if the script is being run as superuser, and if not, print a message saying You must be superuser to use this script, then subsequently
get pass from the user using askpass or something like that then execute the same script as superuser?