You are not logged in.
Pages: 1
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
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 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
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
Is there a doc to describe what all the lines do? I'm a script newbie, and especially the if statements look like greek.
The impossible missions are the only ones which succeed.
Offline
well... that was a bit more basic than I was hoping, but thanks anyway.
Offline
well... that was a bit more basic than I was hoping, but thanks anyway.
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
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
Pages: 1