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

« back to all changes in this revision

Viewing changes to source/dist/util/install_modules/inst_qmaster.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_qmaster.sh
 
5
# Module: qmaster installation 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
#set -x
 
40
 
 
41
 
 
42
#-------------------------------------------------------------------------
 
43
# GetCellRoot
 
44
#
 
45
GetCellRoot()
 
46
{
 
47
   if [ $AUTO = true ]; then
 
48
      SGE_CELL_ROOT=$SGE_CELL_ROOT
 
49
       $INFOTEXT -log "Using >%s< as SGE_CELL_ROOT." "$SGE_CELL_ROOT"
 
50
   else
 
51
      $CLEAR
 
52
      $INFOTEXT -u "\nGrid Engine cell root"
 
53
      $INFOTEXT -n "Enter the cell root <<<"
 
54
      INP=`Enter `
 
55
      eval SGE_CELL_ROOT=$INP
 
56
      $INFOTEXT -wait -auto $AUTO -n "\nUsing cell root >%s<. Hit <RETURN> to continue >> " $SGE_CELL_ROOT
 
57
      $CLEAR
 
58
   fi
 
59
}
 
60
 
 
61
#-------------------------------------------------------------------------
 
62
# GetCell
 
63
#
 
64
GetCell()
 
65
{
 
66
   is_done="false"
 
67
 
 
68
   if [ $AUTO = true ]; then
 
69
    SGE_CELL=$CELL_NAME
 
70
    SGE_CELL_VAL=$CELL_NAME
 
71
    $INFOTEXT -log "Using >%s< as CELL_NAME." "$CELL_NAME"
 
72
 
 
73
    if [ -f $SGE_ROOT/$SGE_CELL/common/bootstrap -a "$QMASTER" = "install" ]; then
 
74
       $INFOTEXT -log "The cell name you have used and the bootstrap already exists!"
 
75
       $INFOTEXT -log "It seems that you have already a installed system."
 
76
       $INFOTEXT -log "A installation may cause, that data can be lost!"
 
77
       $INFOTEXT -log "Please, check this directory and remove it, or use any other cell name"
 
78
       $INFOTEXT -log "Exiting installation now!"
 
79
       MoveLog
 
80
       exit 1
 
81
    fi 
 
82
 
 
83
   else
 
84
   while [ $is_done = "false" ]; do 
 
85
      $CLEAR
 
86
      $INFOTEXT -u "\nGrid Engine cells"
 
87
      if [ "$SGE_CELL" = "" ]; then
 
88
         $INFOTEXT -n "\nGrid Engine supports multiple cells.\n\n" \
 
89
                      "If you are not planning to run multiple Grid Engine clusters or if you don't\n" \
 
90
                      "know yet what is a Grid Engine cell it is safe to keep the default cell name\n\n" \
 
91
                      "   default\n\n" \
 
92
                      "If you want to install multiple cells you can enter a cell name now.\n\n" \
 
93
                      "The environment variable\n\n" \
 
94
                      "   \$SGE_CELL=<your_cell_name>\n\n" \
 
95
                      "will be set for all further Grid Engine commands.\n\n" \
 
96
                      "Enter cell name [default] >> "
 
97
         INP=`Enter default`
 
98
      else
 
99
         $INFOTEXT -n "\nGrid Engine supports multiple cells.\n\n" \
 
100
                      "If you are not planning to run multiple Grid Engine clusters or if you don't\n" \
 
101
                      "know yet what is a Grid Engine cell it is safe to keep the default cell name\n\n" \
 
102
                      "   default\n\n" \
 
103
                      "If you want to install multiple cells you can enter a cell name now.\n\n" \
 
104
                      "The environment variable\n\n" \
 
105
                      "   \$SGE_CELL=<your_cell_name>\n\n" \
 
106
                      "will be set for all further Grid Engine commands.\n\n" \
 
107
                      "Enter cell name [%s] >> " $SGE_CELL
 
108
         INP=`Enter $SGE_CELL`
 
109
      fi
 
110
      eval SGE_CELL=$INP
 
111
      SGE_CELL_VAL=`eval echo $SGE_CELL`
 
112
      if [ "$QMASTER" = "install" ]; then
 
113
         if [ -d $SGE_ROOT/$SGE_CELL/common ]; then
 
114
            $CLEAR
 
115
            $INFOTEXT "\nThe \"common\" directory in cell >%s< already exists!" $SGE_CELL_VAL
 
116
            $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n "Do you want to select another cell name? (y/n) [y] >> "
 
117
            if [ $? = 0 ]; then
 
118
               is_done="false"
 
119
            else
 
120
               with_bdb=0
 
121
               if [ ! -f $SGE_ROOT/$SGE_CELL/common/bootstrap -a -f $SGE_ROOT/$SGE_CELL/common/sgebdb ]; then
 
122
                  $INFOTEXT -n "Do you want to keep this directory? Choose\n" \
 
123
                               "(YES option) - if you have installed BDB server.\n" \
 
124
                               "(NO option)  - to delete the whole directory!\n"
 
125
                  $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n "Do you want to keep [y] or delete [n] the directory? (y/n) [y] >> "
 
126
                  with_bdb=1
 
127
               else
 
128
                  $INFOTEXT -n "You can overwrite or delete this directory. If you choose overwrite\n" \
 
129
                               "(YES option) only the \"bootstrap\" and \"cluster_name\" files will be deleted).\n" \
 
130
                               "Delete (NO option) - will delete the whole directory!\n"
 
131
                  $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n "Do you want to overwrite [y] or delete [n] the directory? (y/n) [y] >> "
 
132
               fi
 
133
               sel_ret=$?
 
134
               SearchForExistingInstallations "qmaster shadowd execd dbwriter"
 
135
               if [ $sel_ret = 0 -a $with_bdb = 0 ]; then
 
136
                  $INFOTEXT "Deleting bootstrap and cluster_name files!"
 
137
                  ExecuteAsAdmin rm -f $SGE_ROOT/$SGE_CELL_VAL/common/bootstrap
 
138
                  ExecuteAsAdmin rm -f $SGE_ROOT/$SGE_CELL_VAL/common/cluster_name
 
139
               elif [ $sel_ret -ne 0 ]; then
 
140
                  $INFOTEXT "Deleting directory \"%s\" now!" $SGE_ROOT/$SGE_CELL_VAL
 
141
                  ExecuteAsAdmin rm -rf $SGE_ROOT/$SGE_CELL_VAL
 
142
               fi
 
143
               is_done="true"
 
144
            fi
 
145
         else
 
146
            is_done="true"
 
147
         fi
 
148
      elif [ "$BERKELEY" = "install" ]; then
 
149
         SearchForExistingInstallations "bdb"
 
150
         is_done="true"
 
151
      elif [ "$DBWRITER" = "install" ]; then
 
152
         SearchForExistingInstallations "dbwriter"
 
153
         is_done="true"
 
154
      else
 
155
         is_done="true"
 
156
      fi
 
157
   done
 
158
 
 
159
   $INFOTEXT -wait -auto $AUTO -n "\nUsing cell >%s<. \nHit <RETURN> to continue >> " $SGE_CELL_VAL
 
160
   $CLEAR
 
161
   fi
 
162
   export SGE_CELL
 
163
 
 
164
  HOST=`$SGE_UTILBIN/gethostname -aname`
 
165
  if [ "$HOST" = "" ]; then
 
166
     $INFOTEXT -e "can't get hostname of this machine. Installation failed."
 
167
     exit 1
 
168
  fi
 
169
}
 
170
 
 
171
 
 
172
#-------------------------------------------------------------------------
 
173
# GetQmasterSpoolDir()
 
174
#
 
175
GetQmasterSpoolDir()
 
176
{
 
177
   if [ $AUTO = true ]; then
 
178
      QMDIR=$QMASTER_SPOOL_DIR
 
179
      $INFOTEXT -log "Using >%s< as QMASTER_SPOOL_DIR." "$QMDIR"
 
180
   else
 
181
   euid=$1
 
182
 
 
183
   done=false
 
184
   while [ $done = false ]; do
 
185
      $CLEAR
 
186
      $INFOTEXT -u "\nGrid Engine qmaster spool directory"
 
187
      $INFOTEXT "\nThe qmaster spool directory is the place where the qmaster daemon stores\n" \
 
188
                "the configuration and the state of the queuing system.\n\n"
 
189
 
 
190
      if [ $euid = 0 ]; then
 
191
         if [ $ADMINUSER = default ]; then
 
192
            $INFOTEXT "User >root< on this host must have read/write access to the qmaster\n" \
 
193
                      "spool directory.\n"
 
194
         else
 
195
            $INFOTEXT "The admin user >%s< must have read/write access\n" \
 
196
                      "to the qmaster spool directory.\n" $ADMINUSER
 
197
         fi
 
198
      else
 
199
         $INFOTEXT "Your account on this host must have read/write access\n" \
 
200
                   "to the qmaster spool directory.\n"
 
201
      fi
 
202
 
 
203
      $INFOTEXT -n "If you will install shadow master hosts or if you want to be able to start\n" \
 
204
                   "the qmaster daemon on other hosts (see the corresponding section in the\n" \
 
205
                   "Grid Engine Installation and Administration Manual for details) the account\n" \
 
206
                   "on the shadow master hosts also needs read/write access to this directory.\n\n" \
 
207
                   "The following directory\n\n [%s]\n\n will be used as qmaster spool directory by default!\n" \
 
208
                   $SGE_ROOT_VAL/$SGE_CELL_VAL/spool/qmaster
 
209
                   QMDIR=$SGE_ROOT_VAL/$SGE_CELL_VAL/spool/qmaster
 
210
 
 
211
      $INFOTEXT -auto $AUTO -ask "y" "n" -def "n" -n \
 
212
                "Do you want to select another qmaster spool directory (y/n) [n] >> "
 
213
 
 
214
      if [ $? = 1 ]; then
 
215
         done=true
 
216
      else
 
217
         $INFOTEXT -n "Please enter a qmaster spool directory now! >>" 
 
218
         QMDIR=`Enter $SGE_ROOT_VAL/$SGE_CELL_VAL/spool/qmaster`
 
219
         done=true
 
220
      fi
 
221
   done
 
222
   fi
 
223
   export QMDIR
 
224
}
 
225
 
 
226
 
 
227
 
 
228
#--------------------------------------------------------------------------
 
229
# SetPermissions
 
230
#    - set permission for regular files to 644
 
231
#    - set permission for executables and directories to 755
 
232
#
 
233
SetPermissions()
 
234
{
 
235
   $CLEAR
 
236
   $INFOTEXT -u "\nVerifying and setting file permissions"
 
237
   $ECHO
 
238
 
 
239
   euid=`$SGE_UTILBIN/uidgid -euid`
 
240
 
 
241
   if [ $euid != 0 ]; then
 
242
      $INFOTEXT "You are not installing as user >root<\n"
 
243
      $INFOTEXT "Can't set the file owner/group and permissions\n"
 
244
      $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
245
      $CLEAR
 
246
      return 0
 
247
   else
 
248
      if [ "$AUTO" = "true" -a "$SET_FILE_PERMS" = "true" ]; then
 
249
         :
 
250
      else
 
251
         if [ "$WINDOWS_SUPPORT" = true ]; then
 
252
            $INFOTEXT -auto $AUTO -ask "y" "n" -def "n" -n \
 
253
                      "Did you install this version with >pkgadd< or did you already\n" \
 
254
                      "verify and set the file permissions of your distribution (enter: y)\n\n" \
 
255
                      "In some cases, eg: the binaries are stored on a NTFS or on any other\n" \
 
256
                      "filesystem, which provides additional file permissions, the UNIX file\n" \
 
257
                      "permissions can be wrong. In this case we would advise to verify and\n" \
 
258
                      "to set the file permissions (enter: n) (y/n) [n] >> "
 
259
         else
 
260
            $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n \
 
261
                      "Did you install this version with >pkgadd< or did you already\n" \
 
262
                      "verify and set the file permissions of your distribution (y/n) [y] >> "
 
263
         fi
 
264
         if [ $? = 0 ]; then
 
265
            $INFOTEXT -wait -auto $AUTO -n "We do not verify file permissions. Hit <RETURN> to continue >> "
 
266
            $CLEAR
 
267
            return 0
 
268
         fi
 
269
      fi
 
270
   fi
 
271
 
 
272
   rm -f ./tst$$ 2> /dev/null > /dev/null
 
273
   touch ./tst$$ 2> /dev/null > /dev/null
 
274
   ret=$?
 
275
   rm -f ./tst$$ 2> /dev/null > /dev/null
 
276
   if [ $ret != 0 ]; then
 
277
      $INFOTEXT -u "\nVerifying and setting file permissions (continued)"
 
278
 
 
279
      $INFOTEXT "\nWe can't set file permissions on this machine, because user root\n" \
 
280
                  "has not the necessary privileges to change file permissions\n" \
 
281
                  "on this file system.\n\n" \
 
282
                  "Probably this file system is an NFS mount where user root is\n" \
 
283
                  "mapped to user >nobody<.\n\n" \
 
284
                  "Please login now at your file server and set the file permissions and\n" \
 
285
                  "ownership of the entire distribution with the command:\n\n" \
 
286
                  "   # \$SGE_ROOT/util/setfileperm.sh \$SGE_ROOT\n\n" 
 
287
 
 
288
      $INFOTEXT -wait -auto $AUTO -n "Please hit <RETURN> to continue once you set your file permissions >> "
 
289
      $CLEAR
 
290
      return 0
 
291
   else
 
292
      $CLEAR
 
293
      $INFOTEXT -u "\nVerifying and setting file permissions"
 
294
      $INFOTEXT "\nWe may now verify and set the file permissions of your Grid Engine\n" \
 
295
                "distribution.\n\n" \
 
296
                 "This may be useful since due to unpacking and copying of your distribution\n" \
 
297
                 "your files may be unaccessible to other users.\n\n" \
 
298
                 "We will set the permissions of directories and binaries to\n\n" \
 
299
                 "   755 - that means executable are accessible for the world\n\n" \
 
300
                 "and for ordinary files to\n\n" \
 
301
                 "   644 - that means readable for the world\n\n"
 
302
 
 
303
      $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n \
 
304
               "Do you want to verify and set your file permissions (y/n) [y] >> "
 
305
      ret=$?
 
306
   fi
 
307
 
 
308
   if [ $ret = 0 ]; then
 
309
 
 
310
      if [ $RESPORT = true ]; then
 
311
         resportarg="-resport"
 
312
      else
 
313
         resportarg="-noresport"
 
314
      fi
 
315
 
 
316
      if [ $ADMINUSER = default ]; then
 
317
         fileowner=root
 
318
      else
 
319
         fileowner=$ADMINUSER
 
320
      fi
 
321
 
 
322
      filegid=`$SGE_UTILBIN/uidgid -gid`
 
323
 
 
324
      $CLEAR
 
325
 
 
326
      util/setfileperm.sh -auto $SGE_ROOT
 
327
 
 
328
      $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
329
   else
 
330
      $INFOTEXT -wait -auto $AUTO -n "We will not verify your file permissions. Hit <RETURN> to continue >>"
 
331
   fi
 
332
   $CLEAR
 
333
}
 
