1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
|
#!/bin/sh
#
# SGE configuration script (Installation/Uninstallation/Upgrade/Downgrade)
# Scriptname: inst_execd_uninst.sh
#
#___INFO__MARK_BEGIN__
##########################################################################
#
# The Contents of this file are made available subject to the terms of
# the Sun Industry Standards Source License Version 1.2
#
# Sun Microsystems Inc., March, 2001
#
#
# Sun Industry Standards Source License Version 1.2
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.2 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2001 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
##########################################################################
#___INFO__MARK_END__
#
# set -x
WelcomeUninstall()
{
if [ $AUTO = true ]; then
return
fi
$INFOTEXT -u "Grid Engine uninstallation"
if [ "$ALL_EXECDS" = true ]; then
$INFOTEXT "\nYou are going to uninstall all execution hosts!\n" \
"If you are not sure what you are doing, than please stop\n" \
"this procedure with <CTRL-C>!\n"
else
$INFOTEXT "\nYou are going to uninstall a execution host %s!\n" \
"If you are not sure what you are doing, than please stop\n" \
"this procedure with <CTRL-C>!\n" $HOST
fi
$INFOTEXT -wait -n "\nHit <RETURN> to continue >> "
$CLEAR
}
FetchHostname()
{
HOSTS=""
euid=`$SGE_UTILBIN/uidgid -euid`
local_host=`$SGE_UTILBIN/gethostname -aname`
LOCAL_UNINST="false"
REMOTE_UNINST_ARGS=""
if [ $AUTO = "true" ]; then
tmp_local=""
tmp_host_list=""
for h in $EXEC_HOST_LIST_RM; do #set local_host to the end of the list. problem: on first pos the
if [ $h = "$local_host" ]; then #the local host will be removed from adminhost list, further
tmp_local=$h #host uninstallation won't work, due to missing permissions
else
tmp_host_list="$tmp_host_list $h"
fi
done
HOSTS="$tmp_host_list $tmp_local"
REMOTE_UNINST_ARGS="-auto $FILE"
else
HOSTS="$HOST"
fi
if [ "$ALL_EXECDS" = true ]; then
HOSTS=`qconf -sel`
fi
for h in $HOSTS; do
if [ "$NOREMOTE" = "true" -a "$h" = "$local_host" ]; then #only the local host (from RM list) should be uninstalled and
LOCAL_UNINST="true" #if actual host is equal to local host do uninstallation
doUninstall $h
break #break loop, if host found and uninstalled
fi
if [ "$NOREMOTE" = "false" ]; then #also uninstall remote hosts
if [ "$h" = "$local_host" ]; then #if actual host equals to local_host, no rsh/ssh is used for
LOCAL_UNINST="true" #uninstallation
doUninstall $h
else
$INFOTEXT -n "The uninstall script has to login to the uninstalled execution host %s\n" \
"Enter the shell name to be used (rsh/ssh) [%s] >>" $h $SHELL_NAME
SHELL_NAME=`Enter $SHELL_NAME`
SHELL_NAME=`echo "$SHELL_NAME" | tr [A-Z] [a-z]`
if [ "$SHELL_NAME" != "rsh" -a "$SHELL_NAME" != "ssh" ]; then
$INFOTEXT -n "Skipping uninstallation of exec host $host.\n"\
"Invalid shell name %s was selected." $SHELL_NAME
LOCAL_UNINST="false"
continue
fi
which $SHELL_NAME >/dev/null 2>&1
if [ $? -ne 0 ]; then
$INFOTEXT ">>%s<< is not on your PATH!" $SHELL_NAME
continue
fi
#h must be admin host
qconf -ah $h >/dev/null 2>&1
$SHELL_NAME $h "/bin/sh -c \"\
SGE_ROOT=$SGE_ROOT; export SGE_ROOT;\
SGE_CELL=$SGE_CELL; export SGE_CELL;\
SGE_REMOTE_FLAG=REMOTE_EXECD_UNINSTALL; export SGE_REMOTE_FLAG;\
cd $SGE_ROOT; ./inst_sge -ux $REMOTE_UNINST_ARGS\""
#In case we failed we better remove admin host
qconf -dh $h >/dev/null 2>&1
fi
LOCAL_UNINST="false" #reset LOCAL_UNINST variable for following uninstallations
fi
done
}
DisableQueue()
{
exechost=$1
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
$INFOTEXT "Disabling queue %s now" $q
$INFOTEXT -log "Disabling queue %s now" $q
qmod -d $q@$exechost
done
}
SuspendQueue()
{
exechost=$1
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
$INFOTEXT "Suspending queue %s now" $q
$INFOTEXT -log "Suspending queue %s now" $q
qmod -sq $q@$exechost
done
}
SuspendJobs()
{
exechost=$1
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
$INFOTEXT "Suspending Checkpointing Jobs on queue %s now!" $q
$INFOTEXT -log "Suspending Checkpointing Jobs on queue %s now!" $q
qmod -sj $q@$exechost
done
}
RescheduleJobs()
{
exechost=$1
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
$INFOTEXT "Rescheduling Jobs on queue %s now!" $q
$INFOTEXT -log "Rescheduling Jobs on queue %s now!" $q
qmod -r $q@$exechost
done
for q in `qstat -ne -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
$INFOTEXT "There are still running jobs on %s!" $q
$INFOTEXT -log "There are still running jobs on %s!" $q
$INFOTEXT "... trying to force a reschedule!"
$INFOTEXT -log "... trying to force a reschedule!"
qmod -f -r $q@$exechost
done
for q in `qstat -ne -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
$INFOTEXT "There are still running jobs on %s!" $q
$INFOTEXT -log "There are still running jobs on %s!" $q
$INFOTEXT "To make sure, that no date will be lost, the uninstall\n" \
"of this executionhost stops now!"
$INFOTEXT "Please, check the running jobs and run uninstall again!"
$INFOTEXT -log "To make sure, that no date will be lost, the uninstall\n" \
"of this executionhost stops now!"
$INFOTEXT -log "Please, check the running jobs and run uninstall again!"
break
done
}
RemoveQueues()
{
exechost=$1
for q in `qstat -F -l h=$exechost | grep qname | cut -d"=" -f2`; do
$INFOTEXT "Deleting queue %s!" $q
$INFOTEXT -log "Deleting queue %s!" $q
for hgrp in `qconf -shgrpl`; do
$SGE_BIN/qconf -dattr hostgroup hostlist $exechost $hgrp
done
done
}
RemoveExecd()
{
exechost=$1
$INFOTEXT "Removing exec host %s now!" $exechost
$INFOTEXT -log "Removing exec host %s now!" $exechost
qconf -ds $exechost
sleep 1
qconf -ke $exechost
sleep 1
qconf -de $exechost
sleep 1
qconf -dh $exechost
}
RemoveReferences()
{
exechost=$1
$INFOTEXT "Removing exec host references for host %s now!" $exechost
$INFOTEXT -log "Removing exec host references for host %s now!" $exechost
for q in `qconf -sql`; do
qconf -purge queue "*" "$q@$exechost"
done
}
RemoveSpoolDir()
{
exechost=$1
$INFOTEXT "Checking global spooldir configuration for host \"%s\"!" $exechost
$INFOTEXT -log "Checking global spooldir configuration for host \"%s\"!" $exechost
SPOOL_DIR=`qconf -sconf | grep execd_spool_dir | awk '{ print $2 }'`
HOST_DIR=`echo $exechost | tr "[A-Z]" "[a-z]"`
# Check global spool dir for execd host
if [ -d "$SPOOL_DIR/$HOST_DIR" ]; then
$INFOTEXT "Removing spool directory [%s]" $SPOOL_DIR/$HOST_DIR
$INFOTEXT -log "Removing spool directory [%s]" $SPOOL_DIR/$HOST_DIR
ExecuteAsAdmin rm -R $SPOOL_DIR/$HOST_DIR
if [ `ls -la $SPOOL_DIR | wc -l` -lt 4 ]; then
ExecuteAsAdmin rm -R $SPOOL_DIR
fi
fi
$INFOTEXT "Checking local spooldir configuration for host \"%s\"!" $exechost
$INFOTEXT -log "Checking local spooldir configuration for host \"%s\"!" $exechost
SPOOL_DIR=`qconf -sconf $exechost | grep execd_spool_dir | awk '{ print $2 }'`
$INFOTEXT "Delete configuration for host \"%s\"!" $exechost
$INFOTEXT -log "Delete configuration for host \"%s\"!" $exechost
qconf -dconf $exechost
if [ "$SPOOL_DIR" != "" ]; then
if [ -d "$SPOOL_DIR/$HOST_DIR" ]; then
$INFOTEXT "Removing local spool directory [%s]" "$SPOOL_DIR/$HOST_DIR"
$INFOTEXT -log "Removing local spool directory [%s]" "$SPOOL_DIR/$HOST_DIR"
ExecuteAsAdmin rm -R $SPOOL_DIR/$HOST_DIR
fi
fi
}
doUninstall() {
uhost=$1
qconf -se $uhost
ret=$?
if [ $ret = 0 ]; then
$INFOTEXT "Removing execution host %s now!" $uhost
$INFOTEXT -log "Removing execution host %s now!" $uhost
$INFOTEXT "Disabling queues now!"
$INFOTEXT -log "Disabling queues now!"
DisableQueue $uhost
SuspendQueue $uhost
SuspendJobs $uhost
RescheduleJobs $uhost
RemoveQueues $uhost
RemoveSpoolDir $uhost
RemoveReferences $uhost
RemoveExecd $uhost
RemoveRcScript $uhost execd $euid
else
$INFOTEXT "%s is not an execution host" $uhost
$INFOTEXT -log "%s is not an execution host" $uhost
fi
}
|