[wplug] Quick script/SU(or SUDO) question

Vance Kochenderfer vkochend at nyx.net
Thu Jul 13 20:16:10 EDT 2006


You could try a script like the following.  I don't have a Linux
box in front of me to test, so check it out carefully first.  It
uses some bashisms but shouldn't be hard to port to another
shell, mainly substituting backticks for the $( ) construct.

#!/bin/bash

# Checks to see if $myprog is running, starts it if not

# N.B. I haven't tested this
# This script should be executable by those you want able to run
#   it ('chmod g+x' if in the same group, 'chmod o+x' if not)
# If $myprog must be run as you, make this script setuid (e.g.,
#   'chmod u+s') - if this script can be exploited then whoever
#   can run the script gets access to your account...
# Those others must also be able to see files in your directory
#   (e.g., 'chmod g+r $HOME' or 'chmod o+r $HOME') which may
#   cause you to want to do 'chmod go-r' on your other files

myprog=/path/to/your/executable

if [ -z "$(/sbin/pidof $myprog)" ]
  then
    echo "$myprog is not running.  Restarting..."
    $myprog &
  else
    echo "$myprog is already running.  Exiting."
fi

Vance Kochenderfer        |  "Get me out of these ropes and into a
vkochend at nyx.net          |   good belt of Scotch"    -Nick Danger


More information about the wplug mailing list