[maemo-developers] root from scripts Re: [maemo-developers] Is there a convenient way of switching between usb/bluetooth/wifi networking?

From: Frantisek Dufka dufkaf at seznam.cz
Date: Fri Sep 22 12:09:23 EEST 2006
My second attempt to handle stdin and also return proper exit code and 
avoid one shell running is

# use gainroot to become root and relaunch itself and remember tty
if [ `id -u` != 0 ] ; then
#if not already root, call itself as root
[ "$TTY" = "not a tty" ] && unset TTY
sudo gainroot <<EOF
if [ -z "$TTY" ] ; then exec $0 $* ; else exec <$TTY $0 $* ; fi
exit $?
# real script follows

Similar thing can be done with stdout if you do not want to see 'Root 
shell enabled' output of gainroot script. If someone has some 
optimization or know better way how to shuffle input and output 
redirection in shell without using output of tty command, let me know.


More information about the maemo-developers mailing list