On 04/30/2014 11:33 AM, olli hauer wrote:
On 2014-04-30 20:02, ToddAndMargo wrote:
On 04/30/2014 10:38 AM, Jeffrey Anderson wrote:
It seems to me that having a shell script prompt for the root password
is a recipe for disaster, but you can easily check to see if the user is
already root, and bail if not.


That is what I currently do.  I am just wanting to get fancy:

if [ -z "`/usr/bin/whoami | grep root`" ]; then
    echo ""
    # ErrorSound
    echo 'Dude!  You must be root to do this.'
    echo "Try"
    echo "    su root -c \"updateffth $1\""
    echo 'Exiting.   Bummer ...'
    echo ""
    Pause
    exit 1
fi


sudo has the charm to create log entries, and can be easily automated.

I find sudo "annoying".  I do use it for some things though.


What I miss in your example is a syslog call that someone unauthorized tried to 
execute the script.

I am not sure that is necessary.  This is just
a script to install new Firefox or Thunderbird binaries,
update links, and remove old binaries.

$ logger -p user.notice -t test "testing 123"

Would do the job.  Perhaps after they goofed "su"

Maybe ever one to say the job completed.  Probably
not.  You get that when you run the script

Also I would replace pause with `sleep $num' or `read -t $num DUMMY' so in case 
the script is executed by cron it doesn't wait for a signal.

You missed "P" in "Pause"

Pause () {
   echo ""
   read -n 1 -s -p "Press any key to continue..."
   echo ""
}

Since this is meant to run from the command line,
I am not even sure I need it.

Thank you for the tips!

-T



--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reply via email to