FANDOM


You want to run the boinc core client as a service on your OpenSuse installation?

Here are 3 files that hopefully are of help for you.


  • boinc, the service script derived from the original /etc/init.d/sceleton script coming with each installation
  • BOINC, the configuration file sitting in /etc/sysconfig
  • boinc_installation.sh, a script that will do the work for you. Create a user boinc, a group boinc, copy and install the files and configure your system for running boinc as a service - if you want to.

The place for installation is /usr/local/boinc, but you can easily change that place even after installation through simply editing /etc/sysconfig/BOINC

Content of file BOINC:

# boinc client startup options
BOINC_SUBDIR=/boinc
BOINC_CLIENT_ARGS=--allow_remote_gui_rpc
BOINC_USER=boinc
BOINC_PRIORITY=19
BOINC_LOGFILE=/usr/local$BOINC_SUBDIR/BOINC/log.txt
BOINC_DIR=/usr/local$BOINC_SUBDIR/BOINC
BOINC_BIN=/usr/local$BOINC_SUBDIR/BOINC/boinc

Content of file boinc:

#!/bin/sh
#
#     This library is free software; you can redistribute it and/or modify it
#     under the terms of the GNU Lesser General Public License as published by
#     the Free Software Foundation; either version 2.1 of the License, or (at
#     your option) any later version.
#			      
#     This library is distributed in the hope that it will be useful, but
#     WITHOUT ANY WARRANTY; without even the implied warranty of
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#     Lesser General Public License for more details.
#      
#     You should have received a copy of the GNU Lesser General Public
#     License along with this library; if not, write to the Free Software
#     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
#     USA.
#
# /etc/init.d/boinc
#
# system startup script for service/daemon BOINC
#
# LSB compatible service control script; see http://www.linuxbase.org/spec/
# 
### BEGIN INIT INFO
# Provides:          BOINC
# Required-Start:    $syslog $local_fs $network
# Should-Start: $time ypbind sendmail
# Required-Stop:     $syslog $local_fs $network
# Should-Stop: $time ypbind sendmail
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: BOINC daemon
# Description:       Start BOINC daemon for distributed computing
### END INIT INFO

# Check for existence of needed config file and read it
BOINC_CONFIG=/etc/sysconfig/BOINC
test -r $BOINC_CONFIG || { echo "$BOINC_CONFIG not available";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 6; fi; }
	
# Read config	
. $BOINC_CONFIG	
	
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
test -x $BOINC_BIN || { echo "$BOINC_BIN not installed";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

# Source LSB init functions
# providing start_daemon, killproc, pidofproc, 
# log_success_msg, log_failure_msg and log_warning_msg.
# This is currently not used by UnitedLinux based distributions and
# not needed for init scripts for UnitedLinux only. If it is used,
# the functions from rc.status should not be sourced or used.
#. /lib/lsb/init-functions

# Shell functions sourced from /etc/rc.status:
#      rc_check         check and set local and overall rc status
#      rc_status        check and set local and overall rc status
#      rc_status -v     be verbose in local rc status and clear it afterwards
#      rc_status -v -r  ditto and clear both the local and overall rc status
#      rc_status -s     display "skipped" and exit with status 3
#      rc_status -u     display "unused" and exit with status 3
#      rc_failed        set local and overall rc status to failed
#      rc_failed <num>  set local and overall rc status to <num>
#      rc_reset         clear both the local and overall rc status
#      rc_exit          exit appropriate to overall rc status
#      rc_active        checks whether a service is activated by symlinks
. /etc/rc.status

# Reset status of this service
rc_reset

# Return values acc. to LSB for all commands but status:
# 0	  - success
# 1       - generic or unspecified error
# 2       - invalid or excess argument(s)
# 3       - unimplemented feature (e.g. "reload")
# 4       - user had insufficient privileges
# 5       - program is not installed
# 6       - program is not configured
# 7       - program is not running
# 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
# 
# Note that starting an already running service, stopping
# or restarting a not-running service as well as the restart
# with force-reload (in case signaling is not supported) are
# considered a success.

case "$1" in
    start)
	echo -n "Starting BOINC "
	## Start daemon with startproc(8). If this fails
	## the return value is set appropriately by startproc.
	/sbin/startproc -n $BOINC_PRIORITY -u $BOINC_USER -l $BOINC_LOGFILE -s $BOINC_BIN -dir $BOINC_DIR $BOINC_CLIENT_ARGS

	# Remember status and be verbose
	rc_status -v
	;;
    stop)
	echo -n "Shutting down BOINC "
	## Stop daemon with killproc(8) and if this fails
	## killproc sets the return value according to LSB.

	/sbin/killproc -TERM $BOINC_BIN

	# Remember status and be verbose
	rc_status -v
	;;
    try-restart|condrestart)
	## Do a restart only if the service was active before.
	## Note: try-restart is now part of LSB (as of 1.9).
	## RH has a similar command named condrestart.
	if test "$1" = "condrestart"; then
		echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
	fi
	$0 status
	if test $? = 0; then
		$0 restart
	else
		rc_reset	# Not running is not a failure.
	fi
	# Remember status and be quiet
	rc_status
	;;
    restart)
	## Stop the service and regardless of whether it was
	## running or not, start it again.
	$0 stop
	$0 start

	# Remember status and be quiet
	rc_status
	;;
    status)
	echo -n "Checking for service BOINC "
	## Check status with checkproc(8), if process is running
	## checkproc will return with exit status 0.

	# Return value is slightly different for the status command:
	# 0 - service up and running
	# 1 - service dead, but /var/run/  pid  file exists
	# 2 - service dead, but /var/lock/ lock file exists
	# 3 - service not running (unused)
	# 4 - service status unknown :-(
	# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
	
	# NOTE: checkproc returns LSB compliant status values.
	/sbin/checkproc $BOINC_BIN
	# NOTE: rc_status knows that we called this init script with
	# "status" option and adapts its messages accordingly.
	rc_status -v
	;;
    *)
	echo "Usage: $0 {start|stop|status|try-restart|restart}"
	exit 1
	;;