334
 
 
335
 
 
336
#SetSpoolingOptionsBerkeleyDB()
 
337
# $1 - new default spool_dir
 
338
#      TODO: $1 only for local bdb spooling for now
 
339
SetSpoolingOptionsBerkeleyDB()
 
340
{
 
341
   SPOOLING_METHOD=berkeleydb
 
342
   SPOOLING_LIB=libspoolb
 
343
   SPOOLING_SERVER=none
 
344
   SPOOLING_DIR="spooldb"
 
345
   MKDIR="mkdir -p"
 
346
   params_ok=0
 
347
   if [ "$AUTO" = "true" ]; then
 
348
      SPOOLING_SERVER=$DB_SPOOLING_SERVER
 
349
      SPOOLING_DIR="$DB_SPOOLING_DIR"
 
350
 
 
351
      if [ "$SPOOLING_DIR" = "" ]; then
 
352
         $INFOTEXT -log "Please enter a Berkeley DB spooling directory!"
 
353
         MoveLog
 
354
         exit 1
 
355
      fi
 
356
 
 
357
      if [ "$SPOOLING_SERVER" = "" ]; then
 
358
         $INFOTEXT -log "Please enter a Berkeley DB spooling server!"
 
359
         MoveLog
 
360
         exit 1
 
361
      fi
 
362
 
 
363
      if [ -d "$SPOOLING_DIR" -a \( "$SPOOLING_SERVER" = "none" -o "$SPOOLING_SERVER" = "" \) ]; then
 
364
         $INFOTEXT -log "The spooling directory [%s] already exists! Exiting installation!" "$SPOOLING_DIR"
 
365
         MoveLog
 
366
         exit 1 
 
367
      fi
 
368
      SpoolingCheckParams
 
369
      params_ok=$?
 
370
   fi
 
371
   if [ "$QMASTER" = "install" ]; then
 
372
      $INFOTEXT -n "\nThe Berkeley DB spooling method provides two configurations!\n\n" \
 
373
                   " Local spooling:\n" \
 
374
                   " The Berkeley DB spools into a local directory on this host (qmaster host)\n" \
 
375
                   " This setup is faster, but you can't setup a shadow master host\n\n"
 
376
      $INFOTEXT -n " Berkeley DB Spooling Server:\n" \
 
377
                   " If you want to setup a shadow master host, you need to use\nBerkeley DB Spooling Server!\n" \
 
378
                   " In this case you have to choose a host with a configured RPC service.\nThe qmaster host" \
 
379
                   " connects via RPC to the Berkeley DB. This setup is more\nfailsafe," \
 
380
                   " but results in a clear potential security hole. RPC communication\n" \
 
381
                   " (as used by Berkeley DB) can be easily compromised. Please only use this\n" \
 
382
                   " alternative if your site is secure or if you are not concerned about\n" \
 
383
                   " security. Check the installation guide for further advice on how to achieve\n" \
 
384
                   " failsafety without compromising security.\n\n"
 
385
 
 
386
      if [ "$AUTO" = "true" ]; then
 
387
         if [ "$DB_SPOOLING_SERVER" = "none" ]; then
 
388
            is_server="false"
 
389
         else
 
390
            is_server="true"
 
391
         fi
 
392
      else
 
393
         $INFOTEXT -n -ask "y" "n" -def "n" "Do you want to use a Berkeley DB Spooling Server? (y/n) [n] >> "
 
394
         if [ $? = 0 ]; then
 
395
            $INFOTEXT -u "Berkeley DB Setup\n"
 
396
            $INFOTEXT "Please, log in to your Berkeley DB spooling host and execute \"inst_sge -db\""
 
397
            $INFOTEXT -auto $AUTO -wait -n "Please do not continue, before the Berkeley DB installation with\n" \
 
398
                                        "\"inst_sge -db\" is completed, continue with <RETURN>"
 
399
            is_server="true"
 
400
         else
 
401
            is_server="false"
 
402
            $INFOTEXT -n -auto $AUTO -wait "\nHit <RETURN> to continue >> "
 
403
            $CLEAR
 
404
         fi
 
405
      fi
 
406
 
 
407
      if [ $is_server = "true" ]; then
 
408
         SpoolingQueryChange
 
409
      else
 
410
         done="false"
 
411
         is_spool="false"
 
412
 
 
413
         while [ $is_spool = "false" ] && [ $done = "false" ]; do
 
414
            $CLEAR
 
415
            SpoolingQueryChange "$1"
 
416
            if [ -d $SPOOLING_DIR ]; then
 
417
               $INFOTEXT -n -ask "y" "n" -def "n" -auto $AUTO "The spooling directory already exists! Do you want to delete it? [n] >> "
 
418
               ret=$?               
 
419
               if [ $AUTO = true ]; then
 
420
                  $INFOTEXT -log "The spooling directory already exists!\n Please remove it or choose any other spooling directory!"
 
421
                  MoveLog
 
422
                  exit 1
 
423
               fi
 
424
 
 
425
               if [ $ret = 0 ]; then
 
426
                     RM="rm -r"
 
427
                     ExecuteAsAdmin $RM $SPOOLING_DIR
 
428
                     if [ -d $SPOOLING_DIR ]; then
 
429
                        $INFOTEXT "You are not the owner of this directory. You can't delete it!"
 
430
                     else
 
431
                        is_spool="true"
 
432
                     fi
 
433
               else
 
434
                  $INFOTEXT -wait "Please hit <ENTER>, to choose any other spooling directory!"
 
435
               fi
 
436
             else
 
437
                is_spool="true"
 
438
             fi
 
439
 
 
440
            CheckLocalFilesystem $SPOOLING_DIR
 
441
            ret=$?
 
442
            if [ $ret -eq 0 -a "$AUTO" = "false" ]; then
 
443
               $INFOTEXT "\nThe database directory\n\n" \
 
444
                            "   %s\n\n" \
 
445
                            "is not on a local filesystem. Please choose a local filesystem or\n" \
 
446
                            "configure the RPC Client/Server mechanism." $SPOOLING_DIR
 
447
               $INFOTEXT -wait -auto $AUTO -n "\nHit <RETURN> to continue >> "
 
448
            else
 
449
               done="true" 
 
450
            fi
 
451
            
 
452
            if [ $is_spool = "false" ]; then
 
453
               done="false"
 
454
            elif [ $done = "false" ]; then
 
455
               is_spool="false"
 
456
            fi
 
457
 
 
458
         done
 
459
       fi
 
460
   else
 
461
      if [ "$ARCH" = "darwin" ]; then
 
462
         ret=`ps ax | grep "berkeley_db_svc" | wc -l` 
 
463
      else
 
464
         ret=`ps -efa | grep "berkeley_db_svc" | wc -l` 
 
465
      fi
 
466
      if [ $ret -gt 1 ]; then
 
467
         $INFOTEXT -u "Berkeley DB RPC Server installation"
 
468
         $INFOTEXT "\nWe found a running berkeley db server on this host!"
 
469
         if [ "$AUTO" = "true" ]; then
 
470
               if [ $SPOOLING_SERVER = "none" ]; then
 
471
                  $ECHO
 
472
                  ExecuteAsAdmin $MKDIR $SPOOLING_DIR
 
473
                  SPOOLING_ARGS="$SPOOLING_DIR"
 
474
               else
 
475
                  $INFOTEXT -log "We found a running berkeley db server on this host!"
 
476
                  $INFOTEXT -log "Please, check this first! Exiting Installation!"
 
477
                  MoveLog
 
478
                  exit 1
 
479
               fi
 
480
         else                 # $AUTO != true
 
481
            $INFOTEXT "The installation script does not support the configuration of more then one"
 
482
            $INFOTEXT "Berkeley DB on one Berkeley DB RPC host. This has to be done manually."
 
483
            $INFOTEXT "By adding your Berkeley DB spooling directory to the sgebdb rc-script"
 
484
            $INFOTEXT "and restarting the service, your Berkeley DB Server will be able to manage" 
 
485
            $INFOTEXT "more than one database.\n In your sgebdb rc-script you will find a line like: BDBHOMES=\"-h <spool_dir>\""
 
486
            $INFOTEXT "To add your DB, you have to add <your spool_dir> to this line which should"
 
487
            $INFOTEXT "look like this after edit: BDBHOMES=\"-h <spool_dir> -h <your spool_dir>\""
 
488
            $INFOTEXT "... exiting installation now! "
 
489
            exit 1
 
490
         fi 
 
491
      else
 
492
         while [ $params_ok -eq 0 ]; do
 
493
            do_loop="true"
 
494
            while [ $do_loop = "true" ]; do
 
495
               SpoolingQueryChange
 
496
               if [ -d $SPOOLING_DIR ]; then
 
497
                  $INFOTEXT -n -ask "y" "n" -def "n" -auto "$AUTO" "The spooling directory already exists! Do you want to delete it? (y/n) [n] >> "
 
498
                  ret=$?               
 
499
                  if [ "$AUTO" = true ]; then
 
500
                     $INFOTEXT -log "The spooling directory already exists!\n Please remove it or choose any other spooling directory!"
 
501
                     MoveLog
 
502
                     exit 1
 
503
                  fi
 
504
 
 
505
                  if [ $ret = 0 ]; then
 
506
                        RM="rm -r"
 
507
                        ExecuteAsAdmin $RM $SPOOLING_DIR
 
508
                        if [ -d $SPOOLING_DIR ]; then
 
509
                           $INFOTEXT "You are not the owner of this directory. You can't delete it!"
 
510
                        else
 
511
                           do_loop="false"
 
512
                        fi
 
513
                  else
 
514
                     $INFOTEXT -wait "Please hit <ENTER>, to choose any other spooling directory!"
 
515
                     SPOOLING_DIR="spooldb"
 
516
                  fi
 
517
                else
 
518
                   do_loop="false"
 
519
               fi
 
520
            done
 
521
            SpoolingCheckParams
 
522
            params_ok=$?
 
523
         done
 
524
      fi
 
525
   fi
 
526
 
 
527
   if [ "$SPOOLING_SERVER" = "none" ]; then
 
528
      $ECHO
 
529
      ExecuteAsAdmin $MKDIR $SPOOLING_DIR
 
530
      SPOOLING_ARGS="$SPOOLING_DIR"
 
531
   else
 
532
      SPOOLING_ARGS="$SPOOLING_SERVER:`basename $SPOOLING_DIR`"
 
533
   fi
 
534
}
 
535
 
 
536
SetSpoolingOptionsClassic()
 
537
{
 
538
   SPOOLING_METHOD=classic
 
539
   SPOOLING_LIB=libspoolc
 
540
   SPOOLING_ARGS="$SGE_ROOT_VAL/$COMMONDIR;$QMDIR"
 
541
}
 
542
 
 
543
SetSpoolingOptionsDynamic()
 
544
{
 
545
   if [ "$AUTO" = "true" ]; then
 
546
      if [ "$SPOOLING_METHOD" != "berkeleydb" -a "$SPOOLING_METHOD" != "classic" ]; then
 
547
         SPOOLING_METHOD="berkeleydb"
 
548
      fi
 
549
   else
 
550
      if [ "$BERKELEY" = "install" ]; then
 
551
         SPOOLING_METHOD="berkeleydb"
 
552
      else
 
553
         $INFOTEXT -n "Your SGE binaries are compiled to link the spooling libraries\n" \
 
554
                      "during runtime (dynamically). So you can choose between Berkeley DB \n" \
 
555
                      "spooling and Classic spooling method."
 
556
         $INFOTEXT -n "\nPlease choose a spooling method (berkeleydb|classic) [berkeleydb] >> "
 
557
         SPOOLING_METHOD=`Enter berkeleydb`
 
558
      fi
 
559
   fi
 
560
 
 
561
   $CLEAR
 
562
 
 
563
   case $SPOOLING_METHOD in 
 
564
      classic)
 
565
         SetSpoolingOptionsClassic
 
566
         ;;
 
567
      berkeleydb)
 
568
         SetSpoolingOptionsBerkeleyDB
 
569
         ;;
 
570
      *)
 
571
         $INFOTEXT "\nUnknown spooling method. Exit."
 
572
         $INFOTEXT -log "\nUnknown spooling method. Exit."
 
573
         MoveLog
 
574
         exit 1
 
575
         ;;
 
576
   esac
 
577
}
 
578
 
 
579
#--------------------------------------------------------------------------
 
580
# SetSpoolingOptions sets / queries options for the spooling framework
 
581
#
 
582
SetSpoolingOptions()
 
583
{
 
584
   $INFOTEXT -u "\nSetup spooling"
 
585
   COMPILED_IN_METHOD=`ExecuteAsAdmin $SPOOLINIT method`
 
586
   $INFOTEXT -log "Setting spooling method to %s" $COMPILED_IN_METHOD
 
587
   case "$COMPILED_IN_METHOD" in 
 
588
      classic)
 
589
         SetSpoolingOptionsClassic
 
590
         ;;
 
591
      berkeleydb)
 
592
         SetSpoolingOptionsBerkeleyDB
 
593
         ;;
 
594
      dynamic)
 
595
         SetSpoolingOptionsDynamic
 
596
         ;;
 
597
      *)
 
598
         $INFOTEXT "\nUnknown spooling method. Exit."
 
599
         $INFOTEXT -log "\nUnknown spooling method. Exit."
 
600
         MoveLog
 
601
         exit 1
 
602
         ;;
 
603
   esac
 
604
}
 
605
 
 
606
 
 
607
#-------------------------------------------------------------------------
 
608
# Ask the installer for the hostname resolving method
 
609
# (IGNORE_FQND=true/false)
 
610
#
 
611
SelectHostNameResolving()
 
612
{
 
613
   if [ $AUTO = "true" ]; then
 
614
     IGNORE_FQDN_DEFAULT=$HOSTNAME_RESOLVING
 
615
     $INFOTEXT -log "Using >%s< as IGNORE_FQDN_DEFAULT." "$IGNORE_FQDN_DEFAULT"
 
616
     $INFOTEXT -log "If it's >true<, the domain name will be ignored."
 
617
     
 
618
   else
 
619
     $CLEAR
 
620
     $INFOTEXT -u "\nSelect default Grid Engine hostname resolving method"
 
621
     $INFOTEXT "\nAre all hosts of your cluster in one DNS domain? If this is\n" \
 
622
               "the case the hostnames\n\n" \
 
623
               "   >hostA< and >hostA.foo.com<\n\n" \
 
624
               "would be treated as equal, because the DNS domain name >foo.com<\n" \
 
625
               "is ignored when comparing hostnames.\n\n"
 
626
 
 
627
     $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n \
 
628
               "Are all hosts of your cluster in a single DNS domain (y/n) [y] >> "
 
629
     if [ $? = 0 ]; then
 
630
        IGNORE_FQDN_DEFAULT=true
 
631
        $INFOTEXT "Ignoring domain name when comparing hostnames."
 
632
     else
 
633
        IGNORE_FQDN_DEFAULT=false
 
634
        $INFOTEXT "The domain name is not ignored when comparing hostnames."
 
635
     fi
 
636
     $INFOTEXT -wait -auto $AUTO -n "\nHit <RETURN> to continue >> "
 
637
     $CLEAR
 
638
   fi
 
639
 
 
640
   if [ "$IGNORE_FQDN_DEFAULT" = "false" ]; then
 
641
      GetDefaultDomain
 
642
   else
 
643
      CFG_DEFAULT_DOMAIN=none
 
644
   fi
 
645
}
 
