1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
|
#!/bin/sh
#
# Simple SGE cluster creation script.
# Mainly used from gridengine-master postinst
#
# Copyright (C) 2008 Mark Hymers <mhy@debian.org>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the University nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
set -e
if [ $# -ne 4 ]; then
echo "Usage: init_cluster <SGE_ROOT> <SGE_CELL> <spooldir> <manageruser>"
exit 1
fi
export SGE_ROOT=$1
export SGE_CELL=$2
spooldir=$3
manager=$4
baseconf=/usr/share/gridengine/default-configuration
basecomplex=/usr/share/gridengine/util/resources/centry
baseuserset=/usr/share/gridengine/util/resources/usersets
if [ -e ${spooldir}/sge ]; then
echo "${spooldir}/sge already exists: skipping cluster initialization"
exit 0
fi
echo "Initializing cluster with the following parameters:"
echo " => SGE_ROOT: $SGE_ROOT"
echo " => SGE_CELL: $SGE_CELL"
echo " => Spool directory: $spooldir"
echo " => Initial manager user: $manager"
# Initialise the spool
echo "Initializing spool ($spooldir)"
/usr/lib/gridengine/spoolinit berkeleydb libspoolb ${spooldir} init
# Initialize global configuration
echo "Initializing global configuration based on ${baseconf}"
/usr/lib/gridengine/spooldefaults configuration ${baseconf}
# Initialize complexes:
echo "Initializing complexes based on ${basecomplex}"
/usr/lib/gridengine/spooldefaults complexes ${basecomplex}
# Initialize default usersets:
echo "Initializing usersets based on ${baseuserset}"
/usr/lib/gridengine/spooldefaults usersets ${baseuserset}
# Add $manageruser as a manager
echo "Adding user ${manager} as a manager"
/usr/lib/gridengine/spooldefaults managers ${manager}
cat >$SGE_ROOT/$SGE_CELL/common/settings.sh <<EOF
SGE_ROOT=$SGE_ROOT; export SGE_ROOT
SGE_CELL=$SGE_CELL; export SGE_CELL
SGE_ARCH=`$SGE_ROOT/util/arch`; export SGE_ARCH
EOF
cat >$SGE_ROOT/$SGE_CELL/common/settings.csh <<EOF
setenv SGE_ROOT $SGE_ROOT
setenv SGE_CELL $SGE_CELL
setenv SGE_ARCH `$SGE_ROOT/util/arch`
EOF
cat > $SGE_ROOT/$SGE_CELL/common/sge.module <<EOF
#%Module1.0 -*-tcl-*-
proc ModulesHelp { } {
puts stderr "\tSets up the Grid Engine batch system"
}
module-whatis "Grid Engine batch system"
set sge_root "$SGE_ROOT"
set sge_cell "$SGE_CELL"
set sge_arch "`$SGE_ROOT/util/arch`"
setenv SGE_ROOT "\$sge_root"
setenv SGE_CELL "\$sge_cell"
setenv SGE_CLUSTER_NAME "`cat $SGE_ROOT/$SGE_CELL/common/cluster_name 2>/dev/null`"
prepend-path PATH "$sge_root/bin/$sge_arch"
prepend-path PATH "$sge_root/bin"
prepend-path MANPATH "$sge_root/man:`$SGE_ROOT/util/arch -m`"
EOF
echo "Cluster creation complete"
exit 0
|