From 3dcb89648d535dc139f43ffdf58dacc6e6992d91 Mon Sep 17 00:00:00 2001 From: luedeke Date: Mon, 21 Mar 2005 11:10:43 +0000 Subject: [PATCH] change link on bootpc for IOC --- App/scripts/bootlink | 77 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 App/scripts/bootlink diff --git a/App/scripts/bootlink b/App/scripts/bootlink new file mode 100755 index 0000000..44ac3f4 --- /dev/null +++ b/App/scripts/bootlink @@ -0,0 +1,77 @@ +#!/bin/sh +if [ $# -lt 2 ] || [ "$1" = "-?" ] +then + echo "using: $0 (|-) [ [...]]" + echo "change boot path for list of IOCs" + echo "if = \"-\" it shows the current links" + exit +fi +if [ "$1" = "-v" ];then echo "\$Header: /cvs/G/DRV/misc/App/scripts/bootlink,v 1.1 2005/03/21 11:10:43 luedeke Exp $";exit;fi +if [ -d /usr/oracle-9.2 ] ; then + export ORACLE_HOME=/usr/oracle-9.2 +else + export ORACLE_HOME=/usr/oracle-8.1.7 + export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH +fi +targetbase=$1 +if [ "$(chkslsbase.sh $targetbase)" = "" ] && [ "$targetbase" != "-" ] +then + echo -ne "first argument (\"$targetbase\") has to be one out of\n$SLSBASELIST\n" + exit +fi +shift +for ioc in $* +do + list=$(echo $( + $ORACLE_HOME/bin/sqlplus -s ssrm_public/pub01@psip0 << EOF + SET HEADING OFF; + SELECT BOOTPC,SLSBASE FROM SSRM.IOC_LASTBOOTED WHERE SYSTEM = '$ioc'; + EXIT + EOF + )) + if [ "$list" = "no rows selected" ] + then + echo "IOC $ioc not in bootinfo DB" + exit + fi + bootpc=$(echo $list|awk '{print $1}' ); + + slsbase=$(echo $list|awk '{print $2}'); + + #echo "BootPC=$bootpc" + if [ "$slsbase" = "$targetbase" ] + then + echo "according to bootinfo, IOC $ioc already has SLSBASE=$slsbase" + echo "continue anyway" + fi + old=$(ssh $bootpc readlink /ioc/$ioc) + if [ "-" = "$targetbase" ] + then + old=$(ssh $bootpc readlink /ioc/$ioc) + echo "link on $bootpc for $ioc is \"$old\"" + continue + fi + new="$targetbase/iocBoot/ioc/$ioc" + if [ "$old" = "$new" ] + then + echo "no operation: on $bootpc \"/ioc/$ioc\" already points to \"$old\"" + continue + fi + if [ -d "$new" ] + then + ssh $bootpc rm -f /ioc/$ioc + ssh $bootpc ln -s $new /ioc/$ioc + rep=$(ssh $bootpc readlink /ioc/$ioc) + if [ "$rep" = "$new" ] + then + echo "changed on $bootpc from \"$old\" to \"$new\"" + else + echo "ERROR: change on $bootpc from \"$old\" to \"$new\" failed" + echo "link points now to \"$req\". Check permissions:" + ssh $bootpc ls -l /ioc/$ioc + fi + else + echo "target dir \"$tdir\" does not exist" + continue + fi +done