Re: [Hampshire] RHEL init scripts

Top Page

Reply to this message
Author: Samuel Penn
Date:  
To: adrian, Hampshire LUG Discussion List
Subject: Re: [Hampshire] RHEL init scripts

On Wed, September 3, 2008 20:52, Adrian Bridgett wrote:
> On Wed, Sep 3, 2008 at 17:26:43 +0100 (+0100), Samuel Penn wrote:
>>
>> Hi all,
>>
>> What is the standard way to start a process at boot time from an
>> init script as a non-root user? The 'process' is a script (or,
>> rather, several layers of scripts before starting Tomcat).
>>
>> We have tried calling the script with "sudo -u" from the init
>> script, but that doesn't work during the boot process (I don't
>> have more details on why, since I don't have root access to the
>> box in question and can't try it myself), though if it should
>> work then I can tell the admins to investigate this option some
>> more.
>
> Correct - it's in single user mode so "su" and "sudo" may not work. I
> think I remember what I did (/me checks SVN) yep:
> su -s /bin/sh -m $RUN_AS_USER -c "$CMD"


> That "-s /bin/sh" was the magic bit IIRC.


Okay, thanks.

Further investigation (and finding a test system) has also shown
that su $USER -c "$CMD" also appears to work (at least the
process starts as the right user). If it doesn't, we'll
try the above next.

Once I was able to test it, it was lack of tty that sudo was
complaining about.

-- 
Be seeing you,            http://www.glendale.org.uk
Sam.                      xmpp:sam@???