[Lunar-commits] <moonbase> boinc-svn: new module

Duncan Gibson engelsman at lunar-linux.org
Mon Jan 10 22:28:33 CET 2011


commit 6c764533963513a0dc00022f5a2f0a33441bebb0
Author: Christian Krause <kizkizzbangbang at googlemail.com>
Date:   Mon Jan 10 22:28:33 2011 +0100

    boinc-svn: new module
    
    finally did it: porting BOINC for lunar
    
    Note: zbeta module, use at your own risk - untested - engelsman
---
 zbeta/boinc-svn/BUILD               |   37 +++++
 zbeta/boinc-svn/DEPENDS             |    2 +
 zbeta/boinc-svn/DETAILS             |   15 ++
 zbeta/boinc-svn/init.d/boinc-client |  279 +++++++++++++++++++++++++++++++++++
 4 files changed, 333 insertions(+), 0 deletions(-)

diff --git a/zbeta/boinc-svn/BUILD b/zbeta/boinc-svn/BUILD
new file mode 100644
index 0000000..ee6d591
--- /dev/null
+++ b/zbeta/boinc-svn/BUILD
@@ -0,0 +1,37 @@
+(
+  # creates configure script
+  ./_autosetup                             &&
+
+  # overwrite init-script with our own modified one
+  cp $SCRIPT_DIRECTORY/init.d/boinc-client client/scripts/boinc-client.in &&
+
+  # run per default as daemon
+  sedit 's/#BOINCOPTS="--daemon"/BOINCOPTS="--daemon"/' client/scripts/boinc-client.conf &&
+
+  # applies defaults to configure
+  # TODO: conf server and manager
+  ./configure --build=$BUILD                \
+              --prefix=/usr                 \
+              --bindir=/usr/bin             \
+              --infodir=/usr/share/info     \
+              --mandir=/usr/share/man       \
+              --enable-libraries            \
+              --enable-client               \
+	      --disable-manager             \
+	      --disable-server              \
+              $OPTS                        &&
+
+  default_make                             &&
+
+  # creates 'boinc' user if necessary
+  if grep "^boinc:" /etc/passwd > /dev/null; then
+    echo "user 'boinc' already exists"
+  else
+    useradd --system              \
+            --user-group          \
+            --create-home         \
+            --home /var/lib/boinc \
+            boinc
+  fi
+
+) > $C_FIFO 2>&1
diff --git a/zbeta/boinc-svn/DEPENDS b/zbeta/boinc-svn/DEPENDS
new file mode 100644
index 0000000..4f09565
--- /dev/null
+++ b/zbeta/boinc-svn/DEPENDS
@@ -0,0 +1,2 @@
+depends %SSL
+depends curl
diff --git a/zbeta/boinc-svn/DETAILS b/zbeta/boinc-svn/DETAILS
new file mode 100644
index 0000000..4236cd3
--- /dev/null
+++ b/zbeta/boinc-svn/DETAILS
@@ -0,0 +1,15 @@
+          MODULE=boinc-svn
+             MOD=boinc
+         VERSION=trunk
+	  SOURCE=$MOD-$VERSION.tar.bz2
+SOURCE_DIRECTORY=$BUILD_DIRECTORY/$MOD-$VERSION
+      SOURCE_URL=svn+http://boinc.berkeley.edu/svn/trunk/boinc
+        WEB_SITE=http://boinc.berkeley.edu/
+         ENTERED=20101230
+         UPDATED=20101230
+           SHORT="Berkeley Open Infrastructure for Network Computing"
+cat << EOF
+Use the idle time on your computer to cure deseases, study global
+warming, discover pulsars and do many other types of scientific
+research.
+EOF
diff --git a/zbeta/boinc-svn/init.d/boinc-client b/zbeta/boinc-svn/init.d/boinc-client
new file mode 100644
index 0000000..c72fe71
--- /dev/null
+++ b/zbeta/boinc-svn/init.d/boinc-client
@@ -0,0 +1,279 @@
+#!/bin/bash 
+#
+# chkconfig: 345 98 02
+# description: This script starts the local BOINC client as a daemon
+#         For more information about BOINC (the Berkeley Open Infrastructure
+#         for Network Computing) see http://boinc.berkeley.edu
+# processname: boinc
+# config: /etc/default/boinc
+#
+########################################################################
+
+## These 4 installation dirs set by autoconf. ##########################
+prefix=`dirname @prefix@/.`
+exec_prefix=`dirname @exec_prefix@/.`
+bindir=`dirname @bindir@/.`
+sysconfdir=`dirname @sysconfdir@/.`
+########################################################################
+ 
+# set the basic PATH
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+export PATH
+
+BOINCUSER=boinc
+BOINCDIR=/var/lib/boinc
+BOINCEXE_NAME=boinc_client
+BOINCEXE=${bindir}/${BOINCEXE_NAME}
+BOINCCMD_NAME=boinccmd
+BOINCCMD=${bindir}/${BOINCCMD_NAME}
+LOGFILE=/var/log/${BOINCEXE_NAME}.log
+ERRORLOG=/var/log/${BOINCEXE_NAME}_err.log
+PIDFILE=/var/run/${BOINCEXE_NAME}.pid
+BOINCOPTS="--daemon"
+
+# Subsys lock file ...
+
+# If there is the subsys directory, then use it ...
+if [ -d /var/lock/subsys/ ]; then
+        LOCKFILE=/var/lock/subsys/${BOINCEXE_NAME}
+elif [ -d /var/lock ]; then
+        LOCKFILE=/var/lock/${BOINCEXE_NAME}
+elif [ -d /var/run ]; then
+        LOCKFILE=/var/run/${BOINCEXE_NAME}.lock
+fi
+
+# su on Linux seems to need this to be set to work properly in a script
+export TERM=dumb
+
+# define the output string colors and text
+        ESC=`echo -en "\033"`
+  RESULT_OK="${ESC}[\061;32m${ESC}[70G[\040\040\040OK\040\040\040]${ESC}[m"
+RESULT_FAIL="${ESC}[\061;31m${ESC}[70G[\040FAILED\040]${ESC}[m"
+RESULT_WARN="${ESC}[\061;33m${ESC}[70G[\040\040WARN\040\040]${ESC}[m"
+
+function echo_success () { echo -e -n $RESULT_OK ; }
+function echo_failure () { echo -e -n $RESULT_FAIL ; }
+function echo_warning () { echo -e -n $RESULT_WARN ; }
+
+function killproc() {
+     PID=`local_pidof $1`
+     [ -z $PID ] && kill $PID 
+}
+
+# check if we have pidof.  If not use ps and grep for the same job.
+if [ -x /bin/pidof ] ; then 
+  function local_pidof() { 
+    pidof -s -x -o $$ -o $PPID -o %PPID $1 
+  } 
+else
+  function local_pidof() {
+    ps xaugww | sed 's/$/ /' | grep "[ /]$1 " | grep -v $$ | grep -v $PPID | grep -v %PPID | grep -v grep | awk '{print $2}'
+  }
+fi
+
+# overwrite settings from conf file
+. /etc/default/boinc-client
+
+## Check what user we are running as:
+USERNOW=`ps u $$ | tail -1 | awk '{print $1}'`
+if [ -z "$BOINCUSER" ] ; then
+  BOINCUSER="${USERNOW}"
+fi
+
+## Check that BOINCUSER actually exists
+if [ -z "`grep ^${BOINCUSER}: /etc/passwd`" ] ; then
+  if [ -z "`ypcat passwd 2>/dev/null | grep ^${BOINCUSER}:`" ] ; then 
+    if [ -z "`nidump passwd / 2>/dev/null | grep ^${BOINCUSER}:`" ] ; then 
+       echo -n ERROR: user ${BOINCUSER} does not exist.
+       echo_failure
+       echo
+       exit 9
+    fi
+  fi
+fi
+
+# if we are running as root, print a warning.
+if [ "x$NOWARNING" != "xyes" -a  "$BOINCUSER" = "root" ] ; then
+  echo -n WARNING: boinc-client will be running as root
+  echo_warning
+  echo
+fi
+
+# check whether we will be able to write to the BOINC directory
+if [ "${USERNOW}" = "${BOINCUSER}" ] ; then
+  if [ ! -O ${BOINCDIR} ] ; then
+    echo -n ERROR: $BOINCDIR is not owned by $BOINCUSER.
+    echo_failure
+    echo
+    exit 8
+  fi
+elif [ "${USERNOW}" = "root" ] ; then
+  cmd="if test -O ${BOINCDIR} ; then echo success ; fi"
+  if [ -z `su $BOINCUSER -c "$cmd"` ]; then
+    echo -n ERROR: $BOINCDIR is not owned by $BOINCUSER.
+    echo_failure
+    echo
+    exit 8
+  fi
+fi
+
+
+## Locate the executable, either boinc_client, boinc, 
+## or boinc_M.mm_.... with highest version number
+## We only do this if BOINCEXE set above isn't found or is not executable.
+if [ ! -x $BOINCEXE ]; then
+  BOINCEXE=`$WHICH $BOINCEXE_NAME 2>/dev/null`
+  if [ ! -x "$BOINCEXE" ]; then
+    BOINCEXE=`$WHICH boinc 2>/dev/null`
+  fi
+fi
+
+if [ ! -x "$BOINCEXE" ]; then
+  echo -n "Cannot find an executable for the BOINC client."
+  echo_failure
+  echo 
+  exit 2
+fi
+
+## boinccmd will probably be in the same place as the boinc_client
+if [ ! -x $BOINCCMD ]; then
+  BOINCCMD=`$WHICH $BOINCCMD_NAME 2>/dev/null`
+  if [ ! -x "$BOINCCMD" ]; then
+    BOINCCMD=`dirname $BOINCEXE 2>/dev/null`/${BOINCCMD_NAME}
+  fi
+fi
+
+
+if [ "x$NOWARNING" != "xyes" -a ! -x $BOINCCMD ]; then
+  echo -n "Cannot find the boinccmd executable.  Reload will fail."
+  echo_warning
+  echo
+fi
+
+## Functions: $1 is one of  start|stop|status|reload|restart
+
+export NOWARNING=yes
+
+case "$1" in
+  start)
+        cd $BOINCDIR
+        PID=`local_pidof $BOINCEXE_NAME`
+
+        if [ -f lockfile -o -f $LOCKFILE ] ; then
+          if [ -z "$PID" ] ; then
+            # a lockfile exists, but boinc_client isn't running
+            /bin/rm -f lockfile $LOCKFILE $PIDFILE 2>&1 > /dev/null
+          else 
+            echo -n "Another instance of BOINC is running (PID=${PID})."
+            echo_failure
+            echo 
+            exit 1
+          fi
+        fi
+
+        if [ ! -d projects ] ; then
+          echo -n "The BOINC client requires initialization."
+          echo_warning
+          echo 
+        fi
+
+        touch ${LOGFILE} ${ERRORLOG}
+        NOCORE="ulimit -c 0 2>&1 >/dev/null"
+        echo -n "Starting BOINC client as a daemon:  "
+        if [ "${BOINCUSER}" = "${USERNOW}" ] ; then 
+           # I am BOINCUSER.  Just start client as me.
+           $NOCORE
+           $BOINCEXE $BOINCOPTS >>$LOGFILE 2>>$ERRORLOG &
+        else
+           chown ${BOINCUSER} ${LOGFILE} ${ERRORLOG}
+           if [ -f gui_rpc_auth.cfg ] ; then
+              chmod g+r gui_rpc_auth.cfg 
+           fi
+           su - $BOINCUSER -c "$NOCORE ; $BOINCEXE $BOINCOPTS >>$LOGFILE 2>>$ERRORLOG" 2>/dev/null > /dev/null &
+        fi
+        sleep 3  
+        PID=`local_pidof $BOINCEXE_NAME`
+        if [ "$PID" != "" ]; then
+          echo $PID > $PIDFILE
+          touch $LOCKFILE && echo_success || ( echo_failure ; echo )
+        fi
+        echo
+        ;;
+  stop)
+        cd $BOINCDIR
+        if [ ! -f $PIDFILE -a ! -f lockfile -a ! -f $LOCKFILE ] ; then
+          echo -n "BOINC is not running (no lockfiles found)."
+          echo_success
+        else
+          echo -n "Stopping BOINC client daemon:  "    
+          if [ -f $PIDFILE ] ; then
+            PID=`cat $PIDFILE`
+            if [ -n "`ps $PID | grep $PID`" ] ; then
+              kill `cat $PIDFILE`
+              sleep 5
+            fi
+            if [ -z "`ps $PID | grep $PID`" ] ; then
+              echo_success
+            else
+              echo_failure
+              echo
+            fi
+          else
+            killproc $BOINCEXE_NAME  && echo_success  || echo_failure 
+          fi
+          # clean up in any case
+          rm -f lockfile 2>/dev/null >/dev/null
+          rm -f $LOCKFILE 2>/dev/null
+          rm -f $PIDFILE 2>/dev/null
+        fi
+        echo
+        ;;
+  reload)
+        if [ ! -f lockfile -a ! -f $LOCKFILE ] ; then
+          echo  "BOINC is not running (no lockfiles found) -- starting service."
+          $0 start
+        else
+          $BOINCCMD --read_cc_config >>$LOGFILE 2>>$ERRORLOG && echo_success || $0 restart
+        fi
+        ;;
+  restart)
+        $0 stop
+        $0 start
+        ;;
+
+  status)
+        PID=`cat $PIDFILE 2>/dev/null`
+        if [ "$PID" != "" ]; then
+          # is it still running?
+          if [ -z "`ps $PID | grep $PID`" ]; then
+            # not running.  Try the other tests.
+            PID=""
+          fi
+        fi
+        if [ "$PID" == "" ]; then
+          PID=`local_pidof $BOINCEXE_NAME`
+        fi
+        if [ "$PID" == "" ]; then
+          PID=`local_pidof $BOINCEXE`
+        fi
+        if [ "$PID" != "" ]; then
+          echo "BOINC client is running (pid $PID)."
+        else
+          if [ -f $BOINCDIR/lockfile -o -f $LOCKFILE ]; then 
+             echo "BOINC is stopped but lockfile(s) exist."
+             exit 2
+          else 
+             echo "BOINC client is stopped."
+             exit 3
+          fi
+        fi
+        ;;
+
+  *)
+        echo "Usage: boinc {start|stop|restart|reload|status}"
+        exit 1
+esac
+
+exit
+
+#EOF#


More information about the Lunar-commits mailing list