3 # BOINC - start and stop the BOINC client daemon on Unix
5 # Unix start/stop script to run the BOINC client as a daemon at
6 # system startup, as the 'boinc' user (not root!).
8 # This version works on Red Hat Linux, Fedora Core, Mandrake, Debian,
9 # and Slackware Linux, and should work on generic Linux systems
10 # provided that they have 'pidof' (most do).
11 # Metadata for chkconfig and the SUSE equivalent INIT info are included below.
13 # Usage: boinc { start | stop | status | restart }
16 # chkconfig: 345 98 03
17 # description: This script starts the local BOINC client as a daemon
18 # For more information about BOINC (the Berkeley Open Infrastructure
19 # for Network Computing) see http://boinc.berkeley.edu
21 # config: /etc/sysconfig/boinc
25 # Required-Start: $network
26 # Required-Stop: $network
27 # Default-Start: 3 4 5
28 # Default-Stop: 0 1 2 6
29 # Description: This script starts the local BOINC client as a daemon
30 # For more information about BOINC (the Berkeley Open Infrastructure
31 # for Network Computing) see http://boinc.berkeley.edu
34 # Eric Myers <myers@vassar.edu> - 27 July 2004
35 # Department of Physics and Astronomy, Vassar College, Poughkeepsie NY
36 # Eric Myers <myers@spy-hill.net>
37 # Spy Hill Research, Poughkeepsie, New York
38 # @(#) $Id: boinc,v 1.8 2007/09/02 01:05:35 myers Exp $
39 ########################################################################
42 # Defaults, which can be overridden in /etc/sysconfig/boinc (Red Hat)
43 # or /etc/default/boinc (Debian)
47 BUILD_ARCH=i686-pc-linux-gnu
48 BOINCEXE=/usr/local/bin/boinc_client
51 # Log and error files (you should rotate these occasionally)
55 # Additional BOINC options:
56 # Be wary of -allow_remote_gui_rpc, as it can open your machine up
57 # to the world if you don't set a password, or if you set a poor one.
58 # Should be okay if you are behind a NAT firewall.
60 #BOINCOPTS="-allow_remote_gui_rpc" # opens up your machine to the world!
63 # Mandrake 10.1 really wants a subsys lock file ...
64 if [ -d /var/lock/subsys ]; then
65 LOCKDIR=/var/lock/subsys
66 elif [ -d /var/lock ]; then
70 # su on Linux seems to need this to be set to work properly in a script
75 # Init script function library. This stuff is Red Hat specific,
76 # but if the functions are not found we create our own simple replacements.
77 # (The idea for replacing the functions comes from OpenAFS. Thanks guys!)
79 if [ -f /etc/rc.d/init.d/functions ] ; then
80 . /etc/rc.d/init.d/functions
82 export PATH=/sbin:/bin:/usr/sbin:/usr/bin
83 function echo_success () { echo -n " [ OK ] " ; }
84 function echo_failure () { echo -n " [FAILED] " ; }
85 function echo_warning () { echo -n " [WARNING] " ; }
87 PID=$(pidof -s -x -o $$ -o $PPID -o %PPID $1)
88 [ $PID ] && kill $PID ; }
92 ## Look for any local configuration settings which override all above
94 if [ -f /etc/sysconfig/boinc ]; then
95 . /etc/sysconfig/boinc
96 elif [ -f /etc/default/boinc ]; then
101 ## Verify the working directory exists:
103 if [ ! -d $BOINCDIR ]; then
104 echo -n "Cannot find BOINC directory $BOINCDIR "
111 # Some additional places to look for the client executable
112 # (Should do this after init.d/functions and sysconfig/boinc, which sets PATH)
114 export PATH=$BOINCDIR:/usr/local/bin:$PATH
117 ## Locate the executable, either boinc_client, boinc,
118 ## or boinc_M.mm_.... with highest version number
119 ## We only do this if BOINCEXE set above isn't found and executable.
121 if [ ! -x $BOINCEXE ]; then
122 BOINCEXE=$(/usr/bin/which boinc_client 2>/dev/null)
123 if [ ! -x "$BOINCEXE" ]; then
124 BOINCEXE=$(/usr/bin/which boinc 2>/dev/null)
125 if [ ! -x "$BOINCEXE" ]; then
126 BOINCEXE=$(/bin/ls -1 $BOINCDIR/boinc_*_$BUILD_ARCH 2>/dev/null | tail -1 )
131 if [ ! -x "$BOINCEXE" ]; then
132 echo -n "Cannot find an executable for the BOINC client."
140 ## Functions: $1 is one of start|stop|status|restart
146 if [ -f lockfile ] ; then
147 echo -n "Another instance of BOINC is running (lockfile exists)."
153 if [ ! -d projects ] ; then
154 echo -n "The BOINC client requires initialization."
159 echo -n "Starting BOINC client as a daemon: "
160 su $BOINCUSER -c "$BOINCEXE $BOINCOPTS" >>$LOGFILE 2>>$ERRORLOG &
162 PID=$(pidof -s -x -o $$ -o $PPID -o %PPID $BOINCEXE)
164 [ -d $LOCKDIR ] && touch $LOCKDIR/boinc
174 if [ ! -f lockfile -a ! -f $LOCKDIR/boinc ] ; then
175 echo -n "BOINC is not running (no lockfiles found)."
178 echo -n "Stopping BOINC client daemon: "
179 killproc $BOINCEXE && echo_success || echo_failure
180 # clean up in any case
181 rm -f $BOINCDIR/lockfile
193 PID=$(pidof -x -o $$ -o $PPID -o %PPID boinc_client)
194 if [ "$PID" == "" ]; then
195 PID=$(pidof -x -o $$ -o $PPID -o %PPID $BOINCEXE)
197 if [ "$PID" != "" ]; then
198 echo "BOINC client is running (pid $PID)."
200 if [ -f $BOINCDIR/lockfile -o -f $LOCKDIR/boinc ]; then
201 echo "BOINC is stopped but lockfile(s) exist."
203 echo "BOINC client is stopped."
209 echo "Usage: boinc {start|stop|restart|status}"