646
 
 
647
 
 
648
#-------------------------------------------------------------------------
 
649
# SetProductMode
 
650
#
 
651
SetProductMode()
 
652
{
 
653
   if [ $AFS = true ]; then
 
654
      AFS_PREFIX="afs"
 
655
   else
 
656
      AFS_PREFIX=""
 
657
   fi
 
658
 
 
659
   if [ $CSP = true ]; then
 
660
 
 
661
      case $SGE_ARCH in
 
662
 
 
663
      aix* | hp11*)
 
664
          SEC_COUNT=`strings -a $SGE_BIN/sge_qmaster | grep "AIMK_SECURE_OPTION_ENABLED" | wc -l`
 
665
          ;;
 
666
         *)
 
667
          SEC_COUNT=`strings $SGE_BIN/sge_qmaster | grep "AIMK_SECURE_OPTION_ENABLED" | wc -l`
 
668
          ;;
 
669
      esac
 
670
 
 
671
      if [ $SEC_COUNT -ne 1 ]; then
 
672
         $INFOTEXT "\n>sge_qmaster< binary is not compiled with >-secure< option!\n"
 
673
         $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to cancel the installation >> "
 
674
         exit 1
 
675
      else
 
676
         CSP_PREFIX="csp"
 
677
      fi  
 
678
   else
 
679
      CSP_PREFIX=""
 
680
   fi
 
681
 
 
682
      if [ $AFS = "false" ]; then
 
683
         if [ $CSP = "false" ]; then
 
684
            PRODUCT_MODE="none"
 
685
         else
 
686
            PRODUCT_MODE="${CSP_PREFIX}"
 
687
         fi
 
688
      else
 
689
         PRODUCT_MODE="${AFS_PREFIX}"
 
690
      fi
 
691
}
 
692
 
 
693
 
 
694
#-------------------------------------------------------------------------
 
695
# Make directories needed by qmaster
 
696
#
 
697
MakeDirsMaster()
 
698
{
 
699
   $INFOTEXT -u "\nMaking directories"
 
700
   $ECHO
 
701
   $INFOTEXT -log "Making directories"
 
702
   Makedir $SGE_CELL_VAL
 
703
   Makedir $COMMONDIR
 
704
   Makedir $QMDIR
 
705
   Makedir $QMDIR/job_scripts
 
706
 
 
707
   $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
708
   $CLEAR
 
709
}
 
710
 
 
711
 
 
712
#-------------------------------------------------------------------------
 
713
# Adding Bootstrap information
 
714
#
 
715
AddBootstrap()
 
716
{
 
717
   TOUCH=touch
 
718
   $INFOTEXT "Dumping bootstrapping information"
 
719
   $INFOTEXT -log "Dumping bootstrapping information"
 
720
   ExecuteAsAdmin rm -f $COMMONDIR/bootstrap
 
721
   ExecuteAsAdmin $TOUCH $COMMONDIR/bootstrap
 
722
   ExecuteAsAdmin chmod 666 $COMMONDIR/bootstrap
 
723
   PrintBootstrap >> $COMMONDIR/bootstrap
 
724
   ExecuteAsAdmin chmod 444 $COMMONDIR/bootstrap
 
725
}
 
726
 
 
727
#-------------------------------------------------------------------------
 
728
# PrintBootstrap: print SGE default configuration
 
729
#
 
730
PrintBootstrap()
 
731
{
 
732
   $ECHO "# Version: $SGE_VERSION"
 
733
   $ECHO "#"
 
734
   if [ $ADMINUSER != default ]; then
 
735
      $ECHO "admin_user             $ADMINUSER"
 
736
   else
 
737
      $ECHO "admin_user             none"
 
738
   fi
 
739
   $ECHO "default_domain          $CFG_DEFAULT_DOMAIN"
 
740
   $ECHO "ignore_fqdn             $IGNORE_FQDN_DEFAULT"
 
741
   $ECHO "spooling_method         $SPOOLING_METHOD"
 
742
   $ECHO "spooling_lib            $SPOOLING_LIB"
 
743
   $ECHO "spooling_params         $SPOOLING_ARGS"
 
744
   $ECHO "binary_path             $SGE_ROOT_VAL/bin"
 
745
   $ECHO "qmaster_spool_dir       $QMDIR"
 
746
   $ECHO "security_mode           $PRODUCT_MODE"
 
747
   $ECHO "listener_threads        2"
 
748
   $ECHO "worker_threads          2"
 
749
   $ECHO "scheduler_threads       1"
 
750
   if [ "$SGE_ENABLE_JMX" = "true" ]; then
 
751
      $ECHO "jvm_threads             1"
 
752
   else
 
753
      $ECHO "jvm_threads             0"
 
754
   fi
 
755
}
 
756
 
 
757
 
 
758
#-------------------------------------------------------------------------
 
759
# Initialize the spooling database (or directory structure)
 
760
#
 
761
InitSpoolingDatabase()
 
762
{
 
763
   $INFOTEXT "Initializing spooling database"
 
764
   $INFOTEXT -log "Initializing spooling database"
 
765
   ExecuteAsAdmin $SPOOLINIT $SPOOLING_METHOD $SPOOLING_LIB "$SPOOLING_ARGS" init
 
766
 
 
767
   $INFOTEXT -wait -auto $AUTO -n "\nHit <RETURN> to continue >> "
 
768
   $CLEAR
 
769
}
 
770
 
 
771
 
 
772
#-------------------------------------------------------------------------
 
773
# AddConfiguration
 
774
# optional args for GetConfigutration
 
775
# $1 - default CFG_EXE_SPOOL
 
776
# $2 - default CFG_MAIL_ADDR
 
777
AddConfiguration()
 
778
{
 
779
   useold=false
 
780
 
 
781
   if [ $useold = false ]; then
 
782
      GetConfiguration "$@"
 
783
      #TruncCreateAndMakeWriteable $COMMONDIR/configuration
 
784
      #PrintConf >> $COMMONDIR/configuration
 
785
      #SetPerm $COMMONDIR/configuration
 
786
      TMPC=/tmp/configuration
 
787
      TOUCH=touch
 
788
      rm -f $TMPC
 
789
      ExecuteAsAdmin $TOUCH $TMPC
 
790
      PrintConf >> $TMPC
 
791
      SetPerm $TMPC
 
792
      ExecuteAsAdmin $SPOOLDEFAULTS configuration $TMPC
 
793
      rm -f $TMPC
 
794
   fi
 
795
}
 
796
 
 
797
#-------------------------------------------------------------------------
 
798
# PrintConf: print SGE default configuration
 
799
#
 
800
PrintConf()
 
801
{
 
802
   $ECHO "# Version: $SGE_VERSION"
 
803
   $ECHO "#"
 
804
   $ECHO "# DO NOT MODIFY THIS FILE MANUALLY!"
 
805
   $ECHO "#"
 
806
   $ECHO "conf_version           0"
 
807
   $ECHO "execd_spool_dir        $CFG_EXE_SPOOL"
 
808
   $ECHO "mailer                 $MAILER"
 
809
   $ECHO "xterm                  $XTERM"
 
810
   $ECHO "load_sensor            none"
 
811
   $ECHO "prolog                 none"
 
812
   $ECHO "epilog                 none"
 
813
   $ECHO "shell_start_mode       posix_compliant"
 
814
   $ECHO "login_shells           sh,ksh,csh,tcsh"
 
815
   $ECHO "min_uid                0"
 
816
   $ECHO "min_gid                0"
 
817
   $ECHO "user_lists             none"
 
818
   $ECHO "xuser_lists            none"
 
819
   $ECHO "projects               none"
 
820
   $ECHO "xprojects              none"
 
821
   $ECHO "enforce_project        false"
 
822
   $ECHO "enforce_user           auto"
 
823
   $ECHO "load_report_time       00:00:40"
 
824
   $ECHO "max_unheard            00:05:00"
 
825
   $ECHO "reschedule_unknown     00:00:00"
 
826
   $ECHO "loglevel               log_warning"
 
827
   $ECHO "administrator_mail     $CFG_MAIL_ADDR"
 
828
   if [ "$AFS" = true ]; then
 
829
      $ECHO "set_token_cmd          /path_to_token_cmd/set_token_cmd"
 
830
      $ECHO "pag_cmd                /usr/afsws/bin/pagsh"
 
831
      $ECHO "token_extend_time      24:0:0"
 
832
   else
 
833
      $ECHO "set_token_cmd          none"
 
834
      $ECHO "pag_cmd                none"
 
835
      $ECHO "token_extend_time      none"
 
836
   fi
 
837
   $ECHO "shepherd_cmd           none"
 
838
   $ECHO "qmaster_params         none"
 
839
   if [ "$WINDOWS_SUPPORT" = "true" -a "$WIN_DOMAIN_ACCESS" = "true" ]; then
 
840
      $ECHO "execd_params           enable_windomacc=true"
 
841
   elif [ "$WINDOWS_SUPPORT" = "true" -a "$WIN_DOMAIN_ACCESS" = "false" ]; then
 
842
      $ECHO "execd_params           enable_windomacc=false"
 
843
   else
 
844
      $ECHO "execd_params           none"
 
845
   fi
 
846
   $ECHO "reporting_params       accounting=true reporting=false flush_time=00:00:15 joblog=false sharelog=00:00:00"
 
847
   $ECHO "finished_jobs          100"
 
848
   $ECHO "gid_range              $CFG_GID_RANGE"
 
849
   $ECHO "qlogin_command         $QLOGIN_COMMAND"
 
850
   $ECHO "qlogin_daemon          $QLOGIN_DAEMON"
 
851
   if [ "$RLOGIN_COMMAND" != "undef" ]; then
 
852
      $ECHO "rlogin_command         $RLOGIN_COMMAND"
 
853
   fi
 
854
   $ECHO "rlogin_daemon          $RLOGIN_DAEMON"
 
855
   if [ "$RSH_COMMAND" != "undef" ]; then
 
856
      $ECHO "rsh_command            $RSH_COMMAND"
 
857
   fi
 
858
   if [ "$RSH_DAEMON" != "undef" ]; then
 
859
      $ECHO "rsh_daemon             $RSH_DAEMON"
 
860
   fi
 
861
 
 
862
   $ECHO "max_aj_instances       2000"
 
863
   $ECHO "max_aj_tasks           75000"
 
864
   $ECHO "max_u_jobs             0"
 
865
   $ECHO "max_jobs               0"
 
866
   $ECHO "max_advance_reservations 0"
 
867
   $ECHO "auto_user_oticket      0"
 
868
   $ECHO "auto_user_fshare       0"
 
869
   $ECHO "auto_user_default_project none"
 
870
   $ECHO "auto_user_delete_time  86400"
 
871
   $ECHO "delegated_file_staging false"
 
872
   $ECHO "reprioritize           0"
 
873
   if [ "$SGE_JVM_LIB_PATH" != "" ]; then
 
874
      $ECHO "libjvm_path            $SGE_JVM_LIB_PATH"
 
875
   fi
 
876
   if [ "$SGE_ADDITIONAL_JVM_ARGS" != "" ]; then
 
877
      $ECHO "additional_jvm_args            $SGE_ADDITIONAL_JVM_ARGS"
 
878
   fi
 
879
}
 
880
 
 
881
 
 
882
#-------------------------------------------------------------------------
 
883
# AddLocalConfiguration
 
884
#
 
885
AddLocalConfiguration()
 
886
{
 
887
   $CLEAR
 
888
   $INFOTEXT -u "\nCreating local configuration"
 
889
 
 
890
      ExecuteAsAdmin mkdir /tmp/$$
 
891
      TMPH=/tmp/$$/$HOST
 
892
      ExecuteAsAdmin rm -f $TMPH
 
893
      ExecuteAsAdmin touch $TMPH
 
894
      PrintLocalConf 1 >> $TMPH
 
895
      ExecuteAsAdmin $SPOOLDEFAULTS local_conf $TMPH $HOST
 
896
      ExecuteAsAdmin rm -rf /tmp/$$
 
897
}
 
898
 
 
899
 
 
900
#-------------------------------------------------------------------------
 
901
# GetConfiguration: get some parameters for global configuration
 
902
# args are optional
 
903
# $1 - default CFG_EXE_SPOOL
 
904
# $2 - default CFG_MAIL_ADDR
 
905
GetConfiguration()
 
906
{
 
907
 
 
908
   GetGidRange
 
909
 
 
910
   #if [ $fast = true ]; then
 
911
   #   CFG_EXE_SPOOL=$SGE_ROOT_VAL/$SGE_CELL_VAL/spool
 
912
   #   CFG_MAIL_ADDR=none
 
913
   #   return 0
 
914
   #fi
 
915
   if [ $AUTO = true ]; then
 
916
     CFG_EXE_SPOOL=$EXECD_SPOOL_DIR
 
917
     CFG_MAIL_ADDR=$ADMIN_MAIL
 
918
     $INFOTEXT -log "Using >%s< as EXECD_SPOOL_DIR." "$CFG_EXE_SPOOL"
 
919
     $INFOTEXT -log "Using >%s< as ADMIN_MAIL." "$ADMIN_MAIL"
 
920
   else
 
921
   done=false
 
922
   while [ $done = false ]; do
 
923
      $CLEAR
 
924
      $INFOTEXT -u "\nGrid Engine cluster configuration"
 
925
      $INFOTEXT "\nPlease give the basic configuration parameters of your Grid Engine\n" \
 
926
                "installation:\n\n   <execd_spool_dir>\n\n"
 
927
 
 
928
      if [ $ADMINUSER != default ]; then
 
929
            $INFOTEXT "The pathname of the spool directory of the execution hosts. User >%s<\n" \
 
930
                      "must have the right to create this directory and to write into it.\n" "$ADMINUSER"
 
931
      elif [ $euid = 0 ]; then
 
932
            $INFOTEXT "The pathname of the spool directory of the execution hosts. User >root<\n" \
 
933
                      "must have the right to create this directory and to write into it.\n"
 
934
      else
 
935
            $INFOTEXT "The pathname of the spool directory of the execution hosts. You\n" \
 
936
                      "must have the right to create this directory and to write into it.\n"
 
937
      fi
 
938
      
 
939
      if [ -z "$1" ]; then
 
940
         default_value=$SGE_ROOT_VAL/$SGE_CELL_VAL/spool
 
941
      else
 
942
         default_value="$1"
 
943
      fi
 
944
 
 
945
      $INFOTEXT -n "Default: [%s] >> " $default_value
 
946
 
 
947
      CFG_EXE_SPOOL=`Enter $default_value`
 
948
 
 
949
      $CLEAR
 
950
      if [ -z "$2" ]; then
 
951
         default_value=none
 
952
      else
 
953
         default_value="$2"
 
954
      fi
 
955
      $INFOTEXT -u "\nGrid Engine cluster configuration (continued)"
 
956
      $INFOTEXT -n "\n<administrator_mail>\n\n" \
 
957
                   "The email address of the administrator to whom problem reports are sent.\n\n" \
 
958
                   "It's is recommended to configure this parameter. You may use >none<\n" \
 
959
                   "if you do not wish to receive administrator mail.\n\n" \
 
960
                   "Please enter an email address in the form >user@foo.com<.\n\n" \
 
961
                   "Default: [%s] >> " $default_value
 
962
 
 
963
      CFG_MAIL_ADDR=`Enter $default_value`
 
964
 
 
965
      $CLEAR
 
966
      $INFOTEXT "\nThe following parameters for the cluster configuration were configured:\n\n" \
 
967
                "   execd_spool_dir        %s\n" \
 
968
                "   administrator_mail     %s\n" $CFG_EXE_SPOOL $CFG_MAIL_ADDR
 
969
 
 
970
      $INFOTEXT -auto $AUTO -ask "y" "n" -def "n" -n \
 
971
                "Do you want to change the configuration parameters (y/n) [n] >> "
 
972
      if [ $? = 1 ]; then
 
973
         done=true
 
974
      fi
 
975
   done
 
976
   fi
 
977
   export CFG_EXE_SPOOL
 
978
}
 
979
 
 
980
 
 
981
#-------------------------------------------------------------------------
 
982
# GetGidRange
 
983
#
 
984
GetGidRange()
 
985
{
 
986
   done=false
 
987
   if [ -z "$GID_RANGE" ]; then
 
988
        GID_RANGE=20000-20100
 
989
   fi
 
990
   
 
991
   while [ $done = false ]; do
 
992
      $CLEAR
 
993
      $INFOTEXT -u "\nGrid Engine group id range"
 
994
      $INFOTEXT "\nWhen jobs are started under the control of Grid Engine an additional group id\n" \
 
995
                "is set on platforms which do not support jobs. This is done to provide maximum\n" \
 
996
                "control for Grid Engine jobs.\n\n" \
 
997
                "This additional UNIX group id range must be unused group id's in your system.\n" \
 
998
                "Each job will be assigned a unique id during the time it is running.\n" \
 
999
                "Therefore you need to provide a range of id's which will be assigned\n" \
 
1000
                "dynamically for jobs.\n\n" \
 
1001
                "The range must be big enough to provide enough numbers for the maximum number\n" \
 
1002
                "of Grid Engine jobs running at a single moment on a single host. E.g. a range\n" \
 
1003
                "like >20000-20100< means, that Grid Engine will use the group ids from\n" \
 
1004
                "20000-20100 and provides a range for 100 Grid Engine jobs at the same time\n" \
 
1005
                "on a single host.\n\n" \
 
1006
                "You can change at any time the group id range in your cluster configuration.\n"
 
1007
 
 
1008
      $INFOTEXT -n "Please enter a range [%s] >> " $GID_RANGE
 
1009
 
 
1010
      CFG_GID_RANGE=`Enter $GID_RANGE`
 
1011
 
 
1012
      if [ "$CFG_GID_RANGE" != "" ]; then
 
1013
         $INFOTEXT -wait -auto $AUTO -n "\nUsing >%s< as gid range. Hit <RETURN> to continue >> " \
 
1014
                   "$CFG_GID_RANGE"
 
1015
         $CLEAR
 
1016
         done=true
 
1017
      fi
 
1018
     if [ $AUTO = true -a "$GID_RANGE" = "" ]; then
 
1019
        $INFOTEXT -log "Please enter a valid GID Range. Installation failed!"
 
1020
        MoveLog
 
1021
        exit 1
 
1022
     fi
 
1023
 
 
1024
     $INFOTEXT -log "Using >%s< as gid range." "$CFG_GID_RANGE"  
 
1025
   done
 
1026
}
 
1027
 
 
1028
 
 
1029
#-------------------------------------------------------------------------
 
1030
# AddActQmaster: create act_qmaster file
 
1031
#
 
1032
AddActQmaster()
 
1033
{
 
1034
   $INFOTEXT "Creating >act_qmaster< file"
 
1035
 
 
1036
   TruncCreateAndMakeWriteable $COMMONDIR/act_qmaster
 
1037
   $ECHO $HOST >> $COMMONDIR/act_qmaster
 
1038
   SetPerm $COMMONDIR/act_qmaster
 
1039
}
 
1040
 
 
1041
 
 
1042
#-------------------------------------------------------------------------
 
1043
# AddDefaultComplexes
 
1044
#
 
1045
AddDefaultComplexes()
 
1046
{
 
1047
   $INFOTEXT "Adding default complex attributes"
 
1048
   ExecuteAsAdmin $SPOOLDEFAULTS complexes $SGE_ROOT_VAL/util/resources/centry
 
1049
 
 
1050
}
 
1051
 
 
1052
 
 
1053
#-------------------------------------------------------------------------
 
1054
# AddCommonFiles
 
1055
#    Copy files from util directory to common dir
 
1056
#
 
1057
AddCommonFiles()
 
1058
{
 
1059
   for f in sge_aliases qtask sge_request; do
 
1060
      if [ $f = sge_aliases ]; then
 
1061
         $INFOTEXT "Adding >%s< path aliases file" $f
 
1062
      elif [ $f = qtask ]; then
 
1063
         $INFOTEXT "Adding >%s< qtcsh sample default request file" $f
 
1064
      else
 
1065
         $INFOTEXT "Adding >%s< default submit options file" $f
 
1066
      fi
 
1067
      ExecuteAsAdmin cp util/$f $COMMONDIR
 
1068
      ExecuteAsAdmin chmod $FILEPERM $COMMONDIR/$f
 
1069
   done
 
1070
 
 
1071
}
 
1072
 
 
1073
AddJMXFiles() {
 
1074
   if [ "$SGE_ENABLE_JMX" = "true" ]; then
 
1075
      jmx_dir=$COMMONDIR/jmx
 
1076
      ExecuteAsAdmin mkdir -p $jmx_dir
 
1077
      
 
1078
      $INFOTEXT "Adding >jmx/%s< jmx remote access file" jmxremote.access
 
1079
      ExecuteAsAdmin cp util/jmxremote.access $jmx_dir/jmxremote.access
 
1080
      ExecuteAsAdmin chmod $FILEPERM $jmx_dir/jmxremote.access
 
1081
      
 
1082
      $INFOTEXT "Adding >jmx/%s< jmx remote password file" jmxremote.password
 
1083
      ExecuteAsAdmin cp util/jmxremote.password $jmx_dir/jmxremote.password
 
1084
      ExecuteAsAdmin chmod 600 $jmx_dir/jmxremote.password
 
1085
     
 
1086
      $INFOTEXT "Adding >jmx/%s< jmx logging configuration" logging.properties
 
1087
      ExecuteAsAdmin cp util/logging.properties.template $jmx_dir/logging.properties
 
1088
      ExecuteAsAdmin chmod 644 $jmx_dir/logging.properties
 
1089
 
 
1090
      $INFOTEXT "Adding >jmx/%s< java policies configuration" java.policy
 
1091
      ExecuteAsAdmin cp util/java.policy.template $jmx_dir/java.policy
 
1092
      ExecuteAsAdmin chmod 644 $jmx_dir/java.policy
 
1093
 
 
1094
      $INFOTEXT "Adding >jmx/%s< jaas configuration" jaas.config
 
1095
      ExecuteAsAdmin cp util/jaas.config.template $jmx_dir/jaas.config
 
1096
      ExecuteAsAdmin chmod 644 $jmx_dir/jaas.config
 
1097
 
 
1098
      ExecuteAsAdmin touch /tmp/management.properties.$$
 
1099
      Execute sed -e "s#@@SGE_JMX_PORT@@#$SGE_JMX_PORT#g" \
 
1100
                  -e "s#@@SGE_ROOT@@#$SGE_ROOT#g" \
 
1101
                  -e "s#@@SGE_CELL@@#$SGE_CELL#g" \
 
1102
                  -e "s#@@SGE_JMX_SSL@@#$SGE_JMX_SSL#g" \
 
1103
                  -e "s#@@SGE_JMX_SSL_CLIENT@@#$SGE_JMX_SSL_CLIENT#g" \
 
1104
                  -e "s#@@SGE_JMX_SSL_KEYSTORE@@#$SGE_JMX_SSL_KEYSTORE#g" \
 
1105
                  -e "s#@@SGE_JMX_SSL_KEYSTORE_PW@@#$SGE_JMX_SSL_KEYSTORE_PW#g" \
 
1106
                  util/management.properties.template > /tmp/management.properties.$$
 
1107
      ExecuteAsAdmin mv /tmp/management.properties.$$ $jmx_dir/management.properties
 
1108
      ExecuteAsAdmin chmod $FILEPERM $jmx_dir/management.properties
 
1109
      $INFOTEXT "Adding >jmx/%s< jmx configuration" management.properties
 
1110
      
 
1111
   fi
 
1112
}
 
1113
 
 
1114
#-------------------------------------------------------------------------
 
1115
# AddPEFiles
 
1116
#    Copy files from PE template directory to qmaster spool dir
 
1117
#
 
1118
AddPEFiles()
 
1119
{
 
1120
   $INFOTEXT "Adding default parallel environments (PE)"
 
1121
   $INFOTEXT -log "Adding default parallel environments (PE)"
 
1122
   ExecuteAsAdmin $SPOOLDEFAULTS pes $SGE_ROOT_VAL/util/resources/pe
 
1123
}
 
1124
 
 
1125
 
 
1126
#-------------------------------------------------------------------------
 
1127
# AddDefaultUsersets
 
1128
#
 
1129
AddDefaultUsersets()
 
1130
{
 
1131
      $INFOTEXT "Adding SGE default usersets"
 
1132
      ExecuteAsAdmin $SPOOLDEFAULTS usersets $SGE_ROOT_VAL/util/resources/usersets
 
1133
}
 
1134
 
 
1135
 
 
1136
#-------------------------------------------------------------------------
 
1137
# CreateSettingsFile: Create resource files for csh/sh
 
1138
#
 
1139
CreateSettingsFile()
 
1140
{
 
1141
   $INFOTEXT "Creating settings files for >.profile/.cshrc<"
 
1142
 
 
1143
   if [ $RECREATE_SETTINGS = "false" ]; then
 
1144
      if [ -f $SGE_ROOT/$SGE_CELL/common/settings.sh ]; then
 
1145
         ExecuteAsAdmin $RM $SGE_ROOT/$SGE_CELL/common/settings.sh
 
1146
      fi
 
1147
  
 
1148
      if [ -f $SGE_ROOT/$SGE_CELL/common/settings.csh ]; then
 
1149
         ExecuteAsAdmin $RM $SGE_ROOT/$SGE_CELL/common/settings.csh
 
1150
      fi
 
1151
   fi
 
1152
 
 
1153
   ExecuteAsAdmin util/create_settings.sh $SGE_ROOT_VAL/$COMMONDIR
 
1154
 
 
1155
   SetPerm $SGE_ROOT_VAL/$COMMONDIR/settings.sh
 
1156
   SetPerm $SGE_ROOT_VAL/$COMMONDIR/settings.csh
 
1157
 
 
1158
   $INFOTEXT -wait -auto $AUTO -n "\nHit <RETURN> to continue >> "
 
1159
}
 
1160
 
 
1161
 
 
1162
#--------------------------------------------------------------------------
 
1163
# InitCA Create CA and initialize it for daemons and users
 
1164
#
 
1165
InitCA()
 
1166
{
 
1167
 
 
1168
   if [ "$CSP" = true -o \( "$WINDOWS_SUPPORT" = "true" -a "$WIN_DOMAIN_ACCESS" = "true" \) -o "$SGE_JMX_SSL" = true ]; then
 
1169
      # Initialize CA, make directories and get DN info
 
1170
      #
 
1171
      SGE_CA_CMD=util/sgeCA/sge_ca
 
1172
      if [ "$AUTO" = "true" ]; then
 
1173
         if [ "$CSP_RECREATE" = "true" ]; then
 
1174
            $SGE_CA_CMD -init -days 365 -auto $FILE
 
1175
            #if [ -f "$CSP_USERFILE" ]; then
 
1176
            #   $SGE_CA_CMD -usercert $CSP_USERFILE
 
1177
            #fi
 
1178
         fi
 
1179
      else
 
1180
         $SGE_CA_CMD -init -days 365
 
1181
      fi
 
1182
 
 
1183
      #  TODO: CAErrUsage no longer available, error handling ???:w
 
1184
 
 
1185
      if [ "$SGE_JMX_SSL" = true ]; then
 
1186
         touch /tmp/pwfile.$$
 
1187
         chmod 600 /tmp/pwfile.$$
 
1188
         echo "$SGE_JMX_SSL_KEYSTORE_PW" > /tmp/pwfile.$$
 
1189
         $SGE_CA_CMD -sysks -kspwf /tmp/pwfile.$$
 
1190
         rm /tmp/pwfile.$$
 
1191
      fi
 
1192
      
 
1193
      $INFOTEXT -auto $AUTO -wait -n "Hit <RETURN> to continue >> "
 
1194
      $CLEAR
 
1195
   fi
 
1196
}
 
1197
 
 
1198
 
 
1199
#--------------------------------------------------------------------------
 
1200
# StartQmaster
 
1201
#
 
1202
StartQmaster()
 
1203
{
 
1204
   $INFOTEXT -u "\nGrid Engine qmaster startup"
 
1205
   $INFOTEXT "\nStarting qmaster daemon. Please wait ..."
 
1206
 
 
1207
   if [ "$SGE_ENABLE_SMF" = "true" ]; then
 
1208
      $SVCADM enable -s "svc:/application/sge/qmaster:$SGE_CLUSTER_NAME"
 
1209
      if [ $? -ne 0 ]; then
 
1210
         $INFOTEXT "\nFailed to start qmaster deamon over SMF. Check service by issuing "\
 
1211
                   "svcs -l svc:/application/sge/qmaster:%s" $SGE_CLUSTER_NAME
 
1212
         $INFOTEXT -log "\nFailed to start qmaster deamon over SMF. Check service by issuing "\
 
1213
                        "svcs -l svc:/application/sge/qmaster:%s" $SGE_CLUSTER_NAME
 
1214
         if [ $AUTO = true ]; then
 
1215
            MoveLog
 
1216
         fi
 
1217
         exit 1
 
1218
      fi
 
1219
   else
 
1220
      $SGE_STARTUP_FILE -qmaster
 
1221
   fi
 
1222
   CheckRunningDaemon sge_qmaster
 
1223
   run=$?
 
1224
   if [ $run -ne 0 ]; then
 
1225
      $INFOTEXT "sge_qmaster daemon didn't start. Please check your\n" \
 
1226
                "configuration! Installation failed!"
 
1227
      $INFOTEXT -log "sge_qmaster daemon didn't start. Please check your\n" \
 
1228
                     "autoinstall configuration file! Installation failed!"
 
1229
 
 
1230
      MoveLog
 
1231
      exit 1
 
1232
   fi
 
1233
   $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
1234
   $CLEAR
 
1235
}
 
1236
 
 
1237
 
 
1238
#-------------------------------------------------------------------------
 
1239
# AddHosts
 
1240
#
 
1241
AddHosts()
 
1242
{
 
1243
   if [ "$AUTO" = "true" ]; then
 
1244
      for h in $ADMIN_HOST_LIST; do
 
1245
        if [ -f $h ]; then
 
1246
           $INFOTEXT -log "Adding ADMIN_HOSTS from file %s" $h
 
1247
           for tmp in `cat $h`; do
 
1248
             $INFOTEXT -log "Adding ADMIN_HOST %s" $tmp
 
1249
             $SGE_BIN/qconf -ah $tmp
 
1250
           done
 
1251
        else
 
1252
             $INFOTEXT -log "Adding ADMIN_HOST %s" $h
 
1253
             $SGE_BIN/qconf -ah $h
 
1254
        fi
 
1255
      done
 
1256
      
 
1257
      for h in $SUBMIT_HOST_LIST; do
 
1258
        if [ -f $h ]; then
 
1259
           $INFOTEXT -log "Adding SUBMIT_HOSTS from file %s" $h
 
1260
           for tmp in `cat $h`; do
 
1261
             $INFOTEXT -log "Adding SUBMIT_HOST %s" $tmp
 
1262
             $SGE_BIN/qconf -as $tmp
 
1263
           done
 
1264
        else
 
1265
             $INFOTEXT -log "Adding SUBMIT_HOST %s" $h
 
1266
             $SGE_BIN/qconf -as $h
 
1267
        fi
 
1268
      done  
 
1269
 
 
1270
      for h in $SHADOW_HOST; do
 
1271
        if [ -f $h ]; then
 
1272
           $INFOTEXT -log "Adding SHADOW_HOSTS from file %s" $h
 
1273
           for tmp in `cat $h`; do
 
1274
             $INFOTEXT -log "Adding SHADOW_HOST %s" $tmp
 
1275
             $SGE_BIN/qconf -ah $tmp
 
1276
           done
 
1277
        else
 
1278
             $INFOTEXT -log "Adding SHADOW_HOST %s" $h
 
1279
             $SGE_BIN/qconf -ah $h
 
1280
        fi
 
1281
      done
 
1282
  
 
1283
   else
 
1284
      $INFOTEXT -u "\nAdding Grid Engine hosts"
 
1285
      $INFOTEXT "\nPlease now add the list of hosts, where you will later install your execution\n" \
 
1286
                "daemons. These hosts will be also added as valid submit hosts.\n\n" \
 
1287
                "Please enter a blank separated list of your execution hosts. You may\n" \
 
1288
                "press <RETURN> if the line is getting too long. Once you are finished\n" \
 
1289
                "simply press <RETURN> without entering a name.\n\n" \
 
1290
                "You also may prepare a file with the hostnames of the machines where you plan\n" \
 
1291
                "to install Grid Engine. This may be convenient if you are installing Grid\n" \
 
1292
                "Engine on many hosts.\n\n"
 
1293
 
 
1294
      $INFOTEXT -auto $AUTO -ask "y" "n" -def "n" -n \
 
1295
                "Do you want to use a file which contains the list of hosts (y/n) [n] >> "
 
1296
      ret=$?
 
1297
      if [ $ret = 0 ]; then
 
1298
         AddHostsFromFile execd
 
1299
         ret=$?
 
1300
      fi
 
1301
 
 
1302
      if [ $ret = 1 ]; then
 
1303
         AddHostsFromTerminal execd
 
1304
      fi
 
1305
 
 
1306
      $INFOTEXT -wait -auto $AUTO -n "Finished adding hosts. Hit <RETURN> to continue >> "
 
1307
      $CLEAR
 
1308
 
 
1309
      # Adding later shadow hosts to the admin host list
 
1310
      $INFOTEXT "\nIf you want to use a shadow host, it is recommended to add this host\n" \
 
1311
                "to the list of administrative hosts.\n\n" \
 
1312
                "If you are not sure, it is also possible to add or remove hosts after the\n" \
 
1313
                "installation with <qconf -ah hostname> for adding and <qconf -dh hostname>\n" \
 
1314
                "for removing this host\n\nAttention: This is not the shadow host installation\n" \
 
1315
                "procedure.\n You still have to install the shadow host separately\n\n"
 
1316
      $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n \
 
1317
                "Do you want to add your shadow host(s) now? (y/n) [y] >> "
 
1318
      ret=$?
 
1319
      if [ "$ret" = 0 ]; then
 
1320
         $CLEAR
 
1321
         $INFOTEXT -u "\nAdding Grid Engine shadow hosts"
 
1322
         $INFOTEXT "\nPlease now add the list of hosts, where you will later install your shadow\n" \
 
1323
                   "daemon.\n\n" \
 
1324
                   "Please enter a blank separated list of your execution hosts. You may\n" \
 
1325
                   "press <RETURN> if the line is getting too long. Once you are finished\n" \
 
1326
                   "simply press <RETURN> without entering a name.\n\n" \
 
1327
                   "You also may prepare a file with the hostnames of the machines where you plan\n" \
 
1328
                   "to install Grid Engine. This may be convenient if you are installing Grid\n" \
 
1329
                   "Engine on many hosts.\n\n"
 
1330
 
 
1331
         $INFOTEXT -auto $AUTO -ask "y" "n" -def "n" -n \
 
1332
                   "Do you want to use a file which contains the list of hosts (y/n) [n] >> "
 
1333
         ret=$?
 
1334
         if [ $ret = 0 ]; then
 
1335
            AddHostsFromFile shadowd 
 
1336
            ret=$?
 
1337
         fi
 
1338
 
 
1339
         if [ $ret = 1 ]; then
 
1340
            AddHostsFromTerminal shadowd
 
1341
         fi
 
1342
 
 
1343
         $INFOTEXT -wait -auto $AUTO -n "Finished adding hosts. Hit <RETURN> to continue >> "
 
1344
      fi
 
1345
      $CLEAR
 
1346
 
 
1347
   fi
 
1348
 
 
1349
   $INFOTEXT -u "\nCreating the default <all.q> queue and <allhosts> hostgroup"
 
1350
   echo
 
1351
   $INFOTEXT -log "Creating the default <all.q> queue and <allhosts> hostgroup"
 
1352
   TMPL=/tmp/hostqueue$$
 
1353
   TMPL2=${TMPL}.q
 
1354
   rm -f $TMPL $TMPL2
 
1355
   if [ -f $TMPL -o -f $TMPL2 ]; then
 
1356
      $INFOTEXT "\nCan't delete template files >%s< or >%s<" "$TMPL" "$TMPL2"
 
1357
   else
 
1358
      PrintHostGroup @allhosts > $TMPL
 
1359
      Execute $SGE_BIN/qconf -Ahgrp $TMPL
 
1360
      Execute $SGE_BIN/qconf -sq > $TMPL
 
1361
      Execute sed -e "/qname/s/template/all.q/" \
 
1362
                  -e "/hostlist/s/NONE/@allhosts/" \
 
1363
                  -e "/pe_list/s/NONE/make/" $TMPL > $TMPL2
 
1364
      Execute $SGE_BIN/qconf -Aq $TMPL2
 
1365
      rm -f $TMPL $TMPL2        
 
1366
   fi
 
1367
 
 
1368
   $INFOTEXT -wait -auto $AUTO -n "\nHit <RETURN> to continue >> "
 
1369
   $CLEAR
 
1370
 
 
1371
}
 
1372
 
 
1373
 
 
1374
#-------------------------------------------------------------------------
 
1375
# AddSubmitHosts
 
1376
#
 
1377
AddSubmitHosts()
 
1378
{
 
1379
   CERT_COPY_HOST_LIST=""
 
1380
   if [ "$AUTO" = "true" ]; then
 
1381
      CERT_COPY_HOST_LIST=$SUBMIT_HOST_LIST
 
1382
      for h in $SUBMIT_HOST_LIST; do
 
1383
        if [ -f $h ]; then
 
1384
           $INFOTEXT -log "Adding SUBMIT_HOSTS from file %s" $h
 
1385
           for tmp in `cat $h`; do
 
1386
             $INFOTEXT -log "Adding SUBMIT_HOST %s" $tmp
 
1387
             $SGE_BIN/qconf -as $tmp
 
1388
           done
 
1389
        else
 
1390
             $INFOTEXT -log "Adding SUBMIT_HOST %s" $h
 
1391
             $SGE_BIN/qconf -as $h
 
1392
        fi
 
1393
      done  
 
1394
   else
 
1395
      $INFOTEXT -u "\nAdding Grid Engine submit hosts"
 
1396
      $INFOTEXT "\nPlease now add the list of hosts, which should become submit hosts.\n" \
 
1397
                "Please enter a blank separated list of your submit hosts. You may\n" \
 
1398
                "press <RETURN> if the line is getting too long. Once you are finished\n" \
 
1399
                "simply press <RETURN> without entering a name.\n\n" \
 
1400
                "You also may prepare a file with the hostnames of the machines where you plan\n" \
 
1401
                "to install Grid Engine. This may be convenient if you are installing Grid\n" \
 
1402
                "Engine on many hosts.\n\n"
 
1403
 
 
1404
      $INFOTEXT -auto $AUTO -ask "y" "n" -def "n" -n \
 
1405
                "Do you want to use a file which contains the list of hosts (y/n) [n] >> "
 
1406
      ret=$?
 
1407
      if [ $ret = 0 ]; then
 
1408
         AddHostsFromFile submit 
 
1409
         ret=$?
 
1410
      fi
 
1411
 
 
1412
      if [ $ret = 1 ]; then
 
1413
         AddHostsFromTerminal submit 
 
1414
      fi
 
1415
 
 
1416
      $INFOTEXT -wait -auto $AUTO -n "Finished adding hosts. Hit <RETURN> to continue >> "
 
1417
      $CLEAR
 
1418
   fi
 
1419
}
 
1420
 
 
1421
 
 
1422
#-------------------------------------------------------------------------
 
1423
# AddHostsFromFile: Get a list of hosts and add them as
 
1424
# admin and submit hosts
 
1425
#
 
1426
AddHostsFromFile()
 
1427
{
 
1428
   hosttype=$1
 
1429
   file=$2
 
1430
   done=false
 
1431
   while [ $done = false ]; do
 
1432
      $CLEAR
 
1433
      if [ "$hosttype" = "execd" ]; then
 
1434
         $INFOTEXT -u "\nAdding admin and submit hosts from file"
 
1435
      elif [ "$hosttype" = "submit" ]; then
 
1436
         $INFOTEXT -u "\nAdding submit hosts"
 
1437
      else
 
1438
         $INFOTEXT -u "\nAdding admin hosts from file"
 
1439
      fi
 
1440
      $INFOTEXT -n "\nPlease enter the file name which contains the host list: "
 
1441
      file=`Enter none`
 
1442
      if [ "$file" = "none" -o ! -f "$file" ]; then
 
1443
         $INFOTEXT "\nYou entered an invalid file name or the file does not exist."
 
1444
         $INFOTEXT -auto $autoinst -ask "y" "n" -def "y" -n \
 
1445
                   "Do you want to enter a new file name (y/n) [y] >> "
 
1446
         if [ $? = 1 ]; then
 
1447
            return 1
 
1448
         fi
 
1449
      else
 
1450
         if [ "$hosttype" = "execd" ]; then
 
1451
            for h in `cat $file`; do
 
1452
               $SGE_BIN/qconf -ah $h
 
1453
               $SGE_BIN/qconf -as $h
 
1454
            done
 
1455
         elif [ "$hosttype" = "submit" ]; then
 
1456
            for h in $hlist; do
 
1457
               $SGE_BIN/qconf -as $h
 
1458
               CERT_COPY_HOST_LIST="$CERT_COPY_HOST_LIST $h" 
 
1459
            done
 
1460
         else
 
1461
            for h in `cat $file`; do
 
1462
               $SGE_BIN/qconf -ah $h
 
1463
            done
 
1464
         fi
 
1465
         done=true
 
1466
      fi
 
1467
   done
 
1468
}
 
1469
 
 
1470
#-------------------------------------------------------------------------
 
1471
# AddHostsFromTerminal
 
1472
#    Get a list of hosts and add the mas admin and submit hosts
 
1473
#
 
1474
AddHostsFromTerminal()
 
1475
{
 
1476
   hosttype=$1
 
1477
   stop=false
 
1478
   while [ $stop = false ]; do
 
1479
      $CLEAR
 
1480
      if [ "$hosttype" = "execd" ]; then
 
1481
         $INFOTEXT -u "\nAdding admin and submit hosts"
 
1482
      elif [ "$hosttype" = "submit" ]; then
 
1483
         $INFOTEXT -u "\nAdding submit hosts"
 
1484
      else
 
1485
         $INFOTEXT -u "\nAdding admin hosts"
 
1486
      fi
 
1487
      $INFOTEXT "\nPlease enter a blank seperated list of hosts.\n\n" \
 
1488
                "Stop by entering <RETURN>. You may repeat this step until you are\n" \
 
1489
                "entering an empty list. You will see messages from Grid Engine\n" \
 
1490
                "when the hosts are added.\n"
 
1491
 
 
1492
      $INFOTEXT -n "Host(s): "
 
1493
 
 
1494
      hlist=`Enter ""`
 
1495
      if [ "$hosttype" = "execd" ]; then
 
1496
         for h in $hlist; do
 
1497
            $SGE_BIN/qconf -ah $h
 
1498
            $SGE_BIN/qconf -as $h
 
1499
         done
 
1500
      elif [ "$hosttype" = "submit" ]; then
 
1501
         for h in $hlist; do
 
1502
            $SGE_BIN/qconf -as $h
 
1503
            CERT_COPY_HOST_LIST="$CERT_COPY_HOST_LIST $h"
 
1504
         done
 
1505
      else
 
1506
         for h in $hlist; do
 
1507
            $SGE_BIN/qconf -ah $h
 
1508
         done
 
1509
      fi
 
1510
      if [ "$hlist" = "" ]; then
 
1511
         stop=true
 
1512
      else
 
1513
         $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
1514
      fi
 
1515
  done
 
1516
}
 
1517
 
 
1518
 
 
1519
#-------------------------------------------------------------------------
 
1520
# PrintHostGroup:  print an empty hostgroup
 
1521
#
 
1522
PrintHostGroup()
 
1523
{
 
1524
   $ECHO "group_name  $1"
 
1525
   $ECHO "hostlist    NONE"
 
1526
}
 
1527
 
 
1528
 
 
1529
#-------------------------------------------------------------------------
 
1530
# GetQmasterPort: get communication port SGE_QMASTER_PORT
 
1531
#
 
1532
GetQmasterPort()
 
1533
{
 
1534
 
 
1535
   if [ $RESPORT = true ]; then
 
1536
      comm_port_max=1023
 
1537
   else
 
1538
      comm_port_max=65500
 
1539
   fi
 
1540
    PortCollision $SGE_QMASTER_SRV
 
1541
    PortSourceSelect $SGE_QMASTER_SRV
 
1542
 
 
1543
   if [ "$SGE_QMASTER_PORT" != "" -a "$port_source" != "db" ]; then
 
1544
      $INFOTEXT -u "\nGrid Engine TCP/IP communication service"
 
1545
 
 
1546
      if [ $SGE_QMASTER_PORT -ge 1 -a $SGE_QMASTER_PORT -le $comm_port_max ]; then
 
1547
         $INFOTEXT "\nUsing the environment variable\n\n" \
 
1548
                   "   \$SGE_QMASTER_PORT=%s\n\n" \
 
1549
                     "as port for communication.\n\n" $SGE_QMASTER_PORT
 
1550
                      export SGE_QMASTER_PORT
 
1551
                      $INFOTEXT -log "Using SGE_QMASTER_PORT >%s<." $SGE_QMASTER_PORT
 
1552
         if [ "$collision_flag" = "services_only" -o "$collision_flag" = "services_env" ]; then
 
1553
            $INFOTEXT "This overrides the preset TCP/IP service >sge_qmaster<.\n"
 
1554
         fi
 
1555
         $INFOTEXT -auto $AUTO -ask "y" "n" -def "n" -n "Do you want to change the port number? (y/n) [n] >> "
 
1556
         if [ "$?" = 0 ]; then
 
1557
            EnterPortAndCheck $SGE_QMASTER_SRV
 
1558
         fi
 
1559
         $CLEAR
 
1560
         return
 
1561
      else
 
1562
         $INFOTEXT "\nThe environment variable\n\n" \
 
1563
                   "   \$SGE_QMASTER_PORT=%s\n\n" \
 
1564
                   "has an invalid value (it must be in range 1..%s).\n\n" \
 
1565
                   "Please set the environment variable \$SGE_QMASTER_PORT and restart\n" \
 
1566
                   "the installation or configure the service >sge_qmaster<." $SGE_QMASTER_PORT $comm_port_max
 
1567
         $INFOTEXT -log "Your \$SGE_QMASTER_PORT=%s\n\n" \
 
1568
                   "has an invalid value (it must be in range 1..%s).\n\n" \
 
1569
                   "Please check your configuration file and restart\n" \
 
1570
                   "the installation or configure the service >sge_qmaster<." $SGE_QMASTER_PORT $comm_port_max
 
1571
      fi
 
1572
   fi
 
1573
   $INFOTEXT -u "\nGrid Engine TCP/IP service >sge_qmaster<"
 
1574
   if [ "$port_source" = "env" ]; then
 
1575
      EnterPortAndCheck $SGE_QMASTER_SRV
 
1576
      $CLEAR
 
1577
   else
 
1578
      EnterServiceOrPortAndCheck $SGE_QMASTER_SRV
 
1579
      if [ "$port_source" = "db" ]; then
 
1580
         $INFOTEXT "\nUsing the service\n\n" \
 
1581
                   "   sge_qmaster\n\n" \
 
1582
                   "for communication with Grid Engine.\n"
 
1583
      fi
 
1584
      $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
1585
      $CLEAR
 
1586
   fi
 
1587
}
 
1588
 
 
1589
EnterServiceOrPortAndCheck()
 
1590
{
 
1591
   if [ "$1" = "sge_qmaster" ]; then
 
1592
      service_name="sge_qmaster"
 
1593
      port_var_name="SGE_QMASTER_PORT"
 
1594
   else
 
1595
      service_name="sge_execd"
 
1596
      port_var_name="SGE_EXECD_PORT"
 
1597
 
 
1598
   fi
 
1599
 
 
1600
      # Check if $SGE_SERVICE service is available now
 
1601
      service_available=false
 
1602
      done=false
 
1603
      while [ $done = false ]; do
 
1604
         CheckServiceAndPorts service $service_name
 
1605
         if [ $ret != 0 ]; then
 
1606
            $CLEAR
 
1607
            $INFOTEXT -u "\nNo TCP/IP service >%s< yet" $service_name
 
1608
            $INFOTEXT -n "\nIf you have just added the service it may take a while until the service\n" \
 
1609
                         "propagates in your network. If this is true we can again check for\n" \
 
1610
                         "the service >%s<. If you don't want to add this service or if\n" \
 
1611
                         "you want to install Grid Engine just for testing purposes you can enter\n" \
 
1612
                         "a port number.\n" $service_name
 
1613
 
 
1614
              if [ $AUTO != "true" ]; then
 
1615
                 $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n \
 
1616
                      "Check again (enter [n] to specify a port number) (y/n) [y] >> "
 
1617
                 ret=$?
 
1618
              else
 
1619
                 $INFOTEXT -log "Setting %s" $port_var_name
 
1620
                 ret=1
 
1621
              fi
 
1622
 
 
1623
            if [ $ret = 1 ]; then
 
1624
               if [ $AUTO = true ]; then
 
1625
                  $INFOTEXT -log "Please use an unused port number!"
 
1626
                  MoveLog
 
1627
                  exit 1
 
1628
               fi
 
1629
               $CLEAR
 
1630
               EnterAndValidatePortNumber $1
 
1631
               SelectedPortOutput $1
 
1632
               port_source="env"
 
1633
            fi
 
1634
         else
 
1635
            done=true
 
1636
            service_available=true
 
1637
         fi
 
1638
      done
 
1639
}
 
1640
 
 
1641
 
 
1642
EnterPortAndCheck()
 
1643
{
 
1644
 
 
1645
   if [ "$1" = "sge_qmaster" ]; then
 
1646
      service_name="sge_qmaster"
 
1647
      port_var_name="SGE_QMASTER_PORT"
 
1648
   else
 
1649
      service_name="sge_execd"
 
1650
      port_var_name="SGE_EXECD_PORT"
 
1651
 
 
1652
   fi
 
1653
      # Check if $SGE_SERVICE service is available now
 
1654
      done=false
 
1655
      while [ $done = false ]; do
 
1656
            $CLEAR
 
1657
            if [ $AUTO = true ]; then
 
1658
               $INFOTEXT -log "Please use an unused port number!"
 
1659
               MoveLog
 
1660
               exit 1
 
1661
            fi
 
1662
 
 
1663
            EnterAndValidatePortNumber $1
 
1664
            SelectedPortOutput $1
 
1665
      done
 
1666
   $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
1667
}
 
1668
 
 
1669
 
 
1670
SelectedPortOutput()
 
1671
{
 
1672
   if [ "$1" = "sge_qmaster" ]; then
 
1673
      SGE_QMASTER_PORT=$INP
 
1674
      $INFOTEXT "\nUsing the environment variable\n\n" \
 
1675
      "   \$SGE_QMASTER_PORT=%s\n\n" \
 
1676
      "as port for communication.\n\n" $SGE_QMASTER_PORT
 
1677
      export SGE_QMASTER_PORT
 
1678
      $INFOTEXT -log "Using SGE_QMASTER_PORT >%s<." $SGE_QMASTER_PORT
 
1679
   else
 
1680
      SGE_EXECD_PORT=$INP
 
1681
      $INFOTEXT "\nUsing the environment variable\n\n" \
 
1682
      "   \$SGE_EXECD_PORT=%s\n\n" \
 
1683
      "as port for communication.\n\n" $SGE_EXECD_PORT
 
1684
      export SGE_EXECD_PORT
 
1685
      $INFOTEXT -log "Using SGE_EXECD_PORT >%s<." $SGE_EXECD_PORT
 
1686
   fi
 
1687
}
 
1688
 
 
1689
 
 
1690
 
 
1691
EnterAndValidatePortNumber()
 
1692
{
 
1693
   $INFOTEXT -u "\nGrid Engine TCP/IP service >%s<\n" $service_name
 
1694
   $INFOTEXT -n "\n" 
 
1695
   $INFOTEXT -n "Please enter an unused port number >> "
 
1696
 
 
1697
   if [ "$1" = "sge_qmaster" ]; then
 
1698
      INP=`Enter $SGE_QMASTER_PORT`
 
1699
   else
 
1700
      INP=`Enter $SGE_EXECD_PORT`
 
1701
 
 
1702
      if [ "$INP" = "$SGE_QMASTER_PORT" -a $service_name = "sge_execd" ]; then
 
1703
         $INFOTEXT "Please use any other port number!!!"
 
1704
         $INFOTEXT "This %s port number is used by sge_qmaster" $SGE_QMASTER_PORT
 
1705
         if [ $AUTO = "true" ]; then
 
1706
            $INFOTEXT -log "Please use any other port number!!!"
 
1707
            $INFOTEXT -log "This %s port number is used by sge_qmaster" $SGE_QMASTER_PORT
 
1708
            $INFOTEXT -log "Installation failed!!!"
 
1709
            MoveLog
 
1710
            exit 1
 
1711
         fi
 
1712
      fi
 
1713
   fi
 
1714
 
 
1715
   chars=`echo $INP | wc -c`
 
1716
   chars=`expr $chars - 1`
 
1717
   digits=`expr $INP : "[0-9][0-9]*"`
 
1718
   if [ "$chars" != "$digits" ]; then
 
1719
      $INFOTEXT "\nInvalid input. Must be a number."
 
1720
   elif [ $INP -le 1 -o $INP -ge $comm_port_max ]; then
 
1721
      $INFOTEXT "\nInvalid port number. Must be in range [1..%s]." $comm_port_max
 
1722
   elif [ $INP -le 1024 -a $euid != 0 ]; then
 
1723
      $INFOTEXT "\nYou are not user >root<. You need to use a port above 1024."
 
1724
   else
 
1725
      CheckServiceAndPorts port ${INP}
 
1726
 
 
1727
      if [ $ret = 0 ]; then
 
1728
         $INFOTEXT "\nFound service with port number >%s< in >/etc/services<. Choose again." "$INP"
 
1729
      else
 
1730
         done=true
 
1731
      fi
 
1732
   fi
 
1733
   if [ $done = false ]; then
 
1734
      $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
1735
   fi
 
1736
}
 
1737
 
 
1738
 
 
1739
########################################################
 
1740
#
 
1741
# Version to convert a version string in X.Y.Z-* or
 
1742
# X.Y.X_NN format to XYZNN format so can be treated as a
 
1743
# number.
 
1744
#
 
1745
# $1 = version string
 
1746
# Returns numerical version
 
1747
#
 
1748
########################################################
 
1749
JavaVersionString2Num () {
 
1750
 
 
1751
   # Minor and micro default to 0 if not specified.
 
1752
   major=`echo $1 | awk -F. '{print $1}'`
 
1753
   minor=`echo $1 | awk -F. '{print $2}'`
 
1754
   if [ ! -n "$minor" ]; then
 
1755
      minor="0"
 
1756
   fi
 
1757
   micro=`echo $1 | awk -F. '{print $3}'`
 
1758
   if [ ! -n "$micro" ]; then
 
1759
      micro="0"
 
1760
   fi
 
1761
 
 
1762
   # The micro version may further be extended to include a patch number.
 
1763
   # This is typically of the form <micro>_NN, where NN is the 2-digit
 
1764
   # patch number.  However it can also be of the form <micro>-XX, where
 
1765
   # XX is some arbitrary non-digit sequence (eg., "rc").  This latter
 
1766
   # form is typically used for internal-only release candidates or
 
1767
   # development builds.
 
1768
   #
 
1769
   # For these internal builds, we drop the -XX and assume a patch number 
 
1770
   # of "00".  Otherwise, we extract that patch number.
 
1771
   #
 
1772
   patch="00"
 
1773
   dash=`echo $micro | grep "-"`
 
1774
   if [ $? -eq 0 ]; then
 
1775
      # Must be internal build, so drop the trailing variant.
 
1776
      micro=`echo $micro | awk -F- '{print $1}'`
 
1777
   fi
 
1778
 
 
1779
   underscore=`echo $micro | grep "_"`
 
1780
   if [ $? -eq 0 ]; then
 
1781
      # Extract the seperate micro and patch numbers, ignoring anything
 
1782
      # after the 2-digit patch.
 
1783
      patch=`echo $micro | awk -F_ '{print substr($2, 1, 2)}'`
 
1784
      micro=`echo $micro | awk -F_ '{print $1}'`
 
1785
   fi
 
1786
 
 
1787
   echo "${major}${minor}${micro}${patch}"
 
1788
 
 
1789
} # versionString2Num
 
1790
 
 
1791
 
 
1792
#---------------------------------------------------------------------------
 
1793
#  SetLibJvmPath
 
1794
#
 
1795
#     sets the env variable SGE_JVM_LIB_PATH
 
1796
SetLibJvmPath() {
 
1797
   
 
1798
   MIN_JAVA_VERSION=1.5.0
 
1799
   NUM_MIN_JAVA_VERSION=`JavaVersionString2Num $MIN_JAVA_VERSION`
 
1800
   
 
1801
   if [ "$JAVA_HOME" != "" ]; then
 
1802
      java_home=$JAVA_HOME
 
1803
   else
 
1804
      java_home=/usr/java
 
1805
   fi
 
1806
   
 
1807
   # set JRE_HOME 
 
1808
   isdone=false
 
1809
   while [ $isdone != true ]; do
 
1810
      $INFOTEXT -n "Please enter JAVA_HOME or press enter [%s] >> " "$java_home"
 
1811
      INP=`Enter $java_home`
 
1812
      if [ "$INP" = "" -a ! -x $INP/bin/java ]; then
 
1813
         $INFOTEXT "\nInvalid input. Must be a valid JAVA_HOME path."
 
1814
         continue
 
1815
      fi
 
1816
      if [ "$INP" = "" -o ! -x $INP/bin/java ]; then
 
1817
         $INFOTEXT "\nInvalid input. Must be a valid JAVA_HOME path."
 
1818
      else
 
1819
         java_home=$INP
 
1820
         isdone=true
 
1821
      fi
 
1822
   done
 
1823
   
 
1824
   if [ -d $java_home/jre ]; then
 
1825
      java_home=$java_home/jre
 
1826
   fi
 
1827
 
 
1828
   JAVA_VERSION=`$java_home/bin/java -version 2>&1 | head -1`
 
1829
   JAVA_VERSION=`echo $JAVA_VERSION | awk '{print $3}' | sed -e "s/\"//g"`
 
1830
   NUM_JAVA_VERSION=`JavaVersionString2Num $JAVA_VERSION`
 
1831
   
 
1832
   if [ $NUM_JAVA_VERSION -lt $NUM_MIN_JAVA_VERSION ]; then
 
1833
      $INFOTEXT "Warning: Cannot start jvm thread: Invalid java version (%s)), we need %s or higher" $JAVA_VERSION $MIN_JAVA_VERSION
 
1834
      return 1
 
1835
   fi
 
1836
   
 
1837
   case $ARCH in
 
1838
      sol-sparc64) 
 
1839
         jvm_lib_path=$java_home/lib/sparcv9/server/libjvm.so
 
1840
         ;;
 
1841
      sol-amd64)   
 
1842
         jvm_lib_path=$java_home/lib/amd64/server/libjvm.so
 
1843
         ;;
 
1844
      sol-x86)     
 
1845
         #causes a SEGV of libjvm.so for JVM_RawMonitorCreate
 
1846
         #jvm_lib_path=$java_home/lib/i386/server/libjvm.so
 
1847
         jvm_lib_path=$java_home/lib/i386/client/libjvm.so
 
1848
         ;;
 
1849
      lx*-amd64)   
 
1850
         jvm_lib_path=$java_home/lib/amd64/server/libjvm.so
 
1851
         ;;
 
1852
      lx*-x86)     
 
1853
         jvm_lib_path=$java_home/lib/i386/server/libjvm.so
 
1854
         ;;
 
1855
      darwin-ppc)
 
1856
         jvm_lib_path=$java_home/../Libraries/libjvm.dylib
 
1857
         ;;
 
1858
      darwin-x86)  
 
1859
         jvm_lib_path=$java_home/../Libraries/libjvm.dylib
 
1860
         ;;
 
1861
      *) 
 
1862
         $INFOTEXT "Warning: Cannot start jvm thread: Have no java support for $ARCH"
 
1863
         return 1
 
1864
         ;;
 
1865
   esac
 
1866
   
 
1867
   if [ ! -f "$jvm_lib_path" ]; then
 
1868
      jvm_lib_path=""
 
1869
      $INFOTEXT "\nWarning: Cannot start jvm thread: jvm library %s not found" "$jvm_lib_path"
 
1870
      return 1
 
1871
   fi
 
1872
   if [ "$JAVA_HOME" = "" ]; then
 
1873
      JAVA_HOME=$java_home
 
1874
   fi
 
1875
   export jvm_lib_path JAVA_HOME
 
1876
   return 0
 
1877
}
 
1878
 
 
1879
#---------------------------------------------------------------------------
 
1880
#  GetJMXPort
 
1881
#
 
1882
#     sets the env variable SGE_LIBJVM_PATH, SGE_ADDITIONAL_JVM_ARGS, SGE_JMX_PORT
 
1883
#
 
1884
GetJMXPort() {
 
1885
 
 
1886
   if [ "$SGE_ENABLE_JMX" = "true" ]; then
 
1887
 
 
1888
      $INFOTEXT -u "\nGrid Engine JMX MBean server"
 
1889
 
 
1890
      jmx_port_min=1
 
1891
      jmx_port_max=65500
 
1892
 
 
1893
      if [ $AUTO = "true" ]; then
 
1894
 
 
1895
            if [ ! -f "$SGE_JVM_LIB_PATH" ]; then
 
1896
               $INFOTEXT -log "\nWarning: Cannot start jvm thread: jvm library %s not found" "$SGE_JVM_LIB_PATH"
 
1897
               MoveLog
 
1898
               exit 1
 
1899
            else   
 
1900
               $INFOTEXT -log "\nUsing jvm library >%s<" "$SGE_JVM_LIB_PATH"
 
1901
            fi
 
1902
 
 
1903
            if [ "$SGE_JMX_PORT" != "" ]; then
 
1904
               if [ $SGE_JMX_PORT -ge $jmx_port_min -a $SGE_JMX_PORT -le $jmx_port_max ]; then
 
1905
                  $INFOTEXT -log "Using SGE_JMX_PORT >%s<." $SGE_JMX_PORT
 
1906
               else
 
1907
                  $INFOTEXT -log "Your \$SGE_JMX_PORT=%s\n\n" \
 
1908
                            "has an invalid value (it must be in range %s..%s).\n\n" \
 
1909
                            "Please check your configuration file and restart\n" \
 
1910
                            "the installation or configure the service >sge_qmaster<." $SGE_JMX_PORT $jmx_port_min $jmx_port_max
 
1911
                  MoveLog
 
1912
                  exit 1
 
1913
               fi
 
1914
            fi
 
1915
 
 
1916
            # if not set initialize to false
 
1917
            if [ "$SGE_JMX_SSL" = "" ]; then
 
1918
               SGE_JMX_SSL=false
 
1919
            fi
 
1920
            if [ "$SGE_JMX_SSL_CLIENT" = "" ]; then
 
1921
               SGE_JMX_SSL_CLIENT=false
 
1922
            fi
 
1923
      else
 
1924
 
 
1925
         # interactive setup
 
1926
 
 
1927
         sge_jvm_lib_path=""
 
1928
         sge_jmx_port=""
 
1929
         sge_additional_jvm_args="-Xmx256m"
 
1930
         sge_jmx_ssl=false
 
1931
         sge_jmx_ssl_client=false
 
1932
         sge_jxm_ssl_keystore=""
 
1933
         alldone=false
 
1934
         while [ $alldone = false ]; do
 
1935
 
 
1936
            $INFOTEXT -e "Please give some basic parameters for JMX MBean server\n" \
 
1937
            "We will ask for\n" \
 
1938
            "   - JAVA_HOME\n" \
 
1939
            "   - additional JVM arguments (optional)\n" \
 
1940
            "   - JMX MBean server port\n" \
 
1941
            "   - JMX ssl authentication\n" \
 
1942
            "   - JMX ssl client authentication\n" \
 
1943
            "   - JMX ssl server keystore path\n" \
 
1944
            "   - JMX ssl server keystore password\n"
 
1945
            
 
1946
            # set sge_jvm_lib_path
 
1947
            SetLibJvmPath
 
1948
            sge_jvm_lib_path=$jvm_lib_path
 
1949
 
 
1950
            # set SGE_ADDITIONAL_JVM_ARGS
 
1951
            $INFOTEXT -n "Please enter additional JVM arguments (optional, default is [%s]) >> " "$sge_additional_jvm_args"
 
1952
            INP=`Enter "$sge_additional_jvm_args"`
 
1953
            sge_additional_jvm_args="$INP"
 
1954
 
 
1955
            done=false
 
1956
            while [ $done != true ]; do
 
1957
               $INFOTEXT -n "Please enter an unused port number for the JMX MBean server >> "
 
1958
               INP=`Enter $sge_jmx_port`
 
1959
               if [ "$INP" = "" ]; then
 
1960
                  $INFOTEXT "\nInvalid input. Must be a number."
 
1961
                  continue
 
1962
               fi
 
1963
               chars=`echo $INP | wc -c`
 
1964
               chars=`expr $chars - 1`
 
1965
               digits=`expr $INP : "[0-9][0-9]*"`
 
1966
               if [ "$chars" != "$digits" ]; then
 
1967
                  $INFOTEXT "\nInvalid input. Must be a number."
 
1968
               elif [ $INP -lt $jmx_port_min -o $INP -gt $jmx_port_max ]; then
 
1969
                  $INFOTEXT "\nInvalid port number. Must be in range [%s..%s]." $jmx_port_min $jmx_port_max
 
1970
               elif [ $INP -le 1024 -a $euid != 0 ]; then
 
1971
                  $INFOTEXT "\nYou are not user >root<. You need to use a port above 1024."
 
1972
               else
 
1973
                  done=true
 
1974
               fi
 
1975
            done
 
1976
            sge_jmx_port=$INP
 
1977
 
 
1978
            # set SGE_JMX_SSL
 
1979
            $INFOTEXT -n -ask "y" "n" -def "y" \
 
1980
               "Enable JMX SSL server authentication (y/n) [y] >> "
 
1981
            if [ $? = 0 ]; then
 
1982
               sge_jmx_ssl="true"
 
1983
            else    
 
1984
               sge_jmx_ssl="false"
 
1985
            fi   
 
1986
 
 
1987
            if [ "$sge_jmx_ssl" = true ]; then
 
1988
               # set SGE_JMX_SSL_CLIENT
 
1989
               $INFOTEXT -n -ask "y" "n" -def "y" \
 
1990
                  "Enable JMX SSL client authentication (y/n) [y] >> "
 
1991
               if [ $? = 0 ]; then
 
1992
                  sge_jmx_ssl_client="true"
 
1993
               else    
 
1994
                  sge_jmx_ssl_client="false"
 
1995
               fi   
 
1996
 
 
1997
               # set SGE_JMX_SSL_KEYSTORE
 
1998
               if [ "$SGE_QMASTER_PORT" != "" ]; then
 
1999
                  ca_port=port$SGE_QMASTER_PORT
 
2000
               else
 
2001
                  ca_port=sge_qmaster
 
2002
               fi
 
2003
               if [ "$sge_jmx_ssl_keystore" = "" ]; then 
 
2004
                  sge_jmx_ssl_keystore=/var/sgeCA/$ca_port/$SGE_CELL/private/keystore
 
2005
               fi
 
2006
               $INFOTEXT -n "Enter JMX SSL server keystore path [%s] >> " "$sge_jmx_ssl_keystore"
 
2007
               INP=`Enter "$sge_jmx_ssl_keystore"`
 
2008
               sge_jmx_ssl_keystore="$INP"
 
2009
 
 
2010
               # set SGE_JMX_SSL_KEYSTORE_PW
 
2011
               sge_jmx_ssl_keystore_pw=""
 
2012
               STTY_ORGMODE=`stty -g`
 
2013
               $INFOTEXT -n "Enter JMX SSL server keystore pw >> "
 
2014
               stty -echo
 
2015
               INP=`Enter "$sge_jmx_ssl_keystore_pw"`
 
2016
               sge_jmx_ssl_keystore_pw="$INP"
 
2017
               stty "$STTY_ORGMODE"
 
2018
               # echo $sge_jmx_ssl_keystore_pw
 
2019
 
 
2020
            fi
 
2021
 
 
2022
            # show all parameters and redo if needed
 
2023
            $INFOTEXT "\nUsing the following JMX MBean server settings."
 
2024
            $INFOTEXT "   libjvm_path              >%s<" "$sge_jvm_lib_path"
 
2025
            $INFOTEXT "   Additional JVM arguments >%s<" "$sge_additional_jvm_args"
 
2026
            $INFOTEXT "   JMX port                 >%s<" "$sge_jmx_port"
 
2027
            $INFOTEXT "   JMX ssl                  >%s<" "$sge_jmx_ssl"
 
2028
            $INFOTEXT "   JMX client ssl           >%s<" "$sge_jmx_ssl_client"
 
2029
            $INFOTEXT "   JMX server keystore      >%s<" "$sge_jmx_ssl_keystore"
 
2030
            obfuscated_pw=`echo "$sge_jmx_ssl_keystore_pw" | sed 's/./*/g'`
 
2031
            $INFOTEXT "   JMX server keystore pw   >%s<" "$obfuscated_pw"
 
2032
            $INFOTEXT "\n"
 
2033
 
 
2034
            $INFOTEXT -ask "y" "n" -def "y" -n \
 
2035
               "Do you want to use these data (y/n) [y] >> "
 
2036
            if [ $? = 0 ]; then
 
2037
               alldone=true
 
2038
               SGE_JVM_LIB_PATH=$sge_jvm_lib_path
 
2039
               SGE_ADDITIONAL_JVM_ARGS=$sge_additional_jvm_args
 
2040
               SGE_JMX_PORT=$sge_jmx_port
 
2041
               SGE_JMX_SSL=$sge_jmx_ssl
 
2042
               SGE_JMX_SSL_CLIENT=$sge_jmx_ssl_client
 
2043
               SGE_JMX_SSL_KEYSTORE=$sge_jmx_ssl_keystore
 
2044
               SGE_JMX_SSL_KEYSTORE_PW="$sge_jmx_ssl_keystore_pw"
 
2045
               export SGE_JVM_LIB_PATH SGE_JMX_PORT SGE_ADDITIONAL_JVM_ARGS SGE_ENABLE_JMX SGE_JMX_SSL SGE_JMX_SSL_CLIENT SGE_JMX_SSL_KEYSTORE SGE_JMX_SSL_KEYSTORE_PW
 
2046
            else
 
2047
               $CLEAR
 
2048
            fi
 
2049
         done
 
2050
      fi
 
2051
 
 
2052
      $INFOTEXT -wait -auto $AUTO -n "\nHit <RETURN> to continue >> "
 
2053
      $CLEAR
 
2054
 
 
2055
   fi
 
2056
 
 
2057
}
 
2058
 
 
2059
 
 
2060
#-------------------------------------------------------------------------
 
2061
# GetExecdPort: get communication port SGE_EXECD_PORT
 
2062
#
 
2063
GetExecdPort()
 
