HOWTO: Starting SETI when Linux Starts

Permabanned
Joined
18 Oct 2002
Posts
2,010
Location
Huddersfield / Antartica
Hiyas,

Add the following script into your /etc/init.d/ substituting /home/shak/seti1 for your SETI directory:

Code:
#!/sbin/runscript
 checkconfig() {
         if [ ! -e /home/shak/seti1 ]
         then
                einfo "Creating /home/shak/seti1"
                 mkdir /home/shak/seti1
         fi
         if [ ! -e /home/shak/seti1/user_info.sah ]
      then
                 einfo "Setting up SETI@home for the first time"
                 cd ${SETIATHOME_DIR}
                 ./setiathome -login
         fi
 }
 start() {
         checkconfig
        ebegin "Starting SETI@home"
         cd /home/shak/seti1
         ./setiathome -nolock -proxy croccomp.no-ip.com:5517 >&/dev/null&
         eend $?
 }
 stop() {
       ebegin "Stopping SETI@home"
         killall setiathome
         eend $?
 }

You can also swap the S@H arguments on the end.

Then add this to the startup by adding

Code:
/etc/init.d/setiathome start

To /etc/conf.d/local.start

There may be some slight differences for different distros for the local.start and the /etc/init.d

Shak
 
Just a suggestion, wouldn't it be cleaner to add...
Code:
SETIDIR=/home/shak/seti1
SETIPROXY=croccomp.no-ip.com:5517
...at the beginning of the script and then just refer to $SETIDIR and $SETIPROXY in the code? Would also make it easier for peeps to change.

:)
 
Originally posted by Pho
Cool thanks, if you have two seti processes running on a 1 processor machine does it affect anything at all?

This script starts 1 process, for a 2 processor one you have to have another script called seti2 :)

exedanni: It could be cleaner but TBH I was just coding it for me to start with, and found that SETIDIR didnt work because it defines it as Gentoo's SETI dir /opt/setiathome where mine isnt there.

Shak
 
Originally posted by Shak
This script starts 1 process, for a 2 processor one you have to have another script called seti2 :)

exedanni: It could be cleaner but TBH I was just coding it for me to start with, and found that SETIDIR didnt work because it defines it as Gentoo's SETI dir /opt/setiathome where mine isnt there.

Shak

SO am i right in saying i could use the same script to start any programme , if i swap the reference from setiathome to say ksetispy and obviously your name and the correct file.
 
uhuh! But it would be better if it was a GUI file to use the KDE startup scripts.

Add it to /home/dezyboy/.kde/autostart or add use it through the control panel, where there should be an autostart bit.

Alternativelty, just save the current session and then it will use that every time :p

Shak
 
Originally posted by Shak
uhuh! But it would be better if it was a GUI file to use the KDE startup scripts.

Add it to /home/dezyboy/.kde/autostart or add use it through the control panel, where there should be an autostart bit.

Alternativelty, just save the current session and then it will use that every time :p

Shak

Right i'm on the right track now..... Just faceing the wrong way !
 
I was planning on using the /etc/rc2.d directory for starting and stopping SETI

Two files,

S98setistartup
cd /home/feek/seti
./setiathome -nolock -proxy 192.168.0.14:5517


K10setistop
killall setiathome

That should work, shouldn't it? I assume that by doing that though the only way I can confirm it's running it by looking at the process list.

K.
 
Originally posted by Feek
I was planning on using the /etc/rc2.d directory for starting and stopping SETI

Two files,

S98setistartup
cd /home/feek/seti
./setiathome -nolock -proxy 192.168.0.14:5517


K10setistop
killall setiathome

That should work, shouldn't it? I assume that by doing that though the only way I can confirm it's running it by looking at the process list.

K.

Yes that would work BUT, in general all the files in /etc/rc.d/rc2.d are actually links to the /etc/rc.d/init.d .

The runlevel scripts then pass start or stop to the init.d script like in this example of dhcp startup. A quick edit and then a symbolic link to this in the rc2.d dir for both a start (SXX) and kill (KXX) with do the job. The nice part of this is it detaches the proccess properly and the parent becomes the init process. It also will not block your startup for conditions are not exactly right. Also the defined functions can be called from the commandline like this:

/etc/rc.d/init.d status

and will return

dhcpd (pid 13370) is running...

This is the "right" way to do it! :D



Code:
##########################
# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
if [ ! -f /etc/sysconfig/network ]; then
    exit 0
fi

. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x /usr/sbin/dhcpd ] || exit 0

# See how we were called.
case "$1" in
  start)
        # Start daemon.
        echo -n "Starting DHCP services: "
        daemon /usr/sbin/dhcpd -lf /var/dhcp/dhcpd.leases
        echo
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down DHCP: "
        killproc /usr/sbin/dhcpd
        echo
        ;;
  status)
        status /usr/sbin/dhcpd
        ;;
  restart)
        echo -n "Restarting DHCP services: "
        killproc dhcpd
        daemon /usr/sbin/dhcpd
        echo "done."
        ;;
  *)
        echo "Usage: dhcp {start|stop|status|restart}"
        exit 1
esac

exit 0
########################
 
Last edited:
"How to start seti when Linux starts?" I thought you boys were 24/7. Should only need to
start it after Linux install, reboot for new kernel or power cuts. :)

seti won't start another instance if one is running so I just have an entry like the line below in
my crontab. (crontab -e to edit, crontab -l to list)

00,30 * * * * cd $HOME/seti; ./setiathome <options> >/dev/null 2> /dev/null

(edited to be correct)

This makes sure it is running every 30 mins and starts it if not.
change <options> to things like -proxy etc
 
Last edited:
Man that lot hurt my head... and I was planning on making a switch to Linux so I could teach my self it... I think I will wait a bit now.

Do ya think I'd get any brownie points for doing my IT Open Uni course on a linux machine? :D
 
Back
Top Bottom