3
# SGE configuration script (Installation/Uninstallation/Upgrade/Downgrade)
4
# Scriptname: inst_execd_uninst.sh
7
##########################################################################
9
# The Contents of this file are made available subject to the terms of
10
# the Sun Industry Standards Source License Version 1.2
12
# Sun Microsystems Inc., March, 2001
15
# Sun Industry Standards Source License Version 1.2
16
# =================================================
17
# The contents of this file are subject to the Sun Industry Standards
18
# Source License Version 1.2 (the "License"); You may not use this file
19
# except in compliance with the License. You may obtain a copy of the
20
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
22
# Software provided under this License is provided on an "AS IS" basis,
23
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
24
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
25
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
26
# See the License for the specific provisions governing your rights and
27
# obligations concerning the Software.
29
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
31
# Copyright: 2001 by Sun Microsystems, Inc.
33
# All Rights Reserved.
35
##########################################################################
42
if [ $AUTO = true ]; then
46
$INFOTEXT -u "Grid Engine uninstallation"
47
if [ "$ALL_EXECDS" = true ]; then
48
$INFOTEXT "\nYou are going to uninstall all execution hosts!\n" \
49
"If you are not sure what you are doing, than please stop\n" \
50
"this procedure with <CTRL-C>!\n"
52
$INFOTEXT "\nYou are going to uninstall a execution host %s!\n" \
53
"If you are not sure what you are doing, than please stop\n" \
54
"this procedure with <CTRL-C>!\n" $HOST
57
$INFOTEXT -wait -n "\nHit <RETURN> to continue >> "
64
euid=`$SGE_UTILBIN/uidgid -euid`
65
local_host=`$SGE_UTILBIN/gethostname -aname`
69
if [ $AUTO = "true" ]; then
72
for h in $EXEC_HOST_LIST_RM; do #set local_host to the end of the list. problem: on first pos the
73
if [ $h = "$local_host" ]; then #the local host will be removed from adminhost list, further
74
tmp_local=$h #host uninstallation won't work, due to missing permissions
76
tmp_host_list="$tmp_host_list $h"
79
HOSTS="$tmp_host_list $tmp_local"
80
REMOTE_UNINST_ARGS="-auto $FILE"
85
if [ "$ALL_EXECDS" = true ]; then
90
if [ "$NOREMOTE" = "true" -a "$h" = "$local_host" ]; then #only the local host (from RM list) should be uninstalled and
91
LOCAL_UNINST="true" #if actual host is equal to local host do uninstallation
93
break #break loop, if host found and uninstalled
96
if [ "$NOREMOTE" = "false" ]; then #also uninstall remote hosts
97
if [ "$h" = "$local_host" ]; then #if actual host equals to local_host, no rsh/ssh is used for
98
LOCAL_UNINST="true" #uninstallation
101
$INFOTEXT -n "The uninstall script has to login to the uninstalled execution host %s\n" \
102
"Enter the shell name to be used (rsh/ssh) [%s] >>" $h $SHELL_NAME
103
SHELL_NAME=`Enter $SHELL_NAME`
104
SHELL_NAME=`echo "$SHELL_NAME" | tr [A-Z] [a-z]`
105
if [ "$SHELL_NAME" != "rsh" -a "$SHELL_NAME" != "ssh" ]; then
106
$INFOTEXT -n "Skipping uninstallation of exec host $host.\n"\
107
"Invalid shell name %s was selected." $SHELL_NAME
111
which $SHELL_NAME >/dev/null 2>&1
112
if [ $? -ne 0 ]; then
113
$INFOTEXT ">>%s<< is not on your PATH!" $SHELL_NAME
116
#h must be admin host
117
qconf -ah $h >/dev/null 2>&1
118
$SHELL_NAME $h "/bin/sh -c \"\
119
SGE_ROOT=$SGE_ROOT; export SGE_ROOT;\
120
SGE_CELL=$SGE_CELL; export SGE_CELL;\
121
SGE_REMOTE_FLAG=REMOTE_EXECD_UNINSTALL; export SGE_REMOTE_FLAG;\
122
cd $SGE_ROOT; ./inst_sge -ux $REMOTE_UNINST_ARGS\""
123
#In case we failed we better remove admin host
124
qconf -dh $h >/dev/null 2>&1
126
LOCAL_UNINST="false" #reset LOCAL_UNINST variable for following uninstallations
136
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
138
$INFOTEXT "Disabling queue %s now" $q
139
$INFOTEXT -log "Disabling queue %s now" $q
151
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
153
$INFOTEXT "Suspending queue %s now" $q
154
$INFOTEXT -log "Suspending queue %s now" $q
155
qmod -sq $q@$exechost
166
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
168
$INFOTEXT "Suspending Checkpointing Jobs on queue %s now!" $q
169
$INFOTEXT -log "Suspending Checkpointing Jobs on queue %s now!" $q
170
qmod -sj $q@$exechost
180
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
182
$INFOTEXT "Rescheduling Jobs on queue %s now!" $q
183
$INFOTEXT -log "Rescheduling Jobs on queue %s now!" $q
188
for q in `qstat -ne -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
190
$INFOTEXT "There are still running jobs on %s!" $q
191
$INFOTEXT -log "There are still running jobs on %s!" $q
192
$INFOTEXT "... trying to force a reschedule!"
193
$INFOTEXT -log "... trying to force a reschedule!"
194
qmod -f -r $q@$exechost
198
for q in `qstat -ne -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
200
$INFOTEXT "There are still running jobs on %s!" $q
201
$INFOTEXT -log "There are still running jobs on %s!" $q
202
$INFOTEXT "To make sure, that no date will be lost, the uninstall\n" \
203
"of this executionhost stops now!"
204
$INFOTEXT "Please, check the running jobs and run uninstall again!"
205
$INFOTEXT -log "To make sure, that no date will be lost, the uninstall\n" \
206
"of this executionhost stops now!"
207
$INFOTEXT -log "Please, check the running jobs and run uninstall again!"
217
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
219
$INFOTEXT "Deleting queue %s!" $q
220
$INFOTEXT -log "Deleting queue %s!" $q
222
for hgrp in `qconf -shgrpl`; do
223
$SGE_BIN/qconf -dattr hostgroup hostlist $exechost $hgrp
235
$INFOTEXT "Removing exec host %s now!" $exechost
236
$INFOTEXT -log "Removing exec host %s now!" $exechost
254
$INFOTEXT "Removing exec host references for host %s now!" $exechost
255
$INFOTEXT -log "Removing exec host references for host %s now!" $exechost
257
for q in `qconf -sql`; do
258
qconf -purge queue "*" "$q@$exechost"
267
$INFOTEXT "Checking global spooldir configuration for host \"%s\"!" $exechost
268
$INFOTEXT -log "Checking global spooldir configuration for host \"%s\"!" $exechost
269
SPOOL_DIR=`qconf -sconf | grep execd_spool_dir | awk '{ print $2 }'`
270
HOST_DIR=`echo $exechost | tr "[A-Z]" "[a-z]"`
272
# Check global spool dir for execd host
273
if [ -d "$SPOOL_DIR/$HOST_DIR" ]; then
274
$INFOTEXT "Removing spool directory [%s]" $SPOOL_DIR/$HOST_DIR
275
$INFOTEXT -log "Removing spool directory [%s]" $SPOOL_DIR/$HOST_DIR
276
ExecuteAsAdmin rm -R $SPOOL_DIR/$HOST_DIR
278
if [ `ls -la $SPOOL_DIR | wc -l` -lt 4 ]; then
279
ExecuteAsAdmin rm -R $SPOOL_DIR
284
$INFOTEXT "Checking local spooldir configuration for host \"%s\"!" $exechost
285
$INFOTEXT -log "Checking local spooldir configuration for host \"%s\"!" $exechost
286
SPOOL_DIR=`qconf -sconf $exechost | grep execd_spool_dir | awk '{ print $2 }'`
288
$INFOTEXT "Delete configuration for host \"%s\"!" $exechost
289
$INFOTEXT -log "Delete configuration for host \"%s\"!" $exechost
290
qconf -dconf $exechost
292
if [ "$SPOOL_DIR" != "" ]; then
293
if [ -d "$SPOOL_DIR/$HOST_DIR" ]; then
294
$INFOTEXT "Removing local spool directory [%s]" "$SPOOL_DIR/$HOST_DIR"
295
$INFOTEXT -log "Removing local spool directory [%s]" "$SPOOL_DIR/$HOST_DIR"
296
ExecuteAsAdmin rm -R $SPOOL_DIR/$HOST_DIR
306
if [ $ret = 0 ]; then
307
$INFOTEXT "Removing execution host %s now!" $uhost
308
$INFOTEXT -log "Removing execution host %s now!" $uhost
309
$INFOTEXT "Disabling queues now!"
310
$INFOTEXT -log "Disabling queues now!"
314
RescheduleJobs $uhost
316
RemoveSpoolDir $uhost
317
RemoveReferences $uhost
319
RemoveRcScript $uhost execd $euid
321
$INFOTEXT "%s is not an execution host" $uhost
322
$INFOTEXT -log "%s is not an execution host" $uhost