#!/bin/shThen run "update-rc.d folding1 defaults".
#
# $Id: folding.init.d,v 1.2 2008/02/27 13:20:31 est Exp $
### BEGIN INIT INFO
# Provides: folding1
# Required-Start: $local_fs,$network
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0
# Short-Description: Start folding@home client
### END INIT INFO
#Adapted from dhcp3-server init file
PATH=/sbin:/bin:/usr/sbin:/usr/bin
test -f $DAEMON || exit 0
. /lib/lsb/init-functions
#Configure these variables to suit your needs
MYUSER='myname' #Run as this user (Change this!)
WORKING='/home/myname/folding1/' #Process Working Directory (This is where the FAH client is stored)
NAME='fah6' #Process Name (This is the Folding @ Home executable name)
FOLDING_OPTS='-forceasm -smp 4'
#No need to edit below this line
DESC='Folding @ Home Client' #Process Description (Brief line to describe FAH)
DAEMON="$WORKING$NAME" #Full Path to the Daemon
MYPID="/var/run/$NAME.1.pid" #PID file
# single arg is -v for messages, -q for none
check_status()
{
if [ ! -r "$MYPID" ]; then
test "$1" != -v || echo "$NAME is not running."
return 3
fi
if read pid < "$MYPID" && ps -p "$pid" > /dev/null 2>&1; then
test "$1" != -v || echo "$NAME is running."
return 0
else
test "$1" != -v || echo "$NAME is not running but $MYPID exists."
return 1
fi
}
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
if start-stop-daemon -b -m --start --chdir "$WORKING" --chuid "$MYUSER" --quiet --pidfile $MYPID \
--exec "$DAEMON" -- $FOLDING_OPTS; then
log_end_msg 0
else
log_end_msg 1
exit 1
fi
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
start-stop-daemon --stop --quiet --pidfile $MYPID
log_end_msg $?
rm -f "$MYPID"
;;
restart | force-reload)
test_config
$0 stop
sleep 2
$0 start
if [ "$?" != "0" ]; then
exit 1
fi
;;
status)
echo -n "Status of $DESC: "
check_status -v
exit "$?"
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1
esac
exit 0
The script is named "folding1" because I actually run multiple folding clients on the same box. It still showed ~15% idle when running the first client with -smp 4 despite having only three cores, so why not? So I created similar scripts, folding2 and folding3, then made the necessary changes to indicate the different directories, and to delete the smp option.