esac
rc_exit

boinc_install.sh, the script to install the whole stuff:

#!/bin/sh
### Author: Michael Schmitt 
### Version: 0.0.2
### Last modified: 2009-08-29
### send feedback to biker54@ebs-schmitt.de
### USE AT YOUR OWN RISC!
### run this script as root only!

USER=boinc # boinc user
GROUP=boinc # boinc group
BS=boinc # name of the script for the boinc service
BC=BOINC # name of the configure script for the boinc service

if ! test -w /etc/passwd; then
	echo "Only root can run this script!"
	exit 1
fi

scripts=
client=

### I create a special group for boinc services
if grep $GROUP: /etc/group > /dev/null; then
	echo "The group $GROUP already exists, skipping group creation..."
else
	echo "Creating group $GROUP"
	groupadd $GROUP
fi

### And a special user too. Don't, call me paranoiac. ;-)
### Password is simply "#" in front of the user-name, followed by "!".
### In the original script this ends up in #boinc!
if  grep $USER: /etc/passwd > /dev/null;  then
	echo "The user $USER already exists, skipping user creation..."
else
	echo "Creating user $USER"
	useradd $USER -g $GROUP
	echo "#"$USER"!" | passwd --stdin "$USER"
fi

### create directory for client installation
mkdir /usr/local/$USER
chown $USER:$GROUP /usr/local/$USER

echo ""
if test -f ./$BS && test -f ./$BC; then
	echo "I found the startup scripts and will copy them in the right directories..."
	cp ./$BS /etc/init.d/$BS
	chown root:root /etc/init.d/$BS
	chmod u=rwx,g=r,o=r /etc/init.d/$BS
	cp ./$BC /etc/sysconfig/$BC
	chown root:root /etc/sysconfig/$BC
	chmod u=rw,g=r,o=r /etc/sysconfig/$BC
	scripts=1
else
	a=
	echo "No startup scripts found. Ether copy them to the same place as this script,"
	echo "so I can copy them and setup your system, or proceed anyway if you want to do"
	echo "this manually."
	scripts=0
	echo -n "Continue anyway (y/n)? "
	while [ "$a" != "y" ] && [ "$a" != "n" ]; do
		read a
	done
	if [ "$a" == "n" ]; then
		### quit script
		exit 1
	fi
fi

