Sample SysV Init Script for fah6 (Recyclable, too!)

This forum contains information about 3rd party applications which may be of use to those who run the FAH client and one place where you might be able to get help when using one of those apps.

Moderator: Site Moderators

Post Reply

How do you start your Folding Client?

SysV init.d
2
17%
other startup script
4
33%
desktop icon
1
8%
manually type script name
0
No votes
manually run the client itself
5
42%
 
Total votes: 12

arfyness
Posts: 13
Joined: Sun Aug 31, 2008 3:13 pm
Hardware configuration: 5 x WinXP (console version installed as service)
1 x Linux (manually, until I figure out what's wrong)
Asus nForce2 Mobo (A7N8X-E) w/ AMD AthlonXP 3200+ :: 1.0GB RAM :: Ubuntu Hardy 8.04.1
Location: Columbus, Ohio, USA

Sample SysV Init Script for fah6 (Recyclable, too!)

Post by arfyness »

I've been messing with this for a while, and now it looks stable enough to share without much embarrasment. :o)

You'll have to change the variables at the top of the file to match your system. My system configuration has it running under my username nate in a working directory /usr/local/folding ... the directory itself and contents of which are all chown nate:nate and at least chmod u+rw ... hopefully you are already at the point you can launch the client if you're reading this.

FEATURES
This script checks for any existing instances, and exits with message and exit code 1 if fah6 is already running. Likewise, it doesn't try to kill something that doesn't exist, and exits with '1'. Startup and shutdown are verified, if there's a problem, the exit code is 1. Also the restart, reload, force-reload options have a timeout allowing child threads to stop.

Client is started with calls to "su $USER" > /bin/sh > client which detaches from sh. It is stopped with "killall -INT" which has not so far chubbed up any WU's or led to messages about "previous termination was improper."

This script is not configured for the SMP client, but that should be easy enough to do: Find the line starting with "su $USER" and change to your liking. Most stuff is easily changed from the first few lines of variables.

I included the chkconfig stuff for it to be started last and shutdown first, but then I found that only works if you have chkconfig (redhat and friends). I use ubuntu, so I decided to learn about update-rc.d instead of getting chkconfig. If you're in debian / ubuntu, take your pick - chkconfig is probably easier to install and learn than update-rc.d is to learn -- or type.

All output is done to stdout, except in the case that you screw up the argument to the script. Then it goes to stderr.

My Precious:

Code: Select all

#!/bin/sh
# chkconfig: 2345 99 00
# description: FAH client SYSV init script

USER="nate"
DAEMON="fah6"
WORKDIR="/usr/local/folding"
DESC="Folding@Home Client"
NAME="folding"

case "$1" in
start)
  echo -n "Starting $DESC: "
  if PID=`pidof $DAEMON`; then
     echo "FAIL: $DESC has already been started: $DAEMON PID [$PID]."
     exit 0
  else
    su $USER -s /bin/sh -c "cd $WORKDIR; ./fah6 -verbosity 9 < /dev/null > /dev/null 2>&1 &"
    if PID=`pidof $DAEMON`; then
       echo "$DAEMON started with PID [$PID]."
    else
       echo "failed to start $DESC ... PID [$PID]."
       exit 1
    fi
  fi
;;
stop)
  echo -n "Stopping $DESC: "
  if PID=`pidof $DAEMON`; then
    killall -INT $DAEMON
    sleep 5
    if PID=`pidof $DAEMON`; then
      echo "NOT TERMINATED YET: still running with PID [$PID]."
      exit 1
    else
      echo "$DAEMON"
    fi
  else
    echo "Not stoping $DESC: $DAEMON has no PID [$PID]." 
    exit 0
  fi
;;
restart | force-reload)
  $0 stop
  echo "Allowing 10sec more for threads to close..."
  sleep 10
  $0 start
  ;;
reload)
  if PID=`pidof $DAEMON`; then
    $0 stop
    echo "Allowing 10sec more for threads to close..."
    sleep 10
    $0 start
  else
        echo  "Will not reload $DESC (not already running)."
  fi
  ;;
*)
  N=/etc/init.d/$NAME
  echo "Usage: $N {start|stop|restart|force-reload|reload}" >&2
  exit 1
  ;;
esac
exit 0
I know there's a few init.d scripts already floating about -- but I like mine better, so Pthhtht. I made it easily recyclable on purpose, since I've done a couple of these so far which weren't.

Enjoy,

-- Nate
Last edited by arfyness on Mon Oct 20, 2008 11:05 am, edited 2 times in total.
:: ./fah6 v6.02 :: Ubuntu Hardy 8.04.1 :: Asus A7N8X-E (nForce2) :: AMD AthlonXP 3200+ :: 1.0GB RAM :: 1 cpu ::

Image
Ivoshiee
Site Moderator
Posts: 822
Joined: Sun Dec 02, 2007 12:05 am
Location: Estonia

Re: SYSV Init Script for fah6 (Recycleable, too!)

Post by Ivoshiee »

Just one of other scripts floating around:
http://ra.vendomar.ee/~ivo/finstall
Post Reply