Skip to content
Permalink
Browse files

Fix scripts that use well-known temp files.

  • Loading branch information...
BrendanCunningham committed Sep 16, 2015
1 parent 51c1195 commit 080ab97461d80a01636f77ba6aecc667c3c0087c
@@ -31,7 +31,9 @@
# [ICS VERSION STRING: unknown]
# copy a file to all hosts

trap "exit 1" SIGHUP SIGTERM SIGINT
temp="$(mktemp --tmpdir "opascpall.XXXXXX")"
trap "rm -f $temp; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $temp" EXIT

# optional override of defaults
if [ -f /etc/sysconfig/opa/opafastfabric.conf ]
@@ -43,7 +45,7 @@ fi

. /opt/opa/tools/ff_funcs

temp=/tmp/opascpall$$
temp=`mktemp`
trap "rm -f $temp" 1 2 3 9 15

Usage_full()
@@ -49,7 +49,7 @@ then
export FF_IPOIB_SUFFIX=""
fi

temp=/tmp/opatest$$
temp=`mktemp`
trap "rm -f $temp" 1 2 3 9 15

# identify how we are being run, affects valid options and usage
@@ -33,8 +33,9 @@

# disable the specified set of hosts

tempfile=/tmp/opadisablehosts$$
tempfile=`mktemp`
trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $tempfile" EXIT

