You are not logged in.

#1 2003-06-23 11:55:11

Moritz
Member
From: Cologne, NRW, Germany
Registered: 2002-10-12
Posts: 166

Skeleton daemon scripts

I had a look at a few scripts in /etc/rc.d/ and noticed, that the maintainers always do threir own stuff. That's okay, but it's a bit weired for other people reading them.
I suggest to write a skeleton script, and port all existing scripts to this one, because it's easier to support them for other people. And it would be helpfull for people creating new scripts for new packages.

what do you think? :?:

Regards,
Moritz

Offline

#2 2003-06-24 07:12:29

Bobonov
Member
From: Roma - Italy
Registered: 2003-05-07
Posts: 295

Re: Skeleton daemon scripts

If you take a look at the official/daemon package they have all the same rc script structure.

The differents structure in some of the unofficial package I think are due to lazy developer   wink  or to particoular necessity of the daemon.

For instance I am preparing the package for courier imap and I have to say that the rc.script is the most difficoult part.
Basically courier is an imap and pop3 server and for both it provide ssl connection. This means that it need (in full configuration) to start up 4 daemons.  Just keeping track of all the pid files is a mess.... Probably, also to be sure that everithing is going to work propelly, I am going to give up and leave the original script.

If you want a basic skeleton just take one of orig/damemon rc script. I have done it for another package.

Offline

#3 2004-07-22 01:11:52

kleptophobiac
Member
From: Sunnyvale, CA
Registered: 2004-04-25
Posts: 488

Re: Skeleton daemon scripts

Is there a doc to describe what all the lines do? I'm a script newbie, and especially the if statements look like greek.

Offline

#4 2004-07-22 01:26:36

dp
Member
From: Zürich, Switzerland
Registered: 2003-05-27
Posts: 3,378
Website

Re: Skeleton daemon scripts

kleptophobiac wrote:

Is there a doc to describe what all the lines do? I'm a script newbie, and especially the if statements look like greek.

http://www.newbie.org/snippets/shell/co … ipts2.html


The impossible missions are the only ones which succeed.

Offline

#5 2004-07-22 01:53:28

kleptophobiac
Member
From: Sunnyvale, CA
Registered: 2004-04-25
Posts: 488

Re: Skeleton daemon scripts

well... that was a bit more basic than I was hoping, but thanks anyway. smile

Offline

#6 2004-07-22 02:51:18

dp
Member
From: Zürich, Switzerland
Registered: 2003-05-27
Posts: 3,378
Website

Re: Skeleton daemon scripts

kleptophobiac wrote:

well... that was a bit more basic than I was hoping, but thanks anyway. smile

sorry :-) maybe it's best that you post parts of the things you are not understanding in the forum and people will explain it to you hopefully directly


The impossible missions are the only ones which succeed.

Offline

#7 2004-07-22 03:02:16

kleptophobiac
Member
From: Sunnyvale, CA
Registered: 2004-04-25
Posts: 488

Re: Skeleton daemon scripts

well, to give you an idea, this is the most advanced bash script I've ever written:

#!/bin/bash
### Checks to see if SSH connection is up

### Configurable variables
HOST=
RPORT=
LPORT=
USER=
LOGLOCATION=


### Recursive function to clean up the log file
cleanup ()
{
        if [ `cat $LOGLOCATION | grep ^ -c` -ge 500 ]
        then
                cat $LOGLOCATION | sed 1d > $LOGLOCATION
                cleanup
        fi
}

### If there are no instances, start one
if [ `ps ax | grep -c $RPORT` -lt 1 ]
then
        echo "`date +"%F %T"` - SSH connection not found..." >> $LOGLOCATION
        ssh -fNC -l $USER -i /home/$USER/.ssh/id_rsa -R $RPORT:localhost:$LPORT $HOST
        echo "`date +"%F %T"` - SSH connection reestablished!" >> $LOGLOCATION
else
        echo "`date +"%F %T"` - SSH connection found. No action taken." >> $LOGLOCATION
fi

### Run the log cleaner
cleanup

I just posted that to LQ as the end result of an old thread I have over there.

I am just confused by the whole stat thing, maintaining a pid, knowing when the process is alive, and wha those funky tests are.

Offline

Board footer

Powered by FluxBB