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

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

pds wrote:
> On Fri, 30 Jan 2009 06:18:20 +0100
> Kevin Kofler <kevin kofler 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):


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

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


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

Attachment: signature.asc
Description: OpenPGP digital signature

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