> su userid -c \"command line\" -s shell path
> 
> See the start case in /etc/rc.d/init.d/xfs for an example.

And a script might look like (WebXXX is made up) ...
----------- start cut ----
#!/bin/sh
#
# Startup script for WebXXX
#
PROG=webxxx
PROGDIR=/home/httpd/webxxx/bin
WSUSER=erl
if [ $WSUSER = `whoami` ] ; then
    STARTCMD="$PROGDIR/$PROG restart"
    STOPCMD="$PROGDIR/$PROG stop"
else
    STARTCMD="su - $WSUSER -c \"$PROGDIR/$PROG restart\""
    STOPCMD="su - $WSUSER -c \"$PROGDIR/$PROG stop\""
fi

if [ ! -x $PROGDIR/$PROG ] ; then
    echo "WebXXX can not execute: $PROGDIR/$PROG, aborting ..."
    exit
fi

if [ "$1" = "start" ] ; then
    echo "WebXXX starting ..."
    cd $PROGDIR
    /bin/sh -c "$STARTCMD"
elif [ "$1" = "stop" ] ; then
    echo "WebXXX shutting down ..."
    cd $PROGDIR
    /bin/sh -c "$STOPCMD"
else
    echo "usage $0 {start | stop}"
fi
-----------  end  cut ----

> On Mon, 19 Jun 2000, you wrote:
> > Sevatio Octavio wrote:
> > > 
> > > Typically if I wanted to run something automatically at bootup, I would put a 
>statement into /etc/rc.d/rc.local .  Those apps will
> > > run under the ownership of 'root'.  How do you get rc.local to run apps under a 
>specific user?
> > > 
> > > Seve
> > I would simply put it into the appropriate user's .bashrc (or
> > whatever shell you are talking about)  
> > 
> > Or, if it is to be run as, say, nobody, I would put a call to
> > setuid() in the source of the program and recompile.
> > 
> > Sheesh, maybe there is a simpler way...  Anyone?
> > 
> > Civileme

Thanks... Dan.

Reply via email to