Service to run user-owned init scripts at boot time?

Mikkel L. Ellertson mikkel at infinity-ltd.com
Fri Jan 30 17:22:47 UTC 2009


pds wrote:
> On Fri, 30 Jan 2009 06:18:20 +0100
> Kevin Kofler <kevin.kofler at chello.at> wrote:
> 
>> This should work:
>>
>> cat >>/etc/rc.d/rc.local <<EOF
>> for i in /home/*/.rc.local ; do
>>   user=${i#/home/}
>>   user=${user%/.rc.local}
>>   su $user -c $i
>> done
>> EOF
>>
>>         Kevin Kofler
>>
> 
> This should work as long as all the prerequisite services have been
> started, such as mounting the file system.
> 
Considering when rc.local runs, all the other services should have
been run. From the rc.local file itself:

# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

> One other requirement is all users accounts are in /home.

You could try something like this (untested):

RClocal=".rc.local"

USERS=`awk -F: '{print $1}' /etc/passwd`
for i in $USERS
  do
   HOME=`grep \^$i: /etc/passwd | awk -F: '{print $6}'`
   if [ -r $HOME/$RClocal ]; then
     su $USER -c $HOME/$RClocal &
   fi
  done

You could fancy it up a bit by only using UIDs 500 or greater,
depending on what you want.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20090130/bfebb595/attachment-0001.sig>


More information about the fedora-list mailing list