My second attempt to handle stdin and also return proper exit code and
avoid one shell running is
#!/bin/sh
# 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=`tty`
[ "$TTY" = "not a tty" ] && unset TTY
sudo
Greg Morgan wrote:
Of course the challenge is doing
something with root.
If you have r&d mode enabled there is easy trick for shell scripts.
#!/bin/sh
# use gainroot to become root and relaunch itself
if [ `id -u` != 0 ] ; then
#if not already root, call itself as root
sudo gainroot