### watch out that there is no similar file in this directory!
boinc_install=`ls boinc_*gnu.sh` # is there a boinc core client install file?
if test $boinc_install; then
	echo "Found a BOINC core client install file: <$boinc_install> and will install it."
	cp $boinc_install /usr/local/$USER/$boinc_install
	chmod u=rwx,g=r,o=r /usr/local/$USER/$boinc_install
	chown $USER:$GROUP /usr/local/$USER/$boinc_install
	cd /usr/local/$USER
	./$boinc_install > /dev/null
	chown -R $USER:$GROUP /usr/local/$USER/BOINC
	chmod -R o=-x /usr/local/$USER/BOINC/*
	### Make shure everybody can run the manager
	chmod o=+rx /usr/local/$USER/BOINC/boincmgr
	client=1
else
	client=0
	echo "No BOINC core client install file found. Ether copy a BOINC installable in"
	echo "the local directory, or skip this and do a manual install."
	echo -n "Continue anyway (y/n)? "
	while [ "$a" != "y" ] && [ "$a" != "n" ]; do
		read a
	done
	if [ "$a" == "n" ]; then
		### quit script
		exit 1
	fi
fi

echo ""
echo ""
echo ""
echo "             Summary of my activities:               "
echo ""
if [ $scripts==1 ]; then
	echo "The startup scripts were found and copied:"
	echo "$BS was copied to /etc/init.d/$BS"
	echo "$BC was copied to /etc/sysconfig/$BC"
	echo "$BC is the config file for your installation."
	echo "$BS starts boinc as a service. Actually it does not jet!"
	echo "First I must tell the system to add the servive to the boot procedure."
	echo ""
	echo -n "Am I allowed to do so (y/n)? "
	while [ "$a" != "y" ] && [ "$a" != "n" ]; do
		read a
	done
	echo ""
	if [ "$a" == "y" ]; then
		insserv /etc/init.d/$BS
		echo "Now boinc is installed as a service. You can start the client as root"
		echo "through </etc/init.d/$BS start>"
	else
		echo "You must manually add the boinc service to the boot procedure of your"
		echo "system. See 'man insserve' for information."
	fi
else
	echo "The startup scripts were not copied. You must do that manually."
	echo "Copy <$BS> at /etc/init.d/$BS"
	echo "and"
	echo "<$BC> at /etc/sysconfig/$BC"
	echo "<$BC> is the config file for your boinc service."
fi

echo ""
echo ""
echo ""
if [ $client==1 ]; then
	echo "The Boinc core client is installed."
else
	echo "No boinc client was installed."
	echo "For a manual install copy your favorite client into /usr/local/$USER"
	echo "enter the install directory: cd /usr/local/$USER"
	echo "If not already done set the executable-bit: chmod u=xr <boinclient>"
	echo "set the owner and group: chown $USER:$GROUP <boincclient>"
	echo "su $USER"
	echo "Execute <boincclient>"
	echo "check the properties e.g. through: ls -l /usr/local/$USER/BOINC"
	echo "correct them if necessary: chown -R $USER:$GROUP BOINC"
	echo "Always DOUBBLECHECK that you are in the right directories, because"
	echo "-R stands for 'recursive' and can do real harm to your system!"
fi
echo ""
echo ""
echo "Have fun doing distributed computing for the sake of mankind!"
echo ""

You can copy and paste the sources in a texteditor like KWrite and save the files in a temorary directory that is otherwise emty.

boinc_install.sh has to be made executable: chmod u=rwx ./boinc_install.sh

Before you run the script as root(!), you might want to get your favorite BOINC client and save the file in the same directory as the other 3 files. If you are happy with the default settings you can go right away running ./boinc_install.sh.

The core client software will be installed in /usr/local/boinc/BOINC.

You can start the manager like /usr/local/boinc/BOINC/run_manager.


You already have installed the Client and only want to install the service?

Do the following as root:

chown root:root ./boinc ./BOINC

Edit ./BOINC to set the right user, means the line "BOINC_USER = boinc" should be changed to the owner of your installed boinc client software.

Alternatively cou can keep the line and change the owner of the client software to boinc(after adding a user named boinc)

Next you make the startup script executable:

chmod u=rwx ./boinc

Copy the file boinc to /etc/init.d/:

cp ./boinc /etc/init.d/boinc

Copy BOINC to /etc/sysconfig

cp ./BOINC /etc/sysconfig/BOINC

Install boinc as a service:

cd /etc/init.d

insserv ./boinc

Next time your computer is started it will automaticaly start the boinc client.

DONE.

If boinc is not running already, you can start the service through: /etc/init.d/boinc start

/etc/init.d/boinc without a parameter will show you the possible options.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.