Well. It's probably best to have 2 scripts: the second one for the root part, which you call from the first script with:
For this to work root has agree with this by putting this in /etc/sudoers (using "visudo" as the editor):
<user> <hostname> = NOPASSWD: /path/to/second/script
(1) Replace "<user>" with the name of the user you want to allow to run the script as root without entering the root password
(2) Replace "<host>" with the hostname of the computer. "localhost" will not do (on my system at least), use the output of "hostname".
Hope this helps. See "man sudo" and "man sudoers" for more information.