Koozali.org: home of the SME Server

Legacy Forums => General Discussion (Legacy) => Topic started by: rmoria on November 25, 2004, 09:47:48 PM

Title: Boinc / setiathome
Post by: rmoria on November 25, 2004, 09:47:48 PM
I have made an effort to get this working.
It seems to be working well, though I do have trouble sometimes with the lockfile.
Any sugestions are welcome. I am pretty new at this.

Adapted from http://noether.vassar.edu/~myers/help/boinc/unix.html

Install libgcc-3.0.4-1.i386.rpm, otherwise boinc won't work.
http://rpm.pbone.net/index.php3/stat/4/idpl/24123/com/libgcc-3.0.4-1.i386.rpm.html
   
Code: [Select]
rpm -Uhv libgcc-3.0.4-1.i386.rpm

Create user boinc
   
Code: [Select]
adduser boinc

Get the latest Linux/x86 client from http://boinc.berkeley.edu/download.php
 and place it in /home/boinc/ (when I wrote this the version was 4.13).
Get the boinc script (or make it yourself), name it boincrun, place it in /home/boinc
Code: [Select]
#!/bin/sh
#
# Adapted for SME 6.01-01 RMoria 2004/11/25


PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH

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


# Defaults, which can be overridden by /etc/sysconfig/boinc

BOINCUSER=boinc
BOINCDIR=/home/boinc
BUILD_ARCH=i686-pc-linux-gnu
LOGFILE=boinc.log
ERRORLOG=error.log
#BOINCOPTS="-allow_remote_gui_rpc"
BOINCOPTS=

# su on linux seems to need this:
export TERM dumb


if [ -f /etc/sysconfig/boinc ]; then
  . /etc/sysconfig/boinc
fi


## Locate the working directory

if [ ! -d $BOINCDIR ]; then
  echo "Cannot find boinc directory $BOINCDIR "
  exit 1
fi


## Locate the executable with highest version

BOINCEXE=/bin/ls -1 $BOINCDIR/boinc_*_$BUILD_ARCH 2>/dev/null | tail -n 1
if [ ! -x "$BOINCEXE" ]; then
  echo "Cannot find/run boinc executable $BOINCEXE "
  exit 2
fi


## Functions: start/stop/status/restart

case "$1" in
  start)
        cd $BOINCDIR
if [ ! -f client_state.xml ] ; then
 echo -n "BOINC client requires initialization first."
 echo_failure
 echo
 exit 3  
fi

if [ -f lockfile ] ; then
 echo -n "Another instance of BOINC is running (lockfile exists)."
 echo_failure
 echo
 exit 4  
fi

echo -n "Starting BOINC client as a daemon: "
su -s /bin/bash - $BOINCUSER  -c "$BOINCEXE $BOINCOPTS &"
        sleep 1  
        PID=pidof $BOINCEXE
if [ "$PID" != "" ]; then
 echo_success
else
 echo_failure
fi
echo
;;


  stop)
echo -n "Stopping boinc client daemon"    
killproc $BOINCEXE && echo_success  || echo_failure
echo
# clean up
rm $BOINCDIR/lockfile -f
;;


  restart)
$0 stop
$0 start
;;

  status)
        PID=pidof $BOINCEXE
if [ "$PID" != "" ]; then
          echo "BOINC client is running (pid $PID)."
        else
          if [ -f $BOINCDIR/lockfile ]; then
             echo "BOINC is stopped but lockfile exists."
 else
        echo "BOINC client is stopped."
          fi
        fi
;;
  *)
echo "Usage: boinc {start|stop|restart|status}"
exit 1
esac

exit

##


Set owner and rights for all files in /home/boinc
   
Code: [Select]
chmod +x boinc*
chown boinc *


Start boinc and enter projectsite and user key:
   
Code: [Select]
su -s /bin/bash - boinc  -c /home/boinc/boinc_4.13_i686-pc-linux-gnu

Starting BOINC client version 4.13 for i686-pc-linux-$
  Enter the URL of the project: http://setiathome.berkeley.edu
  You should have already registered with the project
  and received an account key by email.
  Paste the account key here: 0e26182a7b358062e2b704d0XXXXXXXX (use your own ;-)  )

When all is complete exit with ctrl-c

   
Code: [Select]
ln -s /home/boinc/boincrun /etc/rc7.d/S98boincrun
for automated startup

start Boinc with
Code: [Select]
/home/boinc/boincrun start
Title: Boinc / setiathome
Post by: Reinhold on November 26, 2004, 11:48:23 AM
Hi rmoria,

Nice! Looks good ... but I am still on seti :-D

Havent had more than a cursory look but here are some comments:

You are (somewhat) going against SME standards like
/home/e-smith/files/users  
is the SME user directory however I cannot see where the setup should fail with your RH adduser style...

chmod +x   seems a bit "too much" it's only boinc isn't it?

Now why not start boincrun as user boinc instead of as admin or root?

- Check the settings of the lockfile once...
- Give us the error.log you have if the error persists.

Regards
Reinhold

P.S.: Since I haven't looked for ages...
Is it easy to convert? Can I keep my "standings" ß
Title: Boinc / setiathome
Post by: rmoria on November 26, 2004, 11:54:59 AM
User root or admin didn't seem to do the job.
I tried a existing user, but they were not allowed to log on (su command).

In the original script there was a pipe to a error log, but that didn't seem to work either. As I said, I am new at this.
Title: Boinc / setiathome
Post by: rmoria on November 30, 2004, 12:37:40 PM
Added the folowing code to the script, to get rid of the lockfile problems (look at the first 3 lines where to paste it). It's not pretty but it works.

Code: [Select]
case "$1" in
  start)
        cd $BOINCDIR

PID=pidof $BOINCEXE
if [ "$PID" != "" ]; then
 echo "BOINC is already running"
 exit 4
else
 rm $BOINCDIR/lockfile -f
fi