You are not logged in.

#1 2010-12-06 17:11:16

return new int[5]
Member
Registered: 2010-09-29
Posts: 8

[SOLVED] Folding at home script

Seeing as how the old folding@home startup script was written for an instance of folding@home on a single processor, I tried to adjust the script.
This time suitable for multiprocessor instances of folding@home.

The problem I have is the following. I want it to run in user mode, but because it starts up when my computer starts I can't make it switch to my username without hard coding this.
Is there any way to change this? I don't think running it as root is a good idea, folding@home using a lot of CPU and all.

My script at the moment. My username is sander:

#!/bin/bash
#/etc/rc.d/foldingathome
#
# Starts the Folding@Home client in the background

. /etc/rc.conf
. /etc/rc.d/functions

PID=$(pgrep -u sander Fah)
case "$1" in
    start)
    stat_busy "Starting Folding@Home"
    if [[ "$PID" == "" ]]; then
        su - sander -c "cd ~/folding; ./fah6 -smp -verbosity 9 < /dev/null > /dev/null 2>&1 &"
    fi
    if [[ "$PID" != "" || $? > 0 ]]; then
        stat_fail
    else
        add_daemon foldingathome
        stat_done
    fi
    ;;
    
    stop)
    stat_busy "Stopping Folding@Home"
    [[ "$PID" != "" ]]&& kill $PID &> /dev/null
    if [[ $? > 0 ]]; then
        stat_fail
    else
        rm_daemon foldingathome
        stat_done
    fi
    ;;
    
    restart)
    $0 stop
    sleep 1
    $0 start
    ;;
    
    *)
    echo $"Usage: $0 {start|stop|restart}"
esac

Thanks in advance.

Last edited by return new int[5] (2010-12-06 20:59:50)

Offline

#2 2010-12-06 20:26:12

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 859
Website

Re: [SOLVED] Folding at home script

I'd maybe add a /etc/conf.d/folding@home file or something with a FOLDING_USER variable.  How did the old script do it?

Offline

#3 2010-12-06 20:59:07

return new int[5]
Member
Registered: 2010-09-29
Posts: 8

Re: [SOLVED] Folding at home script

Exactly as you said. For those interested, the complete script:

#!/bin/bash
#/etc/rc.d/foldingathome
#
# Starts the Folding@Home client in the background

. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/foldingathome

PID=$(pgrep -u $FAH_USER Fah)
case "$1" in
    start)
    stat_busy "Starting Folding@Home"
    if [[ "$PID" == "" ]]; then
        su - $FAH_USER -c "cd /opt/folding; ./fah6 -smp -verbosity 9 < /dev/null > /dev/null 2>&1 &"
    fi
    if [[ "$PID" != "" || $? > 0 ]]; then
        stat_fail
    else
        add_daemon foldingathome
        stat_done
    fi
    ;;
    
    stop)
    stat_busy "Stopping Folding@Home"
    [[ "$PID" != "" ]]&& kill $PID &> /dev/null
    if [[ $? > 0 ]]; then
        stat_fail
    else
        rm_daemon foldingathome
        stat_done
    fi
    ;;
    
    restart)
    $0 stop
    sleep 1
    $0 start
    ;;
    
    *)
    echo $"Usage: $0 {start|stop|restart}"
esac

/etc/conf.d/foldingathome contains:

#
# Optional user settings for foldingathome daemon
#
# If you prefer not to run fah as root then you can identifer a current or
# specially created user here.

FAH_USER="sander"

Follow this guide for FAH on multiprocessors:
http://folding.stanford.edu/English/LinUNIGuide

Place it in /opt/folding afterwards, and create the 2 files I posted.

Offline

Board footer

Powered by FluxBB