#!/bin/sh # # BOINC - start and stop the BOINC client daemon on Unix # # Unix start/stop script to run the BOINC client as a daemon at # system startup, as the 'boinc' user (not root!). # # This version works on Red Hat Linux, Fedora Core, Mandriva, # and Slackware Linux, and should work on generic Linux systems # provided they have 'pidof'. Metadata for chkconfig and the SUSE # equivalent INIT info are included below. # # Usage: boinc { start | stop | restart | status } # #### # chkconfig: 345 98 03 # description: This script starts the local BOINC client as a daemon \ # BOINC lets you donate your idle computer time to science \ # projects like SETI@home, Climateprediction.net, Rosetta@home, \ # World Community Grid, and many others. \ # For more info about BOINC (the Berkeley Open Infrastructure \ # for Network Computing) see http://boinc.ssl.berkeley.edu # processname: boinc # config: /etc/sysconfig/boinc # ### BEGIN INIT INFO # Provides: boinc # Required-Start: $network # Required-Stop: $network # Default-Start: 3 4 5 # Default-Stop: 0 1 2 6 # Short-Description: BOINC client daemon initialization script # Description: This script starts the local BOINC client as a daemon \ # BOINC lets you donate your idle computer time to science \ # projects like SETI@home, Climateprediction.net, Rosetta@home, \ # World Community Grid, and many others. \ # For more info about BOINC (the Berkeley Open Infrastructure \ # for Network Computing) see http://boinc.ssl.berkeley.edu ### END INIT INFO # # Eric Myers - 27 July 2004 # Department of Physics and Astronomy, Vassar College, Poughkeepsie NY # Eric Myers # Spy Hill Research, Poughkeepsie, New York # # Jose Da Silva - 30 September 2007 # Minor changes plus used LSB type error return codes 0..7 # # @(#) $Id: boinc,v 1.8.1 2007/09/30 01:01:01 Joses Exp $ ######################################################################## # Defaults, these can be overridden in /etc/sysconfig/boinc BOINCUSER=boinc BOINCDIR=/opt/BOINC BOINCEXE=boinc BOINCERR=0 # Additional BOINC options: # Be wary of -allow_remote_gui_rpc, as it can open your machine up # to the world if you don't set a password, or if you set a poor one. # Should be okay if you are behind a NAT firewall. #BOINCOPTS="-allow_remote_gui_rpc" # opens up your machine to the world! BOINCOPTS= # Log and error files (you should rotate these occasionally) #LOGFILE=boinc.log #ERRORLOG=error.log # Or if you are not using them at all, then send them to null LOGFILE=/dev/null ERRORLOG=/dev/null # Look for any local configuration settings which override all above if [ -f /etc/sysconfig/boinc ]; then . /etc/sysconfig/boinc elif [ -f /etc/default/boinc ]; then . /etc/default/boinc fi # Source function library. if [ -f /etc/init.d/functions ] ; then . /etc/init.d/functions elif [ -f /etc/rc.d/init.d/functions ] ; then . /etc/rc.d/init.d/functions else exit 0 fi # Direct paths to commands used in this script (no path searches needed) CHMOD=/bin/chmod CHOWN=/bin/chown ECHO=/bin/echo NICE=/bin/nice PIDOF=/sbin/pidof RM=/bin/rm SLEEP=/bin/sleep SU=/bin/su TOUCH=/bin/touch # Mandriva 2007 really wants a lock file located here ... if [ -d /var/lock/subsys ]; then LOCKDIR=/var/lock/subsys elif [ -d /var/lock ]; then LOCKDIR=/var/lock fi ## Locate the boinc directory and executable if [ ! -d $BOINCDIR ]; then $ECHO -n $"Cannot find the BOINC directory: ${BOINCDIR}" echo_failure $ECHO exit 5 fi if [ ! -x "$BOINCDIR/$BOINCEXE" ]; then $ECHO -n $"Cannot find the BOINC executable client: ${BOINCEXE}" echo_failure $ECHO exit 5 fi # Functions: $1 is one of start|stop|restart|status case "$1" in start) $0 stop cd $BOINCDIR if [ -f lockfile ]; then $ECHO -n $"Another BOINC is running here (lockfile exists)." echo_failure BOINCERR=3 fi if [ ! -f client_state.xml -o ! -d projects ]; then $ECHO -n $"This BOINC client requires initialization." echo_warning BOINCERR=6 fi $ECHO -n $"Starting BOINC service:" $NICE $SU $BOINCUSER -c "$BOINCDIR/$BOINCEXE $BOINCOPTS" >>$LOGFILE 2>>$ERRORLOG & $SLEEP 3 PID=`$PIDOF -s -x -o $$ -o $PPID -o %PPID $BOINCEXE` if [ $PID ]; then $TOUCH "$LOCKDIR/$BOINCEXE" echo_success else echo_failure BOINCERR=1 fi ;; stop) cd $BOINCDIR if [ ! -f lockfile -a ! -f "$LOCKDIR/$BOINCEXE" ]; then $ECHO -n $"${BOINCEXE} is not running (no lockfile found)." echo_success else $ECHO -n $"Stopping ${BOINCEXE} client daemon:" killproc $BOINCEXE && echo_success || echo_failure fi $RM -f lockfile $RM -f "$LOCKDIR/$BOINCEXE" ;; restart) $0 stop $0 start ;; status) PID=`$PIDOF -x -o $$ -o $$PPID -o %PPID boinc_client` if [ "$PID" == "" ]; then PID=`$PIDOF -x -o $$ -o $$PPID -o %PPID $BOINCEXE` fi if [ "$PID" != "" ]; then $ECHO -n $"${BOINCEXE} (pid $PID) is running..." echo_success #kill -SIGUSR1 $PID; else if [ -f "$BOINCDIR/lockfile" -o -f "$LOCKDIR/$BOINCEXE" ]; then $ECHO -n $"${BOINCEXE} is stopped but lockfile exists." echo_warning BOINCERR=7 else $ECHO -n $"${BOINCEXE} is not running!"; # Do not echo OK or FAIL. result may be okay, or not. fi fi ;; *) $ECHO $"Usage: ${0} {start|stop|restart|status}" exit 1 esac $ECHO exit $BOINCERR