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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



pds wrote:
> On Fri, 30 Jan 2009 06:18:20 +0100
> Kevin Kofler <[email protected]> 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!

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
fedora-list mailing list
[email protected]
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines

[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux