2006-04-08 01:00:15 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2009-02-21 02:42:50 +00:00
|
|
|
# This file is part of BOINC.
|
2006-04-08 01:00:15 +00:00
|
|
|
# http://boinc.berkeley.edu
|
2009-02-21 02:42:50 +00:00
|
|
|
# Copyright (C) 2008 University of California
|
2006-04-08 01:00:15 +00:00
|
|
|
#
|
2009-02-21 02:42:50 +00:00
|
|
|
# BOINC 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 3 of the License, or (at your option) any later version.
|
2006-04-08 01:00:15 +00:00
|
|
|
#
|
2009-02-21 02:42:50 +00:00
|
|
|
# BOINC is distributed in the hope that it will be useful,
|
2006-04-08 01:00:15 +00:00
|
|
|
# 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.
|
|
|
|
#
|
2009-02-21 02:42:50 +00:00
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
# along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-10-09 11:35:47 +00:00
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-04-08 01:00:15 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
##
|
|
|
|
# Script to set up Macintosh to run BOINC client as a daemon / service
|
2023-05-05 18:05:20 +00:00
|
|
|
# by Charlie Fenton 7/26/06
|
2008-01-08 07:52:35 +00:00
|
|
|
# revised 1/6/08 to use launchd
|
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## Note: this version of this script requires BOINC 5.10.34 or later
|
|
|
|
## and OS 10.4 or later.
|
2006-04-08 01:00:15 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
## Usage:
|
2006-07-27 01:25:39 +00:00
|
|
|
##
|
2008-01-08 07:52:35 +00:00
|
|
|
## source Make_BOINC_Service.sh [path_to_client_dir] [path_to_data_dir]
|
2006-07-27 01:25:39 +00:00
|
|
|
##
|
2006-07-27 01:35:31 +00:00
|
|
|
## path_to_client_dir is needed only for stand-alone client or if Manager
|
|
|
|
## is at non-standard location.
|
2006-07-27 01:25:39 +00:00
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## path_to_data_dir is needed only for stand-alone client when data is in
|
2006-07-27 01:35:31 +00:00
|
|
|
## a different directory than the client.
|
2006-07-27 01:25:39 +00:00
|
|
|
##
|
|
|
|
## Directions for use:
|
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## (1) Install BOINC Manager using the BOINC.pkg Installer Package, or
|
|
|
|
## install stand-alone client.
|
|
|
|
## (2) Make sure you are logged in as a user with administrator
|
2006-04-08 01:00:15 +00:00
|
|
|
## privileges.
|
|
|
|
## (3) Run the Terminal application.
|
|
|
|
## (4) In the Terminal window, type "source" and a space.
|
|
|
|
## (5) Drag this script file from the Finder into the Terminal window.
|
2006-07-27 01:25:39 +00:00
|
|
|
## (6) If using the stand-alone client, or if the Manager is in a non-
|
2023-05-05 18:05:20 +00:00
|
|
|
## standard location, drag the folder containing the client from
|
|
|
|
## the Finder into the Terminal window (or type the path excluding
|
2006-07-27 01:35:31 +00:00
|
|
|
## the trailing slash).
|
2023-05-05 18:05:20 +00:00
|
|
|
## (7) If using the stand-alone client, but the client is not in the data
|
|
|
|
## directory, drag the BOINC data folder from the Finder into the
|
2008-01-08 07:52:35 +00:00
|
|
|
## Terminal window (or type the path excluding the trailing slash).
|
2006-07-27 01:37:09 +00:00
|
|
|
## (8) Press the return key.
|
|
|
|
## (9) When prompted, enter your administrator password.
|
|
|
|
## (10) Restart the computer.
|
2006-04-08 01:00:15 +00:00
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## The system will now start BOINC client as a daemon / service at
|
|
|
|
## system startup. You will still be able to control and monitor BOINC
|
|
|
|
## using the BOINC Manager, but BOINC client will remain running after
|
|
|
|
## you quit BOINC Manager, when the ScreenSaver quits, and even when
|
2006-04-08 01:00:15 +00:00
|
|
|
## no user is logged in.
|
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## Note: the BOINC ScreenSaver may not display graphics for some users
|
|
|
|
## when BOINC Client is running as a daemon / service. Thus will be
|
2008-01-08 07:52:35 +00:00
|
|
|
## fixed with the release of BOINC 6.0 and project applications updated
|
|
|
|
## to use the BOINC 6 graphics API.
|
2006-04-08 01:00:15 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## When the system has launched BOINC Client as a daemon, you can stop the
|
2008-01-08 07:52:35 +00:00
|
|
|
## BOINC Client from the Terminal by typing:
|
|
|
|
## sudo launchctl stop edu.berkeley.boinc
|
|
|
|
## and you can restart the BOINC Client from the Terminal by typing:
|
|
|
|
## sudo launchctl start edu.berkeley.boinc
|
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## Note: The BOINC Client will quit immediately after launch if it detects
|
|
|
|
## another instance of BOINC Client already running. So these launchctl
|
|
|
|
## commands will fail if the BOINC Client was started by the BOINC Manager
|
2008-01-08 07:52:35 +00:00
|
|
|
## or ScreenSaver.
|
2006-04-08 01:00:15 +00:00
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## If BOINC Client is not already running when the BOINC Manager is launched,
|
|
|
|
## the Manager will start BOINC Client. This will happen automatically at
|
|
|
|
## login if you have BOINC Manager set as a login item for that user. If
|
|
|
|
## it was started by the Manager, then BOINC Client will quit when the BOINC
|
2008-01-08 07:52:35 +00:00
|
|
|
## Manager quits.
|
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## If BOINC Client is not already running when the BOINC ScreenSaver starts,
|
|
|
|
## the ScreenSaver will start BOINC Client and will quit BOINC Client when
|
2008-01-08 07:52:35 +00:00
|
|
|
## the ScreenSaver is dismissed.
|
|
|
|
##
|
|
|
|
|
|
|
|
## REMOVAL:
|
2023-05-05 18:05:20 +00:00
|
|
|
## To undo the effects of this script (i.e., to permanently stop running BOINC
|
2008-01-08 07:52:35 +00:00
|
|
|
## as a daemon / service):
|
|
|
|
## (1) In the Finder, browse to the /Library/LaunchDaemons folder.
|
2023-05-05 18:05:20 +00:00
|
|
|
## (2) Drag the file edu.berkeley.boinc.plist to the trash. (Finder will ask
|
2008-01-08 07:52:35 +00:00
|
|
|
## for your administrator user name and password).
|
|
|
|
## (3) Restart the computer.
|
2006-04-08 01:00:15 +00:00
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## The system will no longer start BOINC client as a daemon / service
|
|
|
|
## at system startup.
|
2006-04-08 01:00:15 +00:00
|
|
|
##
|
2023-05-05 18:05:20 +00:00
|
|
|
## If you wish to completely remove BOINC from your computer, first
|
|
|
|
## complete the above steps, then follow the directions in the web
|
|
|
|
## page http://boinc.berkeley.edu/mac_advanced.php or in the README.rtf
|
|
|
|
## file supplied with the BOINC installer.
|
2006-04-08 01:00:15 +00:00
|
|
|
##
|
|
|
|
|
2006-07-27 01:25:39 +00:00
|
|
|
if [ $# -eq 0 ] ; then
|
2008-01-08 07:52:35 +00:00
|
|
|
PATH_TO_CLIENT="/Applications/BOINCManager.app/Contents/Resources"
|
|
|
|
PATH_TO_DATA="/Library/Application Support/BOINC Data"
|
2006-07-27 01:25:39 +00:00
|
|
|
# Check for BOINC Manager with embedded BOINC Client
|
2008-01-08 07:52:35 +00:00
|
|
|
if [ ! -f "${PATH_TO_CLIENT}/boinc" ]; then
|
2006-07-27 01:25:39 +00:00
|
|
|
echo " ***************************** ERROR ***************************"
|
|
|
|
echo " * *"
|
|
|
|
echo " * Could not find BOINC Manager with embedded BOINC client *"
|
|
|
|
echo " * in Applications Directory. *"
|
|
|
|
echo " * *"
|
|
|
|
echo " * Please install BOINC Manager before running this script. *"
|
|
|
|
echo " * *"
|
|
|
|
echo " ***************************************************************"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
PATH_TO_CLIENT="$1"
|
|
|
|
PATH_TO_DATA="$1"
|
|
|
|
# Check for stand-alone BOINC Client
|
2008-01-08 07:52:35 +00:00
|
|
|
if [ ! -f "${PATH_TO_CLIENT}/boinc" ]; then
|
2006-07-27 01:25:39 +00:00
|
|
|
echo " ***************************** ERROR ***************************"
|
|
|
|
echo " * *"
|
|
|
|
echo " * Could not find BOINC client at specified directory *"
|
|
|
|
echo " * *"
|
|
|
|
echo " * Please install BOINC client before running this script. *"
|
|
|
|
echo " * *"
|
|
|
|
echo " ***************************************************************"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $# -gt 1 ] ; then
|
|
|
|
PATH_TO_DATA="$2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check for BOINC Data directory
|
|
|
|
if [ ! -d "${PATH_TO_DATA}" ]; then
|
|
|
|
echo " ****************** ERROR ******************"
|
|
|
|
echo " * *"
|
|
|
|
echo " * Could not find BOINC data directory *"
|
|
|
|
echo " * *"
|
|
|
|
echo " *******************************************"
|
|
|
|
return 1
|
2006-04-08 01:00:15 +00:00
|
|
|
fi
|
|
|
|
|
2008-01-08 07:52:35 +00:00
|
|
|
# Delete the old-style boinc daemon StartupItem if present
|
|
|
|
sudo rm -fR /Library/StartupItems/boinc
|
2006-04-08 01:00:15 +00:00
|
|
|
|
|
|
|
# Delete old temporary working directory and files if present
|
2008-01-08 07:52:35 +00:00
|
|
|
rm -fR ~/boincStartupTemp
|
2006-04-08 01:00:15 +00:00
|
|
|
# Create new temporary working directory
|
|
|
|
mkdir -p ~/boincStartupTemp/
|
|
|
|
|
2008-01-08 07:52:35 +00:00
|
|
|
# Create file edu.berkeley.boinc.plist in temporary directory.
|
2023-05-05 18:05:20 +00:00
|
|
|
# (For some reason, we can't create the file directly in the final
|
2008-01-08 07:52:35 +00:00
|
|
|
# destination directory, so we create it here and then move it.)
|
|
|
|
cat >> ~/boincStartupTemp/edu.berkeley.boinc.plist << ENDOFFILE
|
|
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
|
|
<plist version="1.0">
|
|
|
|
<dict>
|
|
|
|
<key>GroupName</key>
|
|
|
|
<string>boinc_master</string>
|
|
|
|
<key>Label</key>
|
|
|
|
<string>edu.berkeley.boinc</string>
|
|
|
|
<key>Program</key>
|
|
|
|
<string>${PATH_TO_CLIENT}/boinc</string>
|
|
|
|
<key>ProgramArguments</key>
|
|
|
|
<array>
|
|
|
|
<string>${PATH_TO_CLIENT}/boinc</string>
|
|
|
|
<string>-redirectio</string>
|
|
|
|
<string>-daemon</string>
|
|
|
|
</array>
|
|
|
|
<key>RunAtLoad</key>
|
|
|
|
<true/>
|
|
|
|
<key>UserName</key>
|
|
|
|
<string>boinc_master</string>
|
|
|
|
<key>WorkingDirectory</key>
|
|
|
|
<string>${PATH_TO_DATA}/</string>
|
|
|
|
</dict>
|
|
|
|
</plist>
|
2006-04-08 01:00:15 +00:00
|
|
|
ENDOFFILE
|
|
|
|
|
2008-01-08 07:52:35 +00:00
|
|
|
sudo mv -f ~/boincStartupTemp/edu.berkeley.boinc.plist /Library/LaunchDaemons/
|
2006-04-08 01:00:15 +00:00
|
|
|
|
|
|
|
# Delete temporary working directory
|
2008-01-08 07:52:35 +00:00
|
|
|
rm -fR ~/boincStartupTemp
|
2006-04-08 01:00:15 +00:00
|
|
|
|
2008-01-08 07:52:35 +00:00
|
|
|
# Set ownership and permissions for our plist
|
|
|
|
sudo chown root:wheel /Library/LaunchDaemons/edu.berkeley.boinc.plist
|
|
|
|
sudo chmod 0444 /Library/LaunchDaemons/edu.berkeley.boinc.plist
|
2006-04-08 01:00:15 +00:00
|
|
|
|
|
|
|
return 0
|