2006-07-18 20:39:05 +00:00
|
|
|
#! /bin/sh
|
|
|
|
|
2006-07-26 11:40:38 +00:00
|
|
|
# Berkeley Open Infrastructure for Network Computing
|
|
|
|
# http://boinc.berkeley.edu
|
|
|
|
# Copyright (C) 2006 University of California
|
|
|
|
#
|
|
|
|
# This 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 software 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.
|
|
|
|
#
|
|
|
|
# To view the GNU Lesser General Public License visit
|
|
|
|
# http://www.gnu.org/copyleft/lesser.html
|
|
|
|
# or write to the Free Software Foundation, Inc.,
|
|
|
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
2006-07-18 20:39:05 +00:00
|
|
|
# Make a BOINC installation "secure"
|
2006-07-25 17:39:54 +00:00
|
|
|
# Create groups and users, set file/dir ownership and protection
|
2006-07-18 20:39:05 +00:00
|
|
|
#
|
|
|
|
# Execute this as root in the BOINC directory
|
2006-07-25 17:39:54 +00:00
|
|
|
# You must have already run the installer script
|
|
|
|
# that creates the switcher/ and locale/ directories, and their contents
|
|
|
|
|
|
|
|
# In addition, you should add boinc_master and boinc_projects
|
|
|
|
# to the supplementary group list of users who will administer BOINC.
|
|
|
|
# e.g.:
|
|
|
|
# usermod -G boinc_master,boinc_projects -a mary
|
2006-07-18 20:39:05 +00:00
|
|
|
|
2006-09-01 21:48:48 +00:00
|
|
|
make_boinc_users() {
|
2006-07-18 20:39:05 +00:00
|
|
|
groupadd boinc_master
|
|
|
|
groupadd boinc_projects
|
|
|
|
useradd boinc_master -g boinc_master
|
|
|
|
useradd boinc_projects -g boinc_projects
|
|
|
|
}
|
|
|
|
|
2006-09-01 21:48:48 +00:00
|
|
|
check_login() {
|
2006-07-18 20:39:05 +00:00
|
|
|
if [ `whoami` != 'root' ]
|
|
|
|
then
|
|
|
|
echo 'This script must be run as root'
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# set_perm path user group perm
|
|
|
|
# set a file or directory to the given ownership/permissions
|
2006-09-01 21:48:48 +00:00
|
|
|
set_perm() {
|
2006-07-26 11:40:38 +00:00
|
|
|
chown $2:$3 "$1"
|
|
|
|
chmod $4 "$1"
|
2006-07-18 20:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# same, but apply to all subdirs and files
|
|
|
|
#
|
2006-09-01 21:48:48 +00:00
|
|
|
set_perm_recursive() {
|
2006-07-26 11:40:38 +00:00
|
|
|
chown -R $2:$3 "$1"
|
|
|
|
chmod -R $4 "$1"
|
2006-07-18 20:39:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# same, but apply to items in the given dir
|
|
|
|
#
|
2006-09-01 21:48:48 +00:00
|
|
|
set_perm_dir() {
|
2006-07-26 11:40:38 +00:00
|
|
|
for file in $(ls "$1")
|
|
|
|
do
|
|
|
|
path="$1/${file}"
|
|
|
|
set_perm "${path}" $2 $3 $4
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2006-09-01 21:48:48 +00:00
|
|
|
update_nested_dirs() {
|
2006-07-26 11:40:38 +00:00
|
|
|
chmod u+x,g+x,o+x "${1}"
|
|
|
|
|
|
|
|
for file in $(ls "$1")
|
2006-07-18 20:39:05 +00:00
|
|
|
do
|
2006-07-26 11:40:38 +00:00
|
|
|
if [ -d "${1}/${file}" ] ; then
|
|
|
|
update_nested_dirs "${1}/${file}"
|
|
|
|
fi
|
2006-07-18 20:39:05 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
check_login
|
|
|
|
|
2006-07-26 13:39:59 +00:00
|
|
|
# If the user forgets to cd to the boinc data directory, this script can do serious damage
|
|
|
|
# so show the directory we are about to modify
|
|
|
|
echo "Changing directory $(pwd) file ownership to user and group boinc_master - OK? (y/n)"
|
2006-07-18 20:39:05 +00:00
|
|
|
read line
|
|
|
|
if [ "$line" != "y" ]
|
|
|
|
then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2006-07-26 13:39:59 +00:00
|
|
|
# if the booinc client is not here, assume it is the wrong directory
|
|
|
|
if [ ! -f "boinc_client" ]
|
|
|
|
then
|
|
|
|
echo "Can't find boinc_client in directory $(pwd); exiting"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2006-07-18 20:39:05 +00:00
|
|
|
make_boinc_users
|
|
|
|
|
2006-07-25 17:39:54 +00:00
|
|
|
set_perm_recursive . boinc_master boinc_master u+rw,g+rw,o+r-w
|
|
|
|
set_perm . boinc_master boinc_master 0775
|
2006-07-25 23:52:00 +00:00
|
|
|
if [ -f gui_rpc_auth.cfg ] ; then
|
2006-07-25 17:39:54 +00:00
|
|
|
set_perm gui_rpc_auth.cfg boinc_master boinc_master 0660
|
|
|
|
fi
|
2006-07-18 20:39:05 +00:00
|
|
|
|
2006-07-25 23:52:00 +00:00
|
|
|
if [ -d projects ] ; then
|
2006-07-25 17:39:54 +00:00
|
|
|
set_perm_recursive projects boinc_master boinc_project u+rw,g+rw,o+r-w
|
|
|
|
set_perm projects boinc_master boinc_master 0775
|
2006-07-26 11:40:38 +00:00
|
|
|
update_nested_dirs projects
|
2006-07-25 17:39:54 +00:00
|
|
|
fi
|
2006-07-18 20:39:05 +00:00
|
|
|
|
2006-07-25 23:52:00 +00:00
|
|
|
if [ -d slots ] ; then
|
2006-07-25 17:39:54 +00:00
|
|
|
set_perm_recursive slots boinc_master boinc_project u+rw,g+rw,o+r-w
|
|
|
|
set_perm slots boinc_master boinc_master 0775
|
2006-07-26 11:40:38 +00:00
|
|
|
update_nested_dirs slots
|
2006-07-25 17:39:54 +00:00
|
|
|
fi
|
2006-07-18 20:39:05 +00:00
|
|
|
|
2006-07-25 17:39:54 +00:00
|
|
|
set_perm switcher/switcher boinc_project boinc_project 6551
|
2006-07-18 20:39:05 +00:00
|
|
|
set_perm switcher/setprojectgrp boinc_master boinc_project 2500
|
|
|
|
set_perm switcher boinc_master boinc_master 0550
|
|
|
|
|
2006-07-25 17:39:54 +00:00
|
|
|
set_perm_recursive locale boinc_master boinc_master u+r-w,g+r-w,o-rwx
|
2006-07-18 20:39:05 +00:00
|
|
|
|
|
|
|
set_perm boinc_client boinc_master boinc_master 6555
|
|
|
|
set_perm boinc_manager boinc_master boinc_master 2555
|