Usage_full()
{
@@ -33,8 +33,9 @@

# reenable the specified set of ports

tempfile=/tmp/opaenableports$$
tempfile=`mktemp`
trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $tempfile" EXIT

# optional override of defaults
if [ -f /etc/sysconfig/opa/opafastfabric.conf ]
@@ -36,8 +36,9 @@
TOOLSDIR=${TOOLSDIR:-/opt/opa/tools}
BINDIR=${BINDIR:-/usr/sbin}

tempfile=/tmp/opaextractbadlinks$$
tempfile=`mktemp`
trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $tempfile" EXIT

Usage_full()
{
@@ -35,8 +35,9 @@
TOOLSDIR=${TOOLSDIR:-/opt/opa/tools}
BINDIR=${BINDIR:-/usr/sbin}

tempfile=/tmp/opaextractlids$$
tempfile=`mktemp`
trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $tempfile" EXIT

Usage_full()
{
@@ -36,8 +36,9 @@
TOOLSDIR=${TOOLSDIR:-/opt/opa/tools}
BINDIR=${BINDIR:-/usr/sbin}

tempfile=/tmp/opaextractsellinks$$
tempfile=`mktemp`
trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $tempfile" EXIT

Usage_full()
{
@@ -32,8 +32,9 @@

# start and stop HFI-SW and/or ISL cable Bit Error Rate tests

tempfile=/tmp/opacabletest$$
tempfile=`mktemp`
trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $tempfile" EXIT

# optional override of defaults
if [ -f /etc/sysconfig/opa/opafastfabric.conf ]
@@ -39,9 +39,6 @@
# information obtained via opareport -o links (live fabric or snapshot).


## Includes
trap "exit 1" SIGHUP SIGTERM SIGINT

# optional override of defaults
if [ -f /etc/sysconfig/opa/opafastfabric.conf ]
then
@@ -160,6 +157,9 @@ clean_files()
fi
} # End of clean_files()

trap 'clean_files; exit 1' SIGINT SIGHUP SIGTERM
trap clean_files EXIT

Usage_full()
{
echo "Usage: opagenswitches [-t portsfile] [-p ports] [-R]" >&2
@@ -221,7 +221,6 @@ Usage()
echo "for example:" >&2
echo " opagenswitches" >&2
echo " opagenswitches -T topology.0:0.xml" >&2
clean_files
exit 2
} # End of Usage()

@@ -32,8 +32,9 @@

# analyzes all the links in the fabric

tempfile=/tmp/opalinkanalysis$$
tempfile=`mktemp`
trap "rm -f $tempfile; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $tempfile" EXIT

# optional override of defaults
if [ -f /etc/sysconfig/opa/opafastfabric.conf ]
@@ -366,8 +366,7 @@ fwUpdate)
else
fn=$fileNameArg
fi
tmpdir=/tmp/12200FW$$
mkdir $tmpdir
tmpdir=`mktemp -d`
cd $tmpdir
tar xzf $fn > /dev/null 2>&1

@@ -220,6 +220,23 @@ debug_6=
debug_7=
#echo "DEBUG-x.y: 0:$debug_0: 1:$debug_1: 2:$debug_2: 3:$debug_3: 4:$debug_4: 5:$debug_5: 6:$debug_6: 7:$debug_7:"

function clean_tempfiles() {
if [ $fl_clean == 1 ]
then
rm -f $FILE_TEMP
rm -f $FILE_TEMP2
rm -f $FILE_LINKSUM
rm -f $FILE_LINKSUM_NOCORE
rm -f $FILE_LINKSUM_NOCABLE
rm -f $FILE_NODEFIS
rm -f $FILE_NODESWITCHES
rm -f $FILE_NODELEAVES
rm -f $FILE_NODECHASSIS
fi
}

trap 'clean_tempfiles; exit 1' SIGINT SIGHUP SIGTERM
trap 'clean_tempfiles' EXIT

## Local functions:
functout=
@@ -400,18 +417,7 @@ gen_topology()
echo "</Report>" >> $FILE_TOPOLOGY_OUT

# Clean temporary files
if [ $fl_clean == 1 ]
then
rm -f $FILE_TEMP
rm -f $FILE_TEMP2
rm -f $FILE_LINKSUM
rm -f $FILE_LINKSUM_NOCORE
rm -f $FILE_LINKSUM_NOCABLE
rm -f $FILE_NODEFIS
rm -f $FILE_NODESWITCHES
rm -f $FILE_NODELEAVES
rm -f $FILE_NODECHASSIS
fi
clean_tempfiles
} # End of gen_topology

# Process rack group name; check for non-null name and find in tb_group[].
@@ -593,9 +599,6 @@ proc_switch()

## Main function:

rm -f $FILE_DEBUG
rm -f $FILE_DEBUG2

# Get options
while getopts c:d:i:Kv:? option
do
@@ -177,6 +177,16 @@ debug_7=
## Local functions:
functout=

function clean_tempfiles() {
if [ $fl_clean == 1 ]
then
rm -f $FILE_TEMP $FILE_TEMP2
fi
}

trap 'clean_tempfiles; exit 1' SIGINT SIGHUP SIGTERM
trap 'clean_tempfiles' EXIT

# Output usage information
usage_full()
{
@@ -260,9 +270,6 @@ proc_coreswitch()

## Main function:

rm -f $FILE_DEBUG
rm -f $FILE_DEBUG2

# Get options
while getopts c:i:Ks:t:T:v:? option
do
@@ -444,11 +451,7 @@ done # End of for (( ix=0 ; $ix <= $max_coreswitch ; ix=$[ix+1] ))
echo ",,,,,,,,,,,,,," >> ${file_topology_out}

# Clean temporary files
if [ $fl_clean == 1 ]
then
rm -f $FILE_TEMP
rm -f $FILE_TEMP2
fi
clean_tempfiles

display_progress "Done"
exit 0
@@ -30,9 +30,10 @@

# [ICS VERSION STRING: unknown]

TEMP1=/tmp/smdiffa$$
TEMP2=/tmp/smdiffb$$
TEMP1=`mktemp`
TEMP2=`mktemp`
trap "rm -f $TEMP1 $TEMP2; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $TEMP1 $TEMP2" EXIT

Usage()
{
@@ -30,8 +30,9 @@

# [ICS VERSION STRING: unknown]

TEMP=/tmp/smgen$$
TEMP=`mktemp`
trap "rm -f $TEMP; exit 1" SIGHUP SIGTERM SIGINT
trap "rm -f $TEMP" EXIT

Usage()
{

0 comments on commit 080ab97

Please sign in to comment.
You can’t perform that action at this time.