#!/bin/bash # # BOINC - start and stop the BOINC client daemon on Unix # # SysVInit start/stop script to run the BOINC client as a daemon at # system startup, as the $BOINCUSER (not root!). # # This version has been modified for Fedora/RHEL. # ### # chkconfig: - 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-client # config: /etc/sysconfig/boinc-client # ### BEGIN INIT INFO # Provides: boinc # Required-Start: $network # Required-Stop: $network # Default-Start: # Default-Stop: 0 1 2 6 # Short-Description: This script monitors the BOINC client. # 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 ### END INIT INFO # # Based on the init script provided by: # Eric Myers <myers@vassar.edu> - 27 July 2004 # Department of Physics and Astronomy, Vassar College, Poughkeepsie NY # Eric Myers <myers@spy-hill.net> # Spy Hill Research, Poughkeepsie, New York # # Rewritten by Milos Jakubicek <xjakub@fi.muni.cz> - 10 March 2009 # Faculty of Informatics, Masaryk University Brno, Czech Republic ######################################################################## # Defaults, which can be overridden by putting new NAME=value lines # in /etc/sysconfig/boinc-client # Name of user to run as: BOINCUSER=boinc # Working directory. BOINCDIR="/var/lib/boinc" # Name of the client executable. BOINCEXE="/usr/bin/boinc_client" BOINCCMD="/usr/bin/boinccmd" # Log and error files (should be placed in /var/log/ to avoid SELinux related issues) LOGFILE="/var/log/boinc.log" ERRORLOG="/var/log/boincerr.log" # BOINC options: for the command line when running the client. BOINCOPTS= # Service name prog=boinc-client # Subsys lock file LOCKFILE="/var/lock/subsys/$prog" # Init script function library. . /etc/rc.d/init.d/functions # Look for any local configuration settings which override all above [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog # Verify the $BOINCDIR working directory exists if [ ! -d $BOINCDIR ]; then echo -n "Cannot find BOINC directory $BOINCDIR" echo_failure echo exit 7 fi # Verify the $BOINCEXE executable exists if [ ! -x $BOINCEXE ]; then echo -n "Cannot find an executable for the BOINC client." echo_failure echo exit 2 fi # Warn if there are no projects attached cd $BOINCDIR if [ ! -d projects ] ; then echo -n "BOINC client requires initialization (no projects attached)." echo_warning echo fi check_status() { status $BOINCEXE >& /dev/null } start() { check_status && exit 0 echo -n $"Starting $prog: " # Check that we're a privileged user if [ `id -u` != 0 ] ; then echo -n "Insufficient rights." failure echo exit 4 fi # Check that log files exist, otherwise create them with proper ownership if [ ! -e $LOGFILE ]; then touch $LOGFILE && chown $BOINCUSER:$BOINCUSER $LOGFILE fi if [ ! -e $ERRORLOG ]; then touch $ERRORLOG && chown $BOINCUSER:$BOINCUSER $ERRORLOG fi daemon --check $BOINCEXE --user $BOINCUSER +10 "$BOINCEXE $BOINCOPTS --dir $BOINCDIR >>$LOGFILE 2>>$ERRORLOG &" >& /dev/null # Check that boinc is running, give it a few tries TRY=0 while [ $TRY -lt 10 ] ; do check_status && { touch $LOCKFILE; success; echo; return; } || sleep 1 let TRY+=1 done; check_status && { touch $LOCKFILE; success; } || failure echo } stop() { cd $BOINCDIR check_status || exit 0 echo -n $"Stopping $prog: " killproc -d 10 $BOINCEXE rm -f $LOCKFILE echo } reload() { check_status || { start; exit; } action "Reading configuration: " $BOINCCMD --read_cc_config | sed -e "s/retval.*//" -e "N;s/\n//;" } restart() { stop start } case "$1" in start) $1 ;; stop) $1 ;; reload) $1 ;; restart) $1 ;; force-reload) reload restart ;; condrestart|try-restart) check_status || exit 0 restart ;; status) status $BOINCEXE ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" exit 2 esac exit $?