Dart00
July 14th, 2010, 01:52 AM
I have a script that runs lots and lots of root commands, copying files in /usr/...stuff like that, then i want to switch users back to the original user and run some gconf tweaks, But now im stuck. I need to update a series of gconf values for a user after copying all the root files, but I noticed once your in root, any gconf values you change, change roots information, not the user who started the script useing sudo. :(
So i was wondering how you would run a script as root, then after your done with all the root commands, "un-root" to the current user who started the script and run the gconf edits:
I put together this so far. It a script that you run, it detects if it was started as root and if not it asks for root password and re-spawns its self exiting out the first instance, then the script runs, switches to the original user after all files are copyed over and starts to run the Military Time custom format update.
OUSER="`whoami`"
if [ "$(id -u)" != "0" ]; then
sudo -K
sudo bash $0
exit
fi
cp config.ini /usr/share/Blah
su $OUSER
gconftool-2 --set "/apps/panel/applets/applet_4/prefs/custom_format" --type string "<span font_desc=\"Trebuchet MS 8.0\" weight=\"bold\">%l:%M %p%n%m/%d/%Y</span>"
echo "Done"
read junk
exit 0The results!.....All it does is copy the files and then gives me a root prompt: "root@shane-desktop:/home/shane/Desktop#" :( Anyone have any ideas?
So i was wondering how you would run a script as root, then after your done with all the root commands, "un-root" to the current user who started the script and run the gconf edits:
I put together this so far. It a script that you run, it detects if it was started as root and if not it asks for root password and re-spawns its self exiting out the first instance, then the script runs, switches to the original user after all files are copyed over and starts to run the Military Time custom format update.
OUSER="`whoami`"
if [ "$(id -u)" != "0" ]; then
sudo -K
sudo bash $0
exit
fi
cp config.ini /usr/share/Blah
su $OUSER
gconftool-2 --set "/apps/panel/applets/applet_4/prefs/custom_format" --type string "<span font_desc=\"Trebuchet MS 8.0\" weight=\"bold\">%l:%M %p%n%m/%d/%Y</span>"
echo "Done"
read junk
exit 0The results!.....All it does is copy the files and then gives me a root prompt: "root@shane-desktop:/home/shane/Desktop#" :( Anyone have any ideas?