3
# SGE configuration script (Installation/Uninstallation/Upgrade/Downgrade)
4
# Scriptname: inst_berkeley.sh
5
# Module: berkeley db install functions
8
##########################################################################
10
# The Contents of this file are made available subject to the terms of
11
# the Sun Industry Standards Source License Version 1.2
13
# Sun Microsystems Inc., March, 2001
16
# Sun Industry Standards Source License Version 1.2
17
# =================================================
18
# The contents of this file are subject to the Sun Industry Standards
19
# Source License Version 1.2 (the "License"); You may not use this file
20
# except in compliance with the License. You may obtain a copy of the
21
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
23
# Software provided under this License is provided on an "AS IS" basis,
24
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
25
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
26
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
27
# See the License for the specific provisions governing your rights and
28
# obligations concerning the Software.
30
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
32
# Copyright: 2001 by Sun Microsystems, Inc.
34
# All Rights Reserved.
36
##########################################################################
43
SPOOLING_DIR="`dirname $QMDIR`"/spooldb
48
if [ -f "$SGE_ROOT/$SGE_CELL/common/bootstrap" ]; then
49
ignore_fqdn=`cat $SGE_ROOT/$SGE_CELL/common/bootstrap | grep "ignore_fqdn" | awk '{ print $2 }'`
50
default_domain=`cat $SGE_ROOT/$SGE_CELL/common/bootstrap | grep "default_domain" | awk '{ print $2 }'`
52
if [ "$IGNORE_FQDN_DEFAULT" != "true" -a "$IGNORE_FQDN_DEFAULT" != "false" ]; then
53
SelectHostNameResolving
55
ignore_fqdn=$IGNORE_FQDN_DEFAULT
56
default_domain=$CFG_DEFAULT_DOMAIN
59
if [ "$BERKELEY" = "install" ]; then
60
$INFOTEXT -u "\nBerkeley Database spooling parameters"
61
$INFOTEXT "\nYou are going to install a RPC Client/Server mechanism!" \
62
"\nIn this case, qmaster will" \
63
"\ncontact a RPC server running on a separate server machine." \
64
"\nIf you want to use the SGE shadowd, you have to use the " \
65
"\nRPC Client/Server mechanism.\n"
66
SPOOLING_SERVER=`$SGE_UTILBIN/gethostname -aname`
67
$INFOTEXT -n "\nEnter database server name or \nhit <RETURN> to use default [%s] >> " $SPOOLING_SERVER
68
SPOOLING_SERVER=`Enter $SPOOLING_SERVER`
70
$INFOTEXT -n "\nEnter the database directory\n" \
71
"or hit <RETURN> to use default [%s] >> " "$SGE_ROOT/$SGE_CELL/$SPOOLING_DIR"
72
SPOOLING_DIR=`Enter $SGE_ROOT/$SGE_CELL/$SPOOLING_DIR`
74
$INFOTEXT -u "\nBerkeley Database spooling parameters"
76
if [ "$is_server" = "true" ]; then
77
#TODO: Does not work is_server is not set
78
$INFOTEXT -n "\nPlease enter the name of your Berkeley DB Spooling Server! >> "
79
SPOOLING_SERVER=`Enter $SPOOLING_SERVER`
80
$INFOTEXT -n "Please enter the Database Directory now!\n"
81
$INFOTEXT -n "Default: [%s] >> " "$SGE_ROOT/$SGE_CELL/spooldb"
82
SPOOLING_DIR="$SGE_ROOT/$SGE_CELL/spooldb"
83
SPOOLING_DIR=`Enter $SPOOLING_DIR`
86
$INFOTEXT -n "\nPlease enter the Database Directory now, even if you want to spool locally,\n" \
87
"it is necessary to enter this Database Directory. \n\nDefault: [%s] >> " "$SPOOLING_DIR"
88
SPOOLING_DIR=`Enter "$SPOOLING_DIR"`
91
if [ "$AUTO" = "true" ]; then
92
SPOOLING_DIR=$DB_SPOOLING_DIR
100
# if we use local spooling, check if the database directory is on local fs
101
if [ "$SPOOLING_SERVER" = "none" ]; then
102
CheckLocalFilesystem $SPOOLING_DIR
104
if [ $ret -eq 0 ]; then
105
$INFOTEXT -e "\nThe database directory >%s<\n" \
106
"is not on a local filesystem.\nPlease choose a local filesystem or configure the RPC Client/Server mechanism" $SPOOLING_DIR
107
if [ "$AUTO" = "true" ]; then
108
$INFOTEXT -log "\nThe database directory >%s<\n" \
109
"is not on a local filesystem.\nPlease choose a local filesystem or configure the RPC Client/Server mechanism" $SPOOLING_DIR
118
if [ "$BERKELEY" = "install" ]; then
119
if [ "$ignore_fqdn" = "true" ]; then
120
tmp_host=`echo $HOST | cut -d. -f1 | tr "[A-Z]" "[a-z]"`
121
tmp_spooling=`echo $SPOOLING_SERVER | cut -d. -f1 | tr "[A-Z]" "[a-z]"`
123
SPOOLING_SERVER=$tmp_spooling
125
tmp_host=`echo $HOST | tr "[A-Z]" "[a-z]"`
126
tmp_spooling=`echo $SPOOLING_SERVER | tr "[A-Z]" "[a-z]"`
127
if [ "$default_domain" != "none" ]; then
128
hasdot=`echo $tmp_host|grep '\.'`
129
if [ "$hasdot" = "" ]; then
130
HOST=$tmp_host.$default_domain
135
hasdot=`echo $tmp_spooling|grep '\.'`
136
if [ "$hasdot" = "" ]; then
137
SPOOLING_SERVER=$tmp_spooling.$default_domain
139
SPOOLING_SERVER=$tmp_spooling
143
SPOOLING_SERVER=$tmp_spooling
147
if [ "$SPOOLING_SERVER" = "$HOST" ]; then
148
# TODO: we should check if the hostname can be resolved
149
# create a script to start the rpc server
150
Makedir $SPOOLING_DIR
152
# Deactivated the copy of DB_CONFIG file. The DB_CONFIG file is still distributed
153
#DB_CONFIG_COPY="cp ./util/install_modules/DB_CONFIG $SPOOLING_DIR/DB_CONFIG"
154
#ExecuteAsAdmin $DB_CONFIG_COPY
155
CreateRPCServerScript
156
$INFOTEXT -wait -auto $AUTO -n "Please remember these values, during Qmaster installation\n you will be asked for! Hit <RETURN> to continue!"
158
$INFOTEXT "Please start the Berkeley DB RPC Server installation locally on host %s!" $SPOOLING_SERVER
159
$INFOTEXT -log "Please start the Berkeley DB RPC Server installation locally on host %s!" $SPOOLING_SERVER
168
PrepareRPCServerStart()
170
$INFOTEXT -log "Starting rpc server on host %s!" $SPOOLING_SERVER
171
$INFOTEXT "Starting rpc server on host %s!" $SPOOLING_SERVER
172
ExecuteRPCServerScript start
174
$INFOTEXT "The Berkeley DB has been started with these parameters:\n\n"
175
$INFOTEXT "Spooling Server Name: %s" $SPOOLING_SERVER
176
$INFOTEXT "DB Spooling Directory: %s\n" $SPOOLING_DIR
177
$INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue!"
179
$INFOTEXT "The Berkeley DB installation is completed now!"
180
$INFOTEXT -log "The Berkeley DB installation is completed now!"
183
CreateRPCServerScript()
187
TMP_RC=/tmp/$pid/sgebdb
188
RPCSCRIPT=$SGE_ROOT/$COMMONDIR/sgebdb
189
ExecuteAsAdmin mkdir -p $TMP_DIR
190
ExecuteAsAdmin sed -e "s%GENROOT%${SGE_ROOT_VAL}%g" \
191
-e "s%GENCELL%${SGE_CELL_VAL}%g" \
192
-e "s%GENADMINUSER%${ADMINUSER}%g" \
193
-e "s%SPOOLING_DIR%${SPOOLING_DIR}%g" \
194
-e "/#+-#+-#+-#-/,/#-#-#-#-#-#/d" \
195
util/rctemplates/sgebdb_template > ${TMP_RC}
196
ExecuteAsAdmin cp $TMP_RC $RPCSCRIPT
197
ExecuteAsAdmin rm -fR $TMP_DIR
198
ExecuteAsAdmin $CHMOD a+x $RPCSCRIPT
202
CheckLocalFilesystem()
207
while [ $is_done = "false" ]; do
214
if [ `$SGE_UTILBIN/fstype $FS` = "nfs4" ]; then
216
elif [ `$SGE_UTILBIN/fstype $FS | grep "nfs" | wc -l` -gt 0 ]; then
224
# Executes the RPC Startup Script
225
# $1 is start or stop
226
# The Script is either executed on the local host and not on a remote host
227
ExecuteRPCServerScript()
229
if [ "$SGE_ENABLE_SMF" = "true" ]; then
230
if [ "$1" = "stop" ]; then
235
$SVCADM $action -s "svc:/application/sge/bdb:$SGE_CLUSTER_NAME"
236
if [ $? -ne 0 ]; then
237
$INFOTEXT "\nFailed to %s Berkeley DB RPC Server over SMF. Check service by issuing "\
238
"svcs -l svc:/application/sge/bdb:%s" $1 $SGE_CLUSTER_NAME
239
$INFOTEXT -log "\nFailed to %s Berkeley DB RPC Server over SMF. Check service by issuing "\
240
"svcs -l svc:/application/sge/bdb:%s" $1 $SGE_CLUSTER_NAME
241
if [ $AUTO = true ]; then
247
ExecuteAsAdmin $SGE_ROOT/$SGE_CELL/common/sgebdb $1
253
QMDIR="$SGE_ROOT/$SGE_CELL/qmaster"
256
ExecuteAsAdmin rm -fr $SPOOLING_DIR
262
TMP_BDBHOME=`cat $TMP_STARTUP_SCRIPT | grep "^[ \t]*BDBHOMES" | cut -d"=" -f2 | sed s/\"//g | cut -d" " -f2`
263
BDBHOME=$SPOOLING_DIR
264
BDBHOMES=" -h "$TMP_BDBHOME" -h "$BDBHOME
267
cat $TMP_STARTUP_SCRIPT | sed -e s?\"$TMP_BDBHOME\"?\"$BDBHOMES\"?g > $TMP_STARTUP_SCRIPT.0
268
`cp $TMP_STARTUP_SCRIPT.0 $TMP_STARTUP_SCRIPT`
269
rm $TMP_STARTUP_SCRIPT.0