~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/dist/util/install_modules/inst_berkeley.sh

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
#
 
3
# SGE configuration script (Installation/Uninstallation/Upgrade/Downgrade)
 
4
# Scriptname: inst_berkeley.sh
 
5
# Module: berkeley db install functions
 
6
#
 
7
#___INFO__MARK_BEGIN__
 
8
##########################################################################
 
9
#
 
10
#  The Contents of this file are made available subject to the terms of
 
11
#  the Sun Industry Standards Source License Version 1.2
 
12
#
 
13
#  Sun Microsystems Inc., March, 2001
 
14
#
 
15
#
 
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
 
22
#
 
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.
 
29
#
 
30
#  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
31
#
 
32
#  Copyright: 2001 by Sun Microsystems, Inc.
 
33
#
 
34
#  All Rights Reserved.
 
35
#
 
36
##########################################################################
 
37
#___INFO__MARK_END__
 
38
 
 
39
 
 
40
SpoolingQueryChange()
 
41
{
 
42
   if [ -z "$1" ]; then
 
43
      SPOOLING_DIR="`dirname $QMDIR`"/spooldb
 
44
   else
 
45
      SPOOLING_DIR="$1"
 
46
   fi
 
47
        
 
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 }'`
 
51
   else
 
52
      if [ "$IGNORE_FQDN_DEFAULT" != "true" -a "$IGNORE_FQDN_DEFAULT" != "false" ]; then
 
53
         SelectHostNameResolving
 
54
      fi
 
55
      ignore_fqdn=$IGNORE_FQDN_DEFAULT
 
56
      default_domain=$CFG_DEFAULT_DOMAIN
 
57
   fi
 
58
 
 
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`
 
69
 
 
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`
 
73
   else
 
74
     $INFOTEXT -u "\nBerkeley Database spooling parameters"
 
75
 
 
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`
 
84
     else
 
85
        SPOOLING_SERVER=none
 
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"`
 
89
     fi
 
90
 
 
91
     if [ "$AUTO" = "true" ]; then
 
92
        SPOOLING_DIR=$DB_SPOOLING_DIR
 
93
     fi
 
94
 
 
95
   fi
 
96
}
 
97
 
 
98
SpoolingCheckParams()
 
99
{
 
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
 
103
      ret=$?
 
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
 
110
         MoveLog
 
111
         exit 1
 
112
      fi
 
113
         return 0
 
114
      else
 
115
         return 1
 
116
      fi
 
117
   else
 
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]"`
 
122
            HOST=$tmp_host
 
123
            SPOOLING_SERVER=$tmp_spooling
 
124
         else
 
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
 
131
               else
 
132
                  HOST=$tmp_host
 
133
               fi
 
134
 
 
135
               hasdot=`echo $tmp_spooling|grep '\.'`
 
136
               if [ "$hasdot" = "" ]; then
 
137
                  SPOOLING_SERVER=$tmp_spooling.$default_domain
 
138
               else
 
139
                  SPOOLING_SERVER=$tmp_spooling
 
140
               fi
 
141
            else
 
142
               HOST=$tmp_host
 
143
               SPOOLING_SERVER=$tmp_spooling
 
144
            fi 
 
145
         fi
 
146
 
 
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
 
151
 
 
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!"
 
157
         else
 
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
 
160
            MoveLog
 
161
            exit 1 
 
162
         fi
 
163
      fi 
 
164
   return 1
 
165
   fi
 
166
}
 
167
 
 
168
PrepareRPCServerStart()
 
169
{
 
170
            $INFOTEXT -log "Starting rpc server on host %s!" $SPOOLING_SERVER
 
171
            $INFOTEXT "Starting rpc server on host %s!" $SPOOLING_SERVER
 
172
            ExecuteRPCServerScript start
 
173
            sleep 5
 
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!"
 
178
 
 
179
            $INFOTEXT "The Berkeley DB installation is completed now!"
 
180
            $INFOTEXT -log "The Berkeley DB installation is completed now!"
 
181
}
 
182
 
 
183
CreateRPCServerScript()
 
184
{
 
185
   pid=$$
 
186
   TMP_DIR=/tmp/$pid
 
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
 
199
}
 
200
 
 
201
 
 
202
CheckLocalFilesystem()
 
203
{
 
204
   is_done="false"
 
205
   FS=$1
 
206
 
 
207
   while [ $is_done = "false" ]; do  
 
208
      FS=`dirname $FS`
 
209
      if [ -d $FS ]; then
 
210
         is_done="true"
 
211
      fi
 
212
   done
 
213
 
 
214
   if [ `$SGE_UTILBIN/fstype $FS` = "nfs4" ]; then
 
215
      return 1
 
216
   elif [ `$SGE_UTILBIN/fstype $FS | grep "nfs" | wc -l` -gt 0 ]; then
 
217
      return 0
 
218
   else
 
219
      return 1
 
220
   fi
 
221
 
 
222
}
 
223
 
 
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()
 
228
{
 
229
   if [ "$SGE_ENABLE_SMF" = "true" ]; then
 
230
      if [ "$1" = "stop" ]; then
 
231
         action=disable
 
232
      else
 
233
         action=enable
 
234
      fi
 
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
 
242
            MoveLog
 
243
         fi
 
244
         exit 1
 
245
      fi
 
246
   else
 
247
      ExecuteAsAdmin $SGE_ROOT/$SGE_CELL/common/sgebdb $1
 
248
   fi
 
249
}
 
250
 
 
251
DeleteSpoolingDir()
 
252
{
 
253
   QMDIR="$SGE_ROOT/$SGE_CELL/qmaster"
 
254
   SpoolingQueryChange  
 
255
 
 
256
   ExecuteAsAdmin rm -fr $SPOOLING_DIR
 
257
   
 
258
}
 
259
 
 
260
EditStartupScript()
 
261
{
 
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
 
265
 
 
266
 
 
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
 
270
 
 
271
 
 
272
}
 
273