[Lunar-commits] <moonbase> boinc: new, as alternative to boinc-svn

Duncan Gibson engelsman at lunar-linux.org
Mon Apr 25 17:20:02 CEST 2011


commit af5c2b01a7d3e9b09826e74542512361f084b8fc
Author: Christian Krause <kizkizzbangbang at googlemail.com>
Date:   Mon Apr 25 17:20:02 2011 +0200

    boinc: new, as alternative to boinc-svn
    
    unfortunately this is based on svn, too, because the boinc guys don't provide
    us with source tarballs ... pls have a look at the SOURCE_VFY!
    
    NOTE: an svn download in lunar, even of a fixed version, will always
          create a tarball with a different sha1sum (due to current date
          and time perhaps?) so I will zap the SOURCE_VFY.
          This is a zbeta module, so Caveat Emptor! - engelsman
---
 zbeta/boinc/BUILD               |   44 ++++++
 zbeta/boinc/CONFLICTS           |    1 +
 zbeta/boinc/DEPENDS             |    2 +
 zbeta/boinc/DETAILS             |   18 +++
 zbeta/boinc/init.d/boinc-client |  283 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 348 insertions(+), 0 deletions(-)

diff --git a/zbeta/boinc/BUILD b/zbeta/boinc/BUILD
new file mode 100644
index 0000000..e7834f2
--- /dev/null
+++ b/zbeta/boinc/BUILD
@@ -0,0 +1,44 @@
+(
+
+  # 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 &&
+
+  # get the alias
+  SSL=`unalias %SSL` &&
+
+  # setting the ssl option
+  if [[ $SSL == "openssl" ]] && module_installed "openssl" ; then
+        OPTS+=" --with-ssl --without-libgnutls"
+  elif [[ $SSL == "gnutls" ]] && module_installed "gnutls" ; then
+        OPTS+=" --with-libgnutls --without-ssl"
+  else
+        OPTS+=" --without-ssl --without-libgnutls"
+  fi &&
+
+  # TODO: move enable/disable client/server/manager to CONFIGURE
+  OPTS+=" --enable-shared --disable-static --enable-libraries --enable-client --enable-dynamic-client-linkage --disable-manager --disable-server" &&
+
+  default_build  &&
+
+  # creates 'boinc' user if necessary
+  if grep "^boinc:" /etc/passwd > /dev/null; then
+    message "${MESSAGE_COLOR}user 'boinc' already exists${DEFAULT_COLOR}"
+  else
+    useradd --system               \
+            --user-group           \
+            --create-home          \
+            --home /var/lib/boinc  \
+            boinc                 &&
+    message "${MESSAGE_COLOR}user 'boinc' created${DEFAULT_COLOR}"
+  fi  &&
+
+  # install bash completion
+  install -m755 client/scripts/boinc.bash /etc/bash_completion.d/boinc-bash-completion.sh
+
+) > $C_FIFO 2>&1
diff --git a/zbeta/boinc/CONFLICTS b/zbeta/boinc/CONFLICTS
new file mode 100644
index 0000000..4cad9f6
--- /dev/null
+++ b/zbeta/boinc/CONFLICTS
@@ -0,0 +1 @@
+conflicts boinc-svn
diff --git a/zbeta/boinc/DEPENDS b/zbeta/boinc/DEPENDS
new file mode 100644
index 0000000..4f09565
--- /dev/null
+++ b/zbeta/boinc/DEPENDS
@@ -0,0 +1,2 @@
+depends %SSL
+depends curl
diff --git a/zbeta/boinc/DETAILS b/zbeta/boinc/DETAILS
new file mode 100644
index 0000000..426bb4b
--- /dev/null
+++ b/zbeta/boinc/DETAILS
@@ -0,0 +1,18 @@
+          MODULE=boinc
+         VERSION=6.10.58
+             VER=6_10_58
+          SOURCE=$MODULE-$VERSION.tar.bz2
+# unfortunately they don't provide source tarballs
+      SOURCE_URL=svn+http://boinc.berkeley.edu/svn/tags/boinc_core_release_$VER
+# don't know if SOURCE_VFY works with svn tag -- pls check it
+#     SOURCE_VFY=sha1:69337e259c190b2393c83ab0a60e507f0ecd6a9e
+        WEB_SITE=http://boinc.berkeley.edu/
+         ENTERED=20110417
+         UPDATED=20110417
+           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/init.d/boinc-client b/zbeta/boinc/init.d/boinc-client
new file mode 100644
index 0000000..b5106c6
--- /dev/null
+++ b/zbeta/boinc/init.d/boinc-client
@@ -0,0 +1,283 @@
+#!/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 /usr/.`
+exec_prefix=`dirname /usr/.`
+bindir=`dirname /usr/bin/.`
+sysconfdir=`dirname ${prefix}/etc/.`
+########################################################################
+
+# 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
+if [[ -f /etc/default/boinc-client ]] ; then
+  . /etc/default/boinc-client
+elif [[ -f /etc/sysconfig/boinc-client ]] ; then
+  . /etc/sysconfig/boinc-client
+fi
+
+## 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