Commit 03b2b7e5 authored by Eric J. Korpela's avatar Eric J. Korpela

- Added init.d script (boinc-client.in) and Makefile.am to install it.

    - I got this from the Fedora package.  I have modified it to create the
      run directory if it does not exist, and to not run boinc as root.
      Checking for running processes needs to be improved.
    - boinc-client.in is still very linux centric and probably won't work on
      non-linux systems or under Bourne shell without significant changes.


svn path=/trunk/boinc/; revision=15018
parent f074fca3
...@@ -3084,3 +3084,18 @@ Charlie April 4 2008 ...@@ -3084,3 +3084,18 @@ Charlie April 4 2008
lib/ lib/
mac/ mac/
mac_backtrace.C mac_backtrace.C
Eric K April 4 2008
- Added init.d script (boinc-client.in) and Makefile.am to install it.
- I got this from the Fedora package. I have modified it to create the
run directory if it does not exist, and to not run boinc as root.
Checking for running processes needs to be improved.
- boinc-client.in is still very linux centric and probably won't work on
non-linux systems or under Bourne shell without significant changes.
configure.ac
client/
scripts/
Makefile.am
boinc-client.in
install:
$(INSTALL) -b boinc-client /etc/init.d/
#!/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, Mandrake, Debian,
# and Slackware Linux, and should work on generic Linux systems
# provided that they have 'pidof' (most do).
# Metadata for chkconfig and the SUSE equivalent INIT info are included below.
#
# Usage: boinc { start | stop | status | reload | restart }
#
###
# 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
# config: /etc/sysconfig/boinc
#
### 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
#
# 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
# @(#) $Id: boinc,v 1.10 2007/12/27 20:09:09 myers Exp $
########################################################################
# Defaults, which can be overridden by putting new NAME=value lines
# in /etc/sysconfig/boinc (for Red Hat/Fedora Linux and variants)
# or /etc/default/boinc (for Debian/Ubuntu and variants)
# Name of user to run as:
#
BOINCUSER=boinc
# Working directory. Could be /home/boinc, /var/lib/boinc, etc..
# The reason I prefer /var/lib/boinc is that this works best for a
# cluster of computers where /home/anything might be shared between machines
#
BOINCDIR=/var/lib/boinc
# Name of the client executable. This is the file "boinc" if you
# unpacked the download file boinc_M.mm.rr_i686-pc-linux-gnu.sh,
# but I like to rename it and put it in a public place.
# (Hint: move boincmgr to /usr/local/bin too so anyone can easily use it).
#
BOINCEXE=@bindir@/boinc_client
BOINCCMD=@bindir@/boinc_cmd
# Log and error files (you should rotate these occasionally)
#
LOGFILE=/var/log/boinc.log
ERRORLOG=/var/log/boincerr.log
# PID file
PIDFILE=/var/run/boinc_client.pid
# BOINC options: for the command line when running the client.
# Be aware that --allow_remote_gui_rpc opens up your machine to the world!
#
#BOINCOPTS="--allow_remote_gui_rpc"
BOINCOPTS="--daemon"
# Subsys lock file ...
# If there is the subsys directory, then use it ...
if [ -d /var/lock/subsys/ ]; then
LOCKFILE=/var/lock/subsys/boinc-client
elif [ -d /var/lock ]; then
LOCKFILE=/var/lock/boinc-client
fi
# su on Linux seems to need this to be set to work properly in a script
export TERM dumb
##
# Init script function library. This stuff is Red Hat specific,
# but if the functions are not found we create our own simple replacements.
# (The idea for replacing the functions comes from OpenAFS. Thanks guys!)
if [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
function echo_success () { echo -n " [ OK ] " ; }
function echo_failure () { echo -n " [FAILED] " ; }
function echo_warning () { echo -n " [WARNING] " ; }
function killproc() {
PID=`pidof -s -x -o $$ -o $PPID -o %PPID $1`
[ $PID ] && kill $PID ; }
fi
## 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
elif [ -f @prefix@/etc/boinc.conf ]; then
. @prefix@/etc/boinc.conf
elif [ -f /etc/boinc.conf ]; then
. /etc/boinc.conf
fi
## Create the working directory if it doesn't exist:
if [ ! -d $BOINCDIR ]; then
echo -n "Creating $BOINCDIR "
if /bin/mkdir -p $BOINCDIR && chown $BOINCUSER $BOINCDIR; then
echo_success
else
echo_failure
exit 7
fi
fi
if [ -z "$BOINCUSER" -o "$BOINCUSER" = "root" ] ; then
BOINCUSER=root
echo -n WARNING: boinc-client will be running as root
echo_warning
fi
if [ -z `su -s /bin/sh $BOINCUSER -c "if test -O ${BOINCDIR} ; then echo success ; fi"` ]; then
echo -n ERROR: $BOINCDIR is not owned by $BOINCUSER.
echo_failure
exit 8
fi
# find which in case we are running somewhere very odd...
if [ -x /usr/bin/which ] ; then
WHICH=/usr/bin/which
elif [ -x /bin/which ] ; then
WHICH=/bin/which
elif [ -x /usr/ucb/which ] ; then
WHICH=/usr/ucb/which
elif [ -x /usr/local/bin/which ] ; then
WHICH=/usr/local/bin/which
else
# give up and hope its in the path
WHICH=which
fi
# Some additional places to look for the client executable
# (Should do this after init.d/functions and sysconfig/boinc, which sets PATH)
export PATH=$BOINCDIR:/usr/local/bin:$PATH
## 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 boinc_client 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
## Functions: $1 is one of start|stop|status|reload|restart
case "$1" in
start)
cd $BOINCDIR
if [ -f lockfile ] ; then
echo -n "Another instance of BOINC is running (lockfile exists)."
echo_success
echo
exit
fi
if [ ! -d projects ] ; then
echo -n "The BOINC client requires initialization."
echo_warning
echo
fi
echo -n "Starting BOINC client as a daemon: "
daemon --user=$BOINCUSER --pidfile=$PIDFILE "$BOINCEXE $BOINCOPTS" >>$LOGFILE 2>>$ERRORLOG &
sleep 1
PID=`pidof -s -x -o $$ -o $PPID -o %PPID $BOINCEXE`
if [ $PID ]; then
touch $LOCKFILE && echo_success || echo_failure
fi
echo
;;
stop)
cd $BOINCDIR
if [ ! -f lockfile -a ! -f $LOCKFILE ] ; then
echo -n "BOINC is not running (no lockfiles found)."
echo_success
else
echo -n "Stopping BOINC client daemon: "
killproc $BOINCEXE && echo_success || echo_failure
# clean up in any case
rm -f $BOINCDIR/lockfile
rm -f $LOCKFILE
fi
echo
;;
reload)
if [ ! -f lockfile -a ! -f $LOCKFILE ] ; then
echo -n "BOINC is not running (no lockfiles found) -- starting service."
$0 start
else
$BOINCCMD --read_cc_config >>$LOGFILE 2>>$ERRORLOG && echo_success || $0 restart
fi
echo
;;
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 "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#
...@@ -662,6 +662,8 @@ AC_CONFIG_FILES([ ...@@ -662,6 +662,8 @@ AC_CONFIG_FILES([
clientgui/Makefile clientgui/Makefile
client/Makefile client/Makefile
client/win/boinc_path_config.py:py/Boinc/boinc_path_config.py.in client/win/boinc_path_config.py:py/Boinc/boinc_path_config.py.in
client/scripts/Makefile
client/scripts/boinc-client
db/Makefile db/Makefile
doc/Makefile doc/Makefile
doc/manpages/Makefile doc/manpages/Makefile
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment