Ticket #1571: inst_execd_auto.sh

File inst_execd_auto.sh, 14.0 KB (added by vuw_ecs_kevin, 3 years ago)

New file of execd install routines to go in util

Line 
1#!/bin/sh
2#
3# SGE configuration script (Installation/Uninstallation/Upgrade/Downgrade)
4# Scriptname: inst_common.sh
5# Module: common 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#  Portions of this software are Copyright (c) 2011 Univa Corporation
37#  Copyright (C) David Love 2011, 2012, University of Liverpool
38#
39##########################################################################
40#___INFO__MARK_END__
41
42#--------------------------------------------------------------------------
43# In initial attempts these two were added to inst_common.sh
44#--------------------------------------------------------------------------
45# CheckBinariesExecd
46#   An attempt to seperate out the master and execd binaries
47#
48CheckBinariesExecd()
49{
50
51   BINFILES_MSTR="sge_qmaster \
52             sge_shadowd"
53
54   BINFILES_EXEC="sge_execd \
55                  sge_coshepherd \
56                  sge_shepherd"
57
58   WARNBINFILES="qmake qmon"
59
60   BINFILES="qacct qalter qconf qdel qhold \
61             qhost qlogin qmod qresub qrls qrsh qselect qsh \
62             qstat qsub qtcsh qping qquota sgepasswd"
63
64   WINBINFILES="sge_coshepherd sge_execd sge_shepherd  \
65                qacct qalter qconf qdel qhold qhost qlogin \
66                qmake qmod qresub qrls qrsh qselect qsh \
67                qstat qsub qtcsh qping qquota qloadsensor.exe"
68
69   # This used to insist on rsh et al, but we're likely to build without,
70   # as they involve suid and we normally have SSH and PAM.
71   UTILFILES="adminrun checkprog checkuser filestat gethostbyaddr gethostbyname \
72              gethostname getservbyname loadcheck now qrsh_starter \
73              testsuidroot authuser uidgid infotext"
74
75   WINUTILFILES="SGE_Helper_Service.exe adminrun checkprog checkuser filestat \
76                 gethostbyaddr gethostbyname gethostname getservbyname loadcheck.exe \
77                 now qrsh_starter rlogin rsh rshd testsuidroot authuser.exe uidgid \
78                 infotext SGE_Starter.exe"
79
80   #SUIDFILES="rsh rlogin testsuidroot sgepasswd"
81
82   if [ "$SGE_ARCH" = "win32-x86" ]; then
83      BINFILES="$WINBINFILES"
84      UTILFILES="$WINUTILFILES"
85   fi
86
87   missing=false
88   for f in $BINFILES; do
89      if [ ! -f $SGE_BIN/$f ]; then
90         missing=true
91         $INFOTEXT "missing program >%s< in directory >%s<" $f $SGE_BIN
92         $INFOTEXT -log "missing program >%s< in directory >%s<" $f $SGE_BIN
93      fi
94   done
95
96   for f in $WARNBINFILES; do
97      if [ ! -f $SGE_BIN/$f ]; then
98         $INFOTEXT "missing program >%s< in directory >%s<" $f $SGE_BIN
99         $INFOTEXT "install will continue but some functionality may be missing"
100         $INFOTEXT -log "missing program >%s< in directory >%s<" $f $SGE_BIN
101         $INFOTEXT -log "install will continue but some functionality may be missing"
102      fi
103   done
104
105   if [ "$1" = "execd" ]; then
106# Only check EXECD binary files
107     for f in $BINFILES_EXEC; do
108        if [ ! -f $SGE_BIN/$f ]; then
109           missing=true
110           $INFOTEXT "missing program >%s< in directory >%s<" $f $SGE_BIN
111           $INFOTEXT -log "missing program >%s< in directory >%s<" $f $SGE_BIN
112        fi
113     done
114   else
115# Check EXECD and MSTR binary files to match original operation
116     for f in $BINFILES_MSTR; do
117        if [ ! -f $SGE_BIN/$f ]; then
118           missing=true
119           $INFOTEXT "missing program >%s< in directory >%s<" $f $SGE_BIN
120           $INFOTEXT -log "missing program >%s< in directory >%s<" $f $SGE_BIN
121        fi
122     done
123   fi
124
125   for f in $UTILFILES; do
126      if [ ! -f $SGE_UTILBIN/$f ]; then
127         missing=true
128         $INFOTEXT "missing program >%s< in directory >%s<" $f $SGE_UTILBIN
129         $INFOTEXT -log "missing program >%s< in directory >%s<" $f $SGE_UTILBIN
130      fi
131   done
132
133   if [ $missing = true ]; then
134      if [ "$SGE_ARCH" = "win32-x86" ]; then
135         $INFOTEXT "\nMissing Grid Engine binaries!\n\n" \
136         "A complete installation needs the following binaries in >%s<:\n\n" \
137         "qacct           qlogin          qrsh            sge_shepherd\n" \
138         "qalter          qmake           qselect         sge_coshepherd\n" \
139         "qconf           qmod            qsh             sge_execd\n" \
140         "qdel            qmon            qstat           qhold\n" \
141         "qresub          qsub            qhost           qrls\n" \
142         "qtcsh           qping           qquota          sgepasswd\n" \
143         "qloadsensor.exe\n\n" \
144         "and the binaries in >%s< should be:\n\n" \
145         "adminrun        gethostbyaddr  loadcheck.exe  rlogin         uidgid\n" \
146         "authuser.exe    checkprog      gethostbyname  now            rsh\n" \
147         "infotext        checkuser      gethostname    rshd\n" \
148         "filestat        getservbyname  qrsh_starter   testsuidroot   SGE_Helper_Service.exe\n" \
149         "SGE_Starter.exe\n\n" \
150         "Installation failed. Exit.\n" $SGE_BIN $SGE_UTILBIN
151      else
152         $INFOTEXT "\nMissing Grid Engine binaries!\n\n" \
153         "A complete installation needs the following binaries in >%s<:\n\n" \
154         "qacct           qlogin          qrsh            sge_shepherd\n" \
155         "qalter          qmake           qselect         sge_coshepherd\n" \
156         "qconf           qmod            qsh             sge_execd\n" \
157         "qdel            qmon            qstat           sge_qmaster\n" \
158         "qhold           qresub          qsub            qhost\n" \
159         "qrls            qtcsh           sge_shadowd     qping\n" \
160         "qquota\n\n" \
161         "and the binaries in >%s< should be:\n\n" \
162         "adminrun       gethostbyaddr  loadcheck      rlogin         uidgid\n" \
163         "authuser       checkprog      gethostbyname  now            rsh\n" \
164         "infotext       checkuser      gethostname    rshd\n" \
165         "filestat       getservbyname  qrsh_starter   testsuidroot\n\n" \
166         "Installation failed. Exit.\n" $SGE_BIN $SGE_UTILBIN
167      fi
168
169      $INFOTEXT -log "\nMissing Grid Engine binaries!\n\n" \
170      "A complete installation needs the following binaries in >%s<:\n\n" \
171      "qacct           qlogin          qrsh            sge_shepherd\n" \
172      "qalter          qmake           qselect         sge_coshepherd\n" \
173      "qconf           qmod            qsh             sge_execd\n" \
174      "qdel            qmon            qstat           sge_qmaster\n" \
175      "qhold           qresub          qsub            qhost\n" \
176      "qrls            qtcsh           sge_shadowd     qping\n" \
177      "qquota\n\n" \
178      "and the binaries in >%s< should be:\n\n" \
179      "adminrun       gethostbyaddr  loadcheck      rlogin         uidgid\n" \
180      "authuser       checkprog      gethostbyname  now            rsh\n" \
181      "infotext       checkuser      gethostname    rshd\n" \
182      "filestat       getservbyname  qrsh_starter   testsuidroot\n\n" \
183      "Installation failed. Exit.\n" $SGE_BIN $SGE_UTILBIN
184
185      MoveLog
186      exit 2 # ToDo: documentation, do not change, exit code used for hedeby
187   fi
188}
189
190
191PreInstallCheckExecd()
192{
193   if [ "$SGE_CHECK_BINARIES" != false ]; then
194      if [ $AUTO = "true" -a $QMASTER = "undef" -a $EXECD = "install" ]; then
195         CheckBinariesExecd execd
196      else
197         CheckBinariesExecd
198      fi
199   fi
200}
201
202#--------------------------------------------------------------------------
203# In initial attempts these were added to inst_execd.sh
204#--------------------------------------------------------------------------
205
206MakeDirsExecd()
207{
208   $INFOTEXT -u "\nMaking directories"
209   $ECHO
210   $INFOTEXT -log "Making directories"
211   $INFOTEXT -log "Making directory SGE_CELL_VAL: %s" $SGE_CELL_VAL
212   Makedir $SGE_CELL_VAL
213   $INFOTEXT -log "Making directory COMMONDIR: %s" $COMMONDIR
214   Makedir $COMMONDIR
215#   Makedir $QMDIR
216#   Makedir $QMDIR/job_scripts
217
218   $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
219   $CLEAR
220}
221
222
223AddBootstrapExecd()
224{
225   TOUCH=touch
226   $INFOTEXT "Dumping bootstrapping information"
227   $INFOTEXT -log "Dumping bootstrapping information"
228#   ExecuteAsAdmin rm -f $COMMONDIR/bootstrap
229   ExecuteAsAdmin $TOUCH $COMMONDIR/bootstrap
230   ExecuteAsAdmin chmod 666 $COMMONDIR/bootstrap
231   PrintBootstrapExecd >> $COMMONDIR/bootstrap
232   ExecuteAsAdmin chmod 444 $COMMONDIR/bootstrap
233}
234
235PrintBootstrapExecd()
236{
237   $ECHO "# Version: $SGE_VERSION"
238   $ECHO "#"
239   if [ $ADMINUSER != default ]; then
240      $ECHO "admin_user              $ADMINUSER"
241   else
242      $ECHO "admin_user              none"
243   fi
244   $ECHO "default_domain          $CFG_DEFAULT_DOMAIN"
245   $ECHO "ignore_fqdn             $IGNORE_FQDN_DEFAULT"
246   $ECHO "spooling_method         $SPOOLING_METHOD"
247   $ECHO "spooling_lib            $SPOOLING_LIB"
248   $ECHO "spooling_params         $SPOOLING_ARGS"
249   $ECHO "binary_path             $SGE_ROOT_VAL/bin"
250   $ECHO "qmaster_spool_dir       $QMDIR"
251   $ECHO "security_mode           $PRODUCT_MODE"
252   $ECHO "listener_threads        2"
253   $ECHO "worker_threads          2"
254   $ECHO "scheduler_threads       1"
255   if [ "$SGE_ENABLE_JMX" = "true" ]; then
256      $ECHO "jvm_threads             1"
257   else
258      $ECHO "jvm_threads             0"
259   fi
260}
261
262AddActQmasterExecd()
263{
264   $INFOTEXT "Creating >act_qmaster< file"
265
266   TruncCreateAndMakeWriteable $COMMONDIR/act_qmaster
267   $ECHO $QMASTER_HOSTNAME >> $COMMONDIR/act_qmaster
268   SetPerm $COMMONDIR/act_qmaster
269}
270
271AddCommonFilesExecd()
272{
273   for f in sge_aliases qtask sge_request; do
274      if [ $f = sge_aliases ]; then
275         $INFOTEXT "Adding >%s< path aliases file" $f
276         $INFOTEXT -log "Adding >%s< path aliases file" $f
277      elif [ $f = qtask ]; then
278         $INFOTEXT "Adding >%s< qtcsh sample default request file" $f
279         $INFOTEXT -log "Adding >%s< qtcsh sample default request file" $f
280      else
281         $INFOTEXT "Adding >%s< default submit options file" $f
282         $INFOTEXT -log "Adding >%s< default submit options file" $f
283      fi
284      ExecuteAsAdmin cp util/$f $COMMONDIR
285      ExecuteAsAdmin chmod $FILEPERM $COMMONDIR/$f
286   done
287
288}
289
290CreateSettingsFileExecd()
291{
292   $INFOTEXT "Creating settings files for >.profile/.cshrc<"
293   $INFOTEXT -log "Creating settings files for >.profile/.cshrc<"
294
295   if [ $RECREATE_SETTINGS = "false" ]; then
296      if [ -f "$SGE_ROOT/$SGE_CELL/common/settings.sh" ]; then
297         ExecuteAsAdmin $RM "$SGE_ROOT/$SGE_CELL/common/settings.sh"
298      fi
299 
300      if [ -f "$SGE_ROOT/$SGE_CELL/common/settings.csh" ]; then
301         ExecuteAsAdmin $RM "$SGE_ROOT/$SGE_CELL/common/settings.csh"
302      fi
303   fi
304
305   if [ "$execd_service" = "true" ]; then
306      SGE_EXECD_PORT=""
307      export SGE_EXECD_PORT
308   fi
309
310   if [ "$qmaster_service" = "true" ]; then
311      SGE_QMASTER_PORT=""
312      export SGE_QMASTER_PORT
313   fi
314
315   ExecuteAsAdmin util/create_settings.sh "$SGE_ROOT_VAL/$COMMONDIR"
316
317   SetPerm "$SGE_ROOT_VAL/$COMMONDIR/settings.sh"
318   SetPerm "$SGE_ROOT_VAL/$COMMONDIR/settings.csh"
319
320   $INFOTEXT -wait -auto $AUTO -n "\nHit <RETURN> to continue >> "
321}
322
323SetProductModeExecd()
324{
325   if [ $AFS = true ]; then
326      AFS_PREFIX="afs"
327   else
328      AFS_PREFIX=""
329   fi
330
331   if [ $CSP = true ]; then
332
333      case $SGE_ARCH in
334
335      aix* | hp11*)
336          SEC_COUNT=`strings -a $SGE_BIN/sge_qmaster | grep "AIMK_SECURE_OPTION_ENABLED" | wc -l`
337          ;;
338      *)
339          # strings(1) may not be installed (e.g. IZ2506).
340          if type strings >/dev/null 2>&1; then
341              SEC_COUNT=`strings $SGE_BIN/sge_qmaster | grep "AIMK_SECURE_OPTION_ENABLED" | wc -l`
342          else
343              # Do our best, but the results of grep on a binary are
344              # unspecified generally.
345              SEC_COUNT=0
346              grep AIMK_SECURE_OPTION_ENABLED $SGE_BIN/sge_qmaster >/dev/null 2>&1 &&
347                SEC_COUNT=1
348          fi
349          ;;
350      esac
351
352      if [ $SEC_COUNT -ne 1 ]; then
353         $INFOTEXT "\n>sge_qmaster< binary not compiled with >-secure< option (or strings(1) missing)!\n"
354         $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to cancel the installation >> "
355         exit 1
356      else
357         CSP_PREFIX="csp"
358      fi 
359   else
360      CSP_PREFIX=""
361   fi
362
363      if [ $AFS = "false" ]; then
364         if [ $CSP = "false" ]; then
365            PRODUCT_MODE="none"
366         else
367            PRODUCT_MODE="${CSP_PREFIX}"
368         fi
369      else
370         PRODUCT_MODE="${AFS_PREFIX}"
371      fi
372}
373
374ProcessSGEClusterNameExecd()
375{
376   # execd installation can create cluster_name file using this
377   if [  "$1" = "execd" ]; then
378       SafelyCreateFile "$SGE_ROOT"/$SGE_CELL/common/cluster_name 644 "$SGE_CLUSTER_NAME"
379   fi
380
381   $ECHO
382   $INFOTEXT "Your \$SGE_CLUSTER_NAME: %s\n" $SGE_CLUSTER_NAME
383   $INFOTEXT -log "Your \$SGE_CLUSTER_NAME: %s" $SGE_CLUSTER_NAME
384   $INFOTEXT -wait -auto $AUTO -n "Hit <RETURN> to continue >> "
385   $CLEAR
386}
387
388GetLocalExecdSpoolDirExecd()
389{
390    LOCAL_EXECD_SPOOL="undef"
391    if [ "$EXECD_SPOOL_DIR_LOCAL" != "" ]; then
392       LOCAL_EXECD_SPOOL=$EXECD_SPOOL_DIR_LOCAL
393    else
394        if [ "$EXECD_SPOOL_DIR" != "" ]; then
395            LOCAL_EXECD_SPOOL=$EXECD_SPOOL_DIR
396        fi
397    fi
398    if [ "$LOCAL_EXECD_SPOOL" != "undef" ]; then
399        MakeLocalSpoolDir
400    else
401        $INFOTEXT -log "No Local execd spool defined. Exit"
402        exit 3
403    fi
404}
405