2064
{
 
2065
 
 
2066
    if [ $RESPORT = true ]; then
 
2067
       comm_port_max=1023
 
2068
    else
 
2069
       comm_port_max=65500
 
2070
    fi
 
2071
 
 
2072
    PortCollision $SGE_EXECD_SRV
 
2073
    PortSourceSelect $SGE_EXECD_SRV
 
2074
    if [ "$SGE_EXECD_PORT" != "" -a "$port_source" != "db" ]; then
 
2075
      $INFOTEXT -u "\nGrid Engine TCP/IP communication service"
 
2076
 
 
2077
      if [ $SGE_EXECD_PORT -ge 1 -a $SGE_EXECD_PORT -le $comm_port_max ]; then
 
2078
         $INFOTEXT "\nUsing the environment variable\n\n" \
 
2079
                   "   \$SGE_EXECD_PORT=%s\n\n" \
 
2080
                     "as port for communication.\n\n" $SGE_EXECD_PORT
 
2081
                      export SGE_EXECD_PORT
 
2082
                      $INFOTEXT -log "Using SGE_EXECD_PORT >%s<." $SGE_EXECD_PORT
 
2083
         if [ "$collision_flag" = "services_only" -o "$collision_flag" = "services_env" ]; then
 
2084
            $INFOTEXT "This overrides the preset TCP/IP service >sge_execd<.\n"
 
2085
         fi
 
2086
         $INFOTEXT -auto $AUTO -ask "y" "n" -def "n" -n "Do you want to change the port number? (y/n) [n] >> "
 
2087
         if [ "$?" = 0 ]; then
 
2088
            EnterPortAndCheck $SGE_EXECD_SRV 
 
2089
         fi
 
2090
         $CLEAR
 
2091
         return
 
2092
      else
 
2093
         $INFOTEXT "\nThe environment variable\n\n" \
 
2094
                   "   \$SGE_EXECD_PORT=%s\n\n" \
 
2095
                   "has an invalid value (it must be in range 1..%s).\n\n" \
 
2096
                   "Please set the environment variable \$SGE_EXECD_PORT and restart\n" \
 
2097
                   "the installation or configure the service >sge_execd<." $SGE_EXECD_PORT $comm_port_max
 
2098
         $INFOTEXT -log "Your \$SGE_EXECD_PORT=%s\n\n" \
 
2099
                   "has an invalid value (it must be in range 1..%s).\n\n" \
 
2100
                   "Please check your configuration file and restart\n" \
 
2101
                   "the installation or configure the service >sge_execd<." $SGE_EXECD_PORT $comm_port_max
 
2102
      fi
 
2103
   fi         
 
2104
      $INFOTEXT -u "\nGrid Engine TCP/IP communication service "
 
2105
   if [ "$port_source" = "env" ]; then
 
2106
 
 
2107
         $INFOTEXT "Make sure to use a different port number for the execution host\n" \
 
2108
                   "as on the qmaster machine\n"
 
2109
         if [ `$SGE_UTILBIN/getservbyname $SGE_QMASTER_SRV 2>/dev/null | wc -w` = 0 -a "$SGE_QMASTER_PORT" != "" ]; then
 
2110
            $INFOTEXT "The qmaster port SGE_QMASTER_PORT = %s\n" $SGE_QMASTER_PORT
 
2111
         elif [ `$SGE_UTILBIN/getservbyname sge_qmaster 2>/dev/null | wc -w` != 0 -a "$SGE_QMASTER_PORT" = "" ]; then
 
2112
            $INFOTEXT "sge_qmaster service set to port %s\n" `$SGE_UTILBIN/getservbyname $SGE_QMASTER_SRV | cut -d" " -f2`
 
2113
         else 
 
2114
            $INFOTEXT "The qmaster port SGE_QMASTER_PORT = %s" $SGE_QMASTER_PORT
 
2115
            $INFOTEXT "sge_qmaster service set to port %s\n" `$SGE_UTILBIN/getservbyname $SGE_QMASTER_SRV | cut -d" " -f2`
 
2116
         fi 
 
2117
         $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
2118
 
 
2119
      # Check if $SGE_SERVICE service is available now
 
2120
      EnterPortAndCheck $SGE_EXECD_SRV
 
2121
      $CLEAR
 
2122
   else
 
2123
      EnterServiceOrPortAndCheck $SGE_EXECD_SRV
 
2124
      if [ "$service_available" = "true" ]; then
 
2125
         $INFOTEXT "\nUsing the service\n\n" \
 
2126
                   "   sge_execd\n\n" \
 
2127
                   "for communication with Grid Engine.\n"
 
2128
      fi
 
2129
      $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
2130
      $CLEAR
 
2131
   fi
 
2132
}
 
2133
 
 
2134
 
 
2135
#-------------------------------------------------------------------------
 
2136
# GetDefaultDomain
 
2137
#
 
2138
GetDefaultDomain()
 
2139
{
 
2140
   done=false
 
2141
 
 
2142
   if [ $AUTO = "true" ]; then
 
2143
      $INFOTEXT -log "Using >%s< as default domain." $DEFAULT_DOMAIN
 
2144
      CFG_DEFAULT_DOMAIN=$DEFAULT_DOMAIN
 
2145
      done=true
 
2146
   fi
 
2147
 
 
2148
   while [ $done = false ]; do
 
2149
      $CLEAR
 
2150
      $INFOTEXT -u "\nDefault domain for hostnames"
 
2151
 
 
2152
      $INFOTEXT "\nSometimes the primary hostname of machines returns the short hostname\n" \
 
2153
                  "without a domain suffix like >foo.com<.\n\n" \
 
2154
                  "This can cause problems with getting load values of your execution hosts.\n" \
 
2155
                  "If you are using DNS or you are using domains in your >/etc/hosts< file or\n" \
 
2156
                  "your NIS configuration it is usually safe to define a default domain\n" \
 
2157
                  "because it is only used if your execution hosts return the short hostname\n" \
 
2158
                  "as their primary name.\n\n" \
 
2159
                  "If your execution hosts reside in more than one domain, the default domain\n" \
 
2160
                  "parameter must be set on all execution hosts individually.\n"
 
2161
 
 
2162
      $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n \
 
2163
                "Do you want to configure a default domain (y/n) [y] >> "
 
2164
      if [ $? = 0 ]; then
 
2165
         $INFOTEXT -n "\nPlease enter your default domain >> "
 
2166
         CFG_DEFAULT_DOMAIN=`Enter ""`
 
2167
         if [ "$CFG_DEFAULT_DOMAIN" != "" ]; then
 
2168
            $INFOTEXT -wait -auto $AUTO -n "\nUsing >%s< as default domain. Hit <RETURN> to continue >> " \
 
2169
                      $CFG_DEFAULT_DOMAIN
 
2170
            $CLEAR
 
2171
            done=true
 
2172
         fi
 
2173
      else
 
2174
         CFG_DEFAULT_DOMAIN=none
 
2175
         done=true
 
2176
      fi
 
2177
   done
 
2178
}
 
2179
 
 
2180
SetScheddConfig()
 
2181
{
 
2182
   $CLEAR
 
2183
 
 
2184
   $INFOTEXT -u "Scheduler Tuning"
 
2185
   $INFOTEXT -n "\nThe details on the different options are described in the manual. \n"
 
2186
   done="false"
 
2187
 
 
2188
   while [ $done = "false" ]; do
 
2189
      $INFOTEXT -u "Configurations"
 
2190
      $INFOTEXT -n "1) Normal\n          Fixed interval scheduling, report limited scheduling information,\n" \
 
2191
                   "          actual + assumed load\n"
 
2192
      $INFOTEXT -n "2) High\n          Fixed interval scheduling, report limited scheduling information,\n" \
 
2193
                   "          actual load\n"
 
2194
      $INFOTEXT -n "3) Max\n          Immediate Scheduling, report no scheduling information,\n" \
 
2195
                   "          actual load\n"
 
2196
 
 
2197
      $INFOTEXT -auto $AUTO -n "Enter the number of your preferred configuration and hit <RETURN>! \n" \
 
2198
                   "Default configuration is [1] >> "
 
2199
      SCHEDD=`Enter 1`
 
2200
 
 
2201
      if [ $AUTO = "false" ]; then
 
2202
         SCHEDD_CONF=$SCHEDD
 
2203
      fi
 
2204
 
 
2205
      if [ $SCHEDD_CONF = "1" ]; then
 
2206
         is_selected="Normal"
 
2207
      elif [ $SCHEDD_CONF = "2" ]; then
 
2208
         is_selected="High"
 
2209
      elif [ $SCHEDD_CONF = "3" ]; then
 
2210
         is_selected="Max"
 
2211
      else
 
2212
         SCHEDD_CONF=1
 
2213
         is_selected="Normal"
 
2214
      fi
 
2215
 
 
2216
      $INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n "\nWe're configuring the scheduler with >%s< settings!\n Do you agree? (y/n) [y] >> " $is_selected
 
2217
      if [ $? = 0 ]; then
 
2218
         done="true"
 
2219
      fi
 
2220
   done
 
2221
 
 
2222
   if [ $AUTO = "true" ]; then
 
2223
      $INFOTEXT -log "Setting scheduler configuration to >%s< setting! " $is_selected
 
2224
   fi
 
2225
 
 
2226
   case $SCHEDD_CONF in
 
2227
 
 
2228
   1)
 
2229
    $SGE_BIN/qconf -Msconf ./util/install_modules/inst_schedd_normal.conf
 
2230
    ;;
 
2231
 
 
2232
   2)
 
2233
    $SGE_BIN/qconf -Msconf ./util/install_modules/inst_schedd_high.conf
 
2234
    ;;
 
2235
 
 
2236
   3)
 
2237
    $SGE_BIN/qconf -Msconf ./util/install_modules/inst_schedd_max.conf
 
2238
    ;;
 
2239
   esac
 
2240
   $CLEAR
 
2241
}
 
2242
 
 
2243
 
 
2244
GiveBerkelyHints()
 
2245
{
 
2246
  $INFOTEXT "If you are using a Berkely DB Server, please add the bdb_checkpoint.sh\n" \
 
2247
            "script to your crontab. This script is used for transaction\n" \
 
2248
            "checkpointing and cleanup in SGE installations with a\n" \
 
2249
            "Berkeley DB RPC Server. You will find this script in:\n" \
 
2250
            "$SGE_ROOT/util/\n\n" \
 
2251
            "It must be added to the crontab of the user (%s), who runs the\n" \
 
2252
            "berkeley_db_svc on the server host. \n\n" \
 
2253
            "e.g. * * * * * <full path to scripts> <sge-root dir> <sge-cell> <bdb-dir>\n" $ADMINUSER
 
2254
}
 
2255
 
 
2256
 
 
2257
WindowsSupport()
 
2258
{
 
2259
   $CLEAR
 
2260
   $INFOTEXT -u "Windows Execution Host Support"
 
2261
   $INFOTEXT -auto $AUTO -ask "y" "n" -def "n" -n "\nAre you going to install Windows Execution Hosts? (y/n) [n] >> "
 
2262
 
 
2263
   if [ $? = 0 ]; then
 
2264
      WINDOWS_SUPPORT=true
 
2265
      WindowsDomainUserAccess
 
2266
   fi
 
2267
}
 
2268
 
 
2269
 
 
2270
WindowsDomainUserAccess()
 
2271
{
 
2272
   $CLEAR
 
2273
   #The windows domain user access handling has changed -> WIN_DOMAIN_ACCESS always has to be true
 
2274
   #$INFOTEXT -u "Windows Domain User Access"
 
2275
   #$INFOTEXT -auto $AUTO -ask "y" "n" -def "y" -n "\nDo you want to use Windows Domain Users (answer: y)\n" \
 
2276
   #                                               "or are you going to use local Windows Users (answer: n) (y/n) [y] >> "
 
2277
   #if [ $? = 0 ]; then
 
2278
      WIN_DOMAIN_ACCESS=true
 
2279
   #fi
 
2280
}
 
2281
 
 
2282
 
 
2283
AddWindowsAdmin()
 
2284
{
 
2285
   if [ "$WINDOWS_SUPPORT" = "true" ]; then
 
2286
      $INFOTEXT -u "Windows Administrator Name"
 
2287
      $INFOTEXT "\nFor a later execution host installation it is recommended to add the\n" \
 
2288
                "Windows Administrator name to the SGE manager list\n"
 
2289
      $INFOTEXT -n "Please, enter the Windows Administrator name [Default: %s] >> " $WIN_ADMIN_NAME
 
2290
 
 
2291
      WIN_ADMIN_NAME=`Enter $WIN_ADMIN_NAME`
 
2292
 
 
2293
      $SGE_BIN/qconf -am $WIN_ADMIN_NAME
 
2294
      $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
 
2295
      $CLEAR
 
2296
   fi
 
2297
}
 
2298
 
 
2299
#-------------------------------------------------------------------------
 
2300
# PortCollision: Is there port collison for service, SGE_QMASTER or
 
2301
#                  SGE_EXECD
 
2302
PortCollision()
 
2303
{
 
2304
 
 
2305
   service=$1
 
2306
   # Call CheckPortsCollision conflict and depending on $ret, print out
 
2307
   # appropriate text
 
2308
 
 
2309
   CheckPortsCollision $service
 
2310
 
 
2311
   #$ECHO "collision_flag is $collision_flag \n"
 
2312
   $INFOTEXT -u "\nGrid Engine TCP/IP communication service"
 
2313
 
 
2314
   case "$collision_flag" in
 
2315
 
 
2316
      env_only)
 
2317
         $INFOTEXT "\nThe port for %s is currently set by the shell environment.\n\n" $service
 
2318
         if [ "$service" = "sge_qmaster" ]; then
 
2319
            $INFOTEXT "   SGE_QMASTER_PORT = %s" $SGE_QMASTER_PORT
 
2320
         else
 
2321
            $INFOTEXT "   SGE_EXECD_PORT = %s" $SGE_EXECD_PORT
 
2322
         fi
 
2323
         INP=1
 
2324
      ;;
 
2325
 
 
2326
      services_only)
 
2327
         $INFOTEXT "\nThe port for %s is currently set as service.\n" $service
 
2328
         if [ "$service" = "sge_qmaster" ]; then
 
2329
            $INFOTEXT "   sge_qmaster service set to port %s" `$SGE_UTILBIN/getservbyname $service | cut -d" " -f2` 
 
2330
         else
 
2331
            $INFOTEXT "   sge_execd service set to port %s" `$SGE_UTILBIN/getservbyname $service | cut -d" " -f2` 
 
2332
         fi
 
2333
         INP=2
 
2334
      ;;
 
2335
 
 
2336
      services_env)
 
2337
         $INFOTEXT "\nThe port for %s is curently set BOTH as service and by the\nshell environment\n" $service
 
2338
         if [ "$service" = "sge_qmaster" ]; then
 
2339
            $INFOTEXT "   SGE_QMASTER_PORT = %s" $SGE_QMASTER_PORT
 
2340
            $INFOTEXT "   sge_qmaster service set to port %s" `$SGE_UTILBIN/getservbyname $service | cut -d" " -f2` 
 
2341
         else
 
2342
            $INFOTEXT "   SGE_EXECD_PORT = %s" $SGE_EXECD_PORT
 
2343
            $INFOTEXT "   sge_execd service set to port %s" `$SGE_UTILBIN/getservbyname $service | cut -d" " -f2` 
 
2344
         fi
 
2345
         INP=1
 
2346
      ;;
 
2347
 
 
2348
      no_ports)
 
2349
         $INFOTEXT "\nThe communication settings for %s are currently not done.\n\n" $service
 
2350
         INP=1
 
2351
       ;;
 
2352
 
 
2353
   esac
 
2354
}
 
2355
 
 
2356
 
 
2357
PortSourceSelect()
 
2358
{
 
2359
   $INFOTEXT "\nNow you have the possibility to set/change the communication ports by using the\n>shell environment< or you may configure it via a network service, configured\nin local >/etc/service<, >NIS< or >NIS+<, adding an entry in the form\n\n"
 
2360
   $INFOTEXT "    %s <port_number>/tcp\n\n" $1
 
2361
   $INFOTEXT "to your services database and make sure to use an unused port number.\n\n"
 
2362
   $INFOTEXT -n "How do you want to configure the Grid Engine communication ports?\n\n"
 
2363
   $INFOTEXT "Using the >shell environment<:                           [1]\n"
 
2364
   $INFOTEXT -n "Using a network service like >/etc/service<, >NIS/NIS+<: [2]\n\n(default: %s) >> " $INP
 
2365
   #INP will be set in function: PortCollision, we need this as default value for auto install
 
2366
   INP=`Enter $INP`
 
2367
 
 
2368
   if [ "$INP" = "1" ]; then
 
2369
      port_source="env"
 
2370
   elif [ "$INP" = "2" ]; then
 
2371
      port_source="db"
 
2372
      if [ "$1" = "sge_qmaster" ]; then
 
2373
         unset SGE_QMASTER_PORT
 
2374
         export SGE_QMASTER_PORT
 
2375
      else
 
2376
         unset SGE_EXECD_PORT
 
2377
         export SGE_EXECD_PORT
 
2378
      fi
 
2379
   fi
 
2380
   
 
2381
   $CLEAR
 
2382
}