diff --git a/xCAT-genesis-scripts/usr/bin/diskdiscover b/xCAT-genesis-scripts/usr/bin/diskdiscover
index 7964d1c9c..bf0ce3ab3 100755
--- a/xCAT-genesis-scripts/usr/bin/diskdiscover
+++ b/xCAT-genesis-scripts/usr/bin/diskdiscover
@@ -51,8 +51,8 @@
# source raidutils
#
###########################################
-str_dir_name=`dirname $0`
-. $str_dir_name/raidutils
+str_dir_name="$(dirname "$0")"
+. "$str_dir_name/raidutils"
############################################
@@ -83,8 +83,8 @@ if [ "x$input" == "x--help" -o "x$input" == "x-h" ]; then
usagesc
exit 0
fi
-if [ -z $input ]; then
+if [ -z "$input" ]; then
get_all_devices_for_raid
else
- get_devices_by_pciid $input
+ get_devices_by_pciid "$input"
fi
diff --git a/xCAT-genesis-scripts/usr/bin/dodiscovery b/xCAT-genesis-scripts/usr/bin/dodiscovery
index 1438a1600..ebebad61d 100755
--- a/xCAT-genesis-scripts/usr/bin/dodiscovery
+++ b/xCAT-genesis-scripts/usr/bin/dodiscovery
@@ -9,8 +9,7 @@ reqtime=0
maxresptime=180
minixcatd.awk &
-PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBLIC KEY"`
-PUBKEY=`echo $PUBKEY|sed -e 's/ //g'`
+PUBKEY="$(openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|awk '!/ PUBLIC KEY/{printf $0}')"
export PUBKEY
logger -s -t $log_label -p local4.info "Beginning node discovery process..."
@@ -98,8 +97,8 @@ if [ -r /sys/devices/virtual/dmi/id/product_name ]; then #x86
fi
if [ -z "$MTM" -o "$MTM" == ":" ]; then
logger -s -t $log_label -p local4.warning "Couldn't find MTM information in FRU, falling back to DMI (MTMS-based discovery may fail)"
- m=`cat /sys/devices/virtual/dmi/id/sys_vendor`
- n=`cat /sys/devices/virtual/dmi/id/product_name`
+ read -r m /dev/null; then
+ if ! dmidecode -t 41|grep -q $obslot; then
obdevs=("${obdevs[@]}" $obslot)
fi
done
@@ -271,7 +270,7 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v
echo "" >> /tmp/discopacket
done
if [ "$UUID" == "unknown" ]; then
- UUID=`echo $MTM-$SERIAL-$MAC_OF_FIRST_UP_NIC | tr /A-Z/ /a-z/`
+ UUID="${MTM,,}-${SERIAL,,}-${MAC_OF_FIRST_UP_NIC,,}"
echo "$UUID" >> /tmp/discopacket
fi
echo "$PUBKEY" >> /tmp/discopacket #this is not secure to use by itself, switch sourced pubkey for security
diff --git a/xCAT-genesis-scripts/usr/bin/dosysclone b/xCAT-genesis-scripts/usr/bin/dosysclone
index ad1a7313b..cd7b3b53e 100755
--- a/xCAT-genesis-scripts/usr/bin/dosysclone
+++ b/xCAT-genesis-scripts/usr/bin/dosysclone
@@ -19,7 +19,7 @@ ping_test
get_scripts_directory
-if [ ! -z $HOSTNAME ]; then
+if [ ! -z "$HOSTNAME" ]; then
logmsg
logmsg "This hosts name is: $HOSTNAME"
fi
diff --git a/xCAT-genesis-scripts/usr/bin/getadapter b/xCAT-genesis-scripts/usr/bin/getadapter
index 918d92b97..eb1c0a913 100755
--- a/xCAT-genesis-scripts/usr/bin/getadapter
+++ b/xCAT-genesis-scripts/usr/bin/getadapter
@@ -1,5 +1,4 @@
#!/bin/bash
-#set -x
XCATPORT=3001
export XCATPORT
@@ -18,35 +17,35 @@ echo "
getadapter
update" >> "$ADAPTERFILE"
-#scan adapters have recognized by operating system
+# scan adapters that are recognized by operating system
for n in /sys/class/net/*; do
nic=${n##/sys/class/net/}
if [ "$nic" == "lo" ]; then
continue
else
echo '' >> "$ADAPTERFILE"
- tmp=`udevadm info /sys/class/net/"$nic" | grep " INTERFACE" | awk -F '=' '{print $2}'`
+ tmp="$(udevadm info "/sys/class/net/$nic" | awk -F '=' '/ INTERFACE/{print $2}')"
if [ -n "$tmp" ]; then
echo "$tmp" >> "$ADAPTERFILE"
fi
- tmp=`udevadm info /sys/class/net/"$nic" | grep ID_NET_NAME | awk -F '=' '{print $2}'|sort -u| tr -s "\n" "/" | sed "s/\/$//g"`
+ tmp="$(udevadm info "/sys/class/net/$nic" | awk -F '=' '/ID_NET_NAME/{print $2}'|sort -u| tr -s "\n" "/" | sed 's#/$##g')"
if [ -n "$tmp" ]; then
echo "$tmp" >> "$ADAPTERFILE"
fi
- tmp=`udevadm info /sys/class/net/"$nic" | grep DEVPATH | awk -F 'devices' '{print $2}'`
+ tmp="$(udevadm info "/sys/class/net/$nic" | awk -F 'devices' '/DEVPATH/{print $2}')"
if [ -n "$tmp" ]; then
echo "${tmp%/net*}" >> "$ADAPTERFILE"
fi
- echo "`cat /sys/class/net/$nic/address`" >> "$ADAPTERFILE"
- tmp=`udevadm info /sys/class/net/"$nic" | grep ID_VENDOR_FROM_DATABASE | awk -F '=' '{print $2}' | tr -s "\n" "/" | sed "s/\/$//g"`
+ echo "$(cat "/sys/class/net/$nic/address")" >> "$ADAPTERFILE"
+ tmp="$(udevadm info "/sys/class/net/$nic" | awk -F '=' '/ID_VENDOR_FROM_DATABASE/{print $2}' | tr -s "\n" "/" | sed 's#/$##g')"
if [ -n "$tmp" ]; then
echo "$tmp" >> "$ADAPTERFILE"
fi
- tmp=`udevadm info /sys/class/net/"$nic" | grep ID_MODEL_FROM_DATABASE | awk -F '=' '{print $2}'`
+ tmp="$(udevadm info /sys/class/net/"$nic" | awk -F '=' '/ID_MODEL_FROM_DATABASE/{print $2}')"
if [ -n "$tmp" ]; then
echo "$tmp" >> "$ADAPTERFILE"
fi
- tmp=`ip link show $nic`
+ tmp="$(ip link show "$nic")"
if [ -n "$tmp" ]; then
tmp=${tmp#*state }
echo "${tmp% mode*}" >> "$ADAPTERFILE"
@@ -55,34 +54,34 @@ for n in /sys/class/net/*; do
fi
done
-for pci in `lspci |awk '/Ethernet/ {print $1}' `; do
+for pci in $(lspci |awk '/Ethernet/ {print $1}'); do
if ! grep -q "$pci" "$ADAPTERFILE" 2>/dev/null; then
- tmp=`lspci |grep "$pci"`
- echo '' >> "$ADAPTERFILE"
- echo "$pci" >> "$ADAPTERFILE"
- echo "${tmp##*:}" >> "$ADAPTERFILE"
- echo '' >> "$ADAPTERFILE"
- fi
+ tmp="$(lspci |grep "$pci")"
+ echo "
+$pci
+${tmp##*:}
+" >> "$ADAPTERFILE"
+ fi
done
-for pci in `lspci |awk '/Network/ {print $1}' `; do
+for pci in $(lspci |awk '/Network/ {print $1}'); do
if ! grep -q "$pci" "$ADAPTERFILE" 2>/dev/null; then
- tmp=`lspci |grep "$pci"`
- echo '' >> "$ADAPTERFILE"
- echo "$pci" >> "$ADAPTERFILE"
- echo "${tmp##*: }" >> "$ADAPTERFILE"
- echo '' >> "$ADAPTERFILE"
- fi
+ tmp="$(lspci |grep "$pci")"
+ echo "
+$pci
+${tmp##*: }
+" >> "$ADAPTERFILE"
+ fi
done
-for pci in `lspci |awk '/Mellanox/ {print $1}' `; do
+for pci in $(lspci |awk '/Mellanox/ {print $1}'); do
if ! grep -q "$pci" "$ADAPTERFILE" 2>/dev/null; then
- tmp=`lspci |grep "$pci"`
- echo '' >> "$ADAPTERFILE"
- echo "$pci" >> "$ADAPTERFILE"
- echo "${tmp##*: }" >> "$ADAPTERFILE"
- echo '' >> "$ADAPTERFILE"
- fi
+ tmp="$(lspci |grep "$pci")"
+ echo "
+$pci
+${tmp##*: }
+" >> "$ADAPTERFILE"
+ fi
done
echo "" >> "$ADAPTERFILE"
@@ -98,7 +97,7 @@ if [ -n "$XCATMASTER" ]; then
openssl s_client -connect $XCATMASTER:$XCATPORT <"$ADAPTERFILE" >>"$SCANNICLOG" 2>&1
fi
else
- dhcps=`awk -F ' |;' '/dhcp-server/ { print $(NF-1) }' /var/lib/dhclient/dhclient.leases | tail -n 1`
+ dhcps="$(awk -F ' |;' '/dhcp-server/ { print $(NF-1) }' /var/lib/dhclient/dhclient.leases | tail -n 1)"
if [ -n "$dhcps" ]; then
if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
echo "using /etc/xcat/certkey.pem and /etc/xcat/cert.pem to transmit scan result to $dhcps" >> "$SCANNICLOG"
diff --git a/xCAT-genesis-scripts/usr/bin/getcert b/xCAT-genesis-scripts/usr/bin/getcert
index 5cb40906d..cf4cf1b07 100755
--- a/xCAT-genesis-scripts/usr/bin/getcert
+++ b/xCAT-genesis-scripts/usr/bin/getcert
@@ -5,7 +5,7 @@ if [ -z "$XCATDEST" ]; then
XCATDEST=$1
fi
#retry in case certkey.pem is not right, yet
-while ! openssl req -new -key /etc/xcat/certkey.pem -out /tmp/tls.csr -subj "/CN=`hostname`" >& /dev/null; do
+while ! openssl req -new -key /etc/xcat/certkey.pem -out /tmp/tls.csr -subj "/CN=$(hostname)" >& /dev/null; do
sleep 1
done
echo "
@@ -20,20 +20,20 @@ echo "
" >> /tmp/certreq.xml
openssl dgst -sha512 -out /tmp/certreq.sha512 -sign /etc/xcat/privkey.pem /tmp/certreq.xml #chain off the switch published key
openssl enc -e -a -in /tmp/certreq.sha512 > /tmp/certreq.b64sig
-cat /tmp/certreq.xml |while read line; do
+while read -r line; do
if [ "$line" = "" ]; then
cat /tmp/certreq.b64sig >> /tmp/certreq.xml.new
fi
- echo $line >> /tmp/certreq.xml.new
-done
+ echo "$line" >> /tmp/certreq.xml.new
+done < /tmp/certreq.xml
mv /tmp/certreq.xml.new /tmp/certreq.xml
rm /tmp/certreq.b64sig /tmp/certreq.sha512
-cat /tmp/certreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/certresp.xml
+openssl s_client -connect "$XCATDEST" -quiet 2> /dev/null < /tmp/certreq.xml > /tmp/certresp.xml
if grep 'BEGIN CERTIFICATE' /tmp/certresp.xml > /dev/null; then
awk '/BEGIN CERTIFICATE/,/END CERTIFICATE/' < /tmp/certresp.xml > /etc/xcat/cert.pem
#stop transmitting sysDesc, allowing the public key to age out of validity
- for iface in `grep '^ e' /var/lib/lldpad/lldpad.conf|awk '{print $1}' `; do
- lldptool -T -i $iface -V sysDesc enableTx=no >& /dev/null
+ for iface in $(grep '^ e' /var/lib/lldpad/lldpad.conf|awk '{print $1}'); do
+ lldptool -T -i "$iface" -V sysDesc enableTx=no >& /dev/null
done
fi
rm /tmp/certreq.xml
diff --git a/xCAT-genesis-scripts/usr/bin/getdestiny b/xCAT-genesis-scripts/usr/bin/getdestiny
index 15cfc1baa..6f3a44f01 100755
--- a/xCAT-genesis-scripts/usr/bin/getdestiny
+++ b/xCAT-genesis-scripts/usr/bin/getdestiny
@@ -18,13 +18,13 @@ while [ ! -f /tmp/destiny.xml ] || grep error /tmp/destiny.xml; do
fi
echo " " >&2
if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
- cat /tmp/destreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml
+ openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect "$XCATDEST" -quiet 2> /dev/null < /tmp/destreq.xml > /tmp/destiny.xml
else
- cat /tmp/destreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml
+ openssl s_client -connect "$XCATDEST" -quiet 2> /dev/null < /tmp/destreq.xml > /tmp/destiny.xml
fi
done
rm /tmp/destreq.xml
-DESTINY=`grep '' /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'`
+DESTINY="$(grep '' /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}')"
rm /tmp/destiny.xml
-echo $DESTINY
+echo "$DESTINY"
diff --git a/xCAT-genesis-scripts/usr/bin/getipmi b/xCAT-genesis-scripts/usr/bin/getipmi
index 5fb26c4a4..a1882826e 100755
--- a/xCAT-genesis-scripts/usr/bin/getipmi
+++ b/xCAT-genesis-scripts/usr/bin/getipmi
@@ -10,9 +10,9 @@ fi
# This section only works in genesis
if [ -z "$XCATDEST" ]; then
- for parm in `cat /proc/cmdline` ; do
- if echo $parm |grep xcatd= > /dev/null; then
- XCATDEST=`echo $parm |awk -F= '{print $2}'`
+ for parm in $(cat /proc/cmdline); do
+ if echo "$parm" |grep -q xcatd=; then
+ XCATDEST="$(echo "$parm" |awk -F= '{print $2}')"
fi
done
fi
@@ -27,10 +27,10 @@ for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
then break;
fi;
done
-BMCMAC=`ipmitool lan print $LANCHAN|grep ^MAC|awk '{print $4}'` #bmcconfig may opt to use DHCP, if so we need to feed up the mac address
+BMCMAC="$(ipmitool lan print "$LANCHAN"|grep ^MAC|awk '{print $4}')" #bmcconfig may opt to use DHCP, if so we need to feed up the mac address
#TODO: need a way to get the DUID the service processor may use, perhaps reserve that for 'ibmsetup' since spec doesn't touch ipv6?
-IPMIMFG=`ipmitool mc info |grep "^Manufacturer ID"|awk '{print $4}'`
-XPROD=`ipmitool mc info | grep "^Product ID"|awk '{print $4}'`
+IPMIMFG="$(ipmitool mc info |grep "^Manufacturer ID"|awk '{print $4}')"
+XPROD="$(ipmitool mc info | grep "^Product ID"|awk '{print $4}')"
if [ "$IPMIMFG" == "42817" -a "$XPROD" == "16975" ]; then
ISOPENBMC=1 # AC922
elif [ "$IPMIMFG" == "42817" -a "$XPROD" == "1" ]; then
@@ -57,9 +57,9 @@ while [ ! -f /tmp/ipmicfg.xml ] || grep error /tmp/ipmicfg.xml; do
echo -en " \r";
if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
- cat /tmp/bmcreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/ipmicfg.xml
+ openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect "$XCATDEST" -quiet 2> /dev/null < /tmp/bmcreq.xml > /tmp/ipmicfg.xml
else
- cat /tmp/bmcreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/ipmicfg.xml
+ openssl s_client -connect "$XCATDEST" -quiet 2> /dev/null < /tmp/bmcreq.xml > /tmp/ipmicfg.xml
fi
done
rm /tmp/bmcreq.xml
diff --git a/xCAT-genesis-scripts/usr/bin/nextdestiny b/xCAT-genesis-scripts/usr/bin/nextdestiny
index 086951c98..298826afb 100755
--- a/xCAT-genesis-scripts/usr/bin/nextdestiny
+++ b/xCAT-genesis-scripts/usr/bin/nextdestiny
@@ -16,16 +16,16 @@ while [ ! -f /tmp/destiny.xml ]; do
done
echo " " >&2;
if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
- cat /tmp/destreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml
+ openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect "$XCATDEST" -quiet 2> /dev/null < /tmp/destreq.xml > /tmp/destiny.xml
else
- cat /tmp/destreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/destiny.xml
+ openssl s_client -connect "$XCATDEST" -quiet 2> /dev/null < /tmp/destreq.xml > /tmp/destiny.xml
fi
timer=60
done
rm /tmp/destreq.xml
-DESTINY=`grep '' /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'`
+DESTINY="$(grep '' /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}')"
if [ -z "$DESTINY" ]; then
- ERROR=`grep '' /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}'`
+ ERROR="$(grep '' /tmp/destiny.xml | awk -F'>' '{print $2}'|awk -F'<' '{print $1}')"
if [ ! -z "$ERROR" ]; then
DESTINY="error=$ERROR"
else
@@ -33,4 +33,4 @@ if [ -z "$DESTINY" ]; then
fi
fi
rm /tmp/destiny.xml
-echo $DESTINY
+echo "$DESTINY"
diff --git a/xCAT-genesis-scripts/usr/bin/raidcmd b/xCAT-genesis-scripts/usr/bin/raidcmd
index 266c65727..6c9ab0ae4 100755
--- a/xCAT-genesis-scripts/usr/bin/raidcmd
+++ b/xCAT-genesis-scripts/usr/bin/raidcmd
@@ -11,7 +11,7 @@ iprconfig="iprconfig"
########################################
function cmd_show_config {
local lines=""
- lines=`$iprconfig -c show-config`
+ lines="$($iprconfig -c show-config)"
echo "$lines"
}
@@ -22,7 +22,7 @@ function cmd_show_config {
########################################
function cmd_show_ioas {
local lines=""
- lines=`$iprconfig -c show-ioas`
+ lines="$($iprconfig -c show-ioas)"
echo "$lines"
}
@@ -34,7 +34,7 @@ function cmd_show_ioas {
function cmd_show_details {
local lines=""
local dev=$*
- lines=`$iprconfig -c show-details $dev`
+ lines="$($iprconfig -c show-details $dev)"
echo "$lines"
}
@@ -45,7 +45,7 @@ function cmd_show_details {
########################################
function cmd_show_arrays {
local lines=""
- lines=`$iprconfig -c show-arrays`
+ lines="$($iprconfig -c show-arrays)"
echo "$lines"
}
@@ -60,7 +60,7 @@ function cmd_show_arrays {
function is_array {
local lines=""
local dev=$*
- lines=`$iprconfig -c show-details $dev | grep -sq "RAID Level"`
+ lines="$($iprconfig -c show-details $dev | grep -sq "RAID Level")"
echo "$?"
}
@@ -72,7 +72,7 @@ function is_array {
function cmd_alt_status {
local lines=""
local dev=$*
- lines=`$iprconfig -c alt-status $dev`
+ lines="$($iprconfig -c alt-status $dev)"
echo "$lines"
}
@@ -84,7 +84,7 @@ function cmd_alt_status {
function cmd_show_status {
local lines=""
local dev=$*
- lines=`$iprconfig -c status $dev`
+ lines="$($iprconfig -c status $dev)"
echo "$lines"
}
@@ -96,7 +96,7 @@ function cmd_show_status {
function cmd_show_alt_config {
local lines=""
local dev=$*
- lines=`$iprconfig -c show-alt-config`
+ lines="$($iprconfig -c show-alt-config)"
echo "$lines"
}
@@ -108,7 +108,7 @@ function cmd_show_alt_config {
function cmd_query_raid_delete {
local lines=""
local ioa=$*
- lines=`$iprconfig -c query-raid-delete $ioa`
+ lines="$($iprconfig -c query-raid-delete $ioa)"
echo "$lines"
}
@@ -120,7 +120,7 @@ function cmd_query_raid_delete {
function cmd__raid_delete {
local lines=""
local array=$*
- lines=`$iprconfig -c raid-delete "$array"`
+ lines="$($iprconfig -c raid-delete "$array")"
}
##################################################################
@@ -131,6 +131,6 @@ function cmd__raid_delete {
function cmd_raid_create {
local iprconfig_args=$1
local member_sgs=$2
- lines=`$iprconfig -c raid-create $iprconfig_args $member_sgs`
+ lines="$($iprconfig -c raid-create $iprconfig_args $member_sgs)"
}
diff --git a/xCAT-genesis-scripts/usr/bin/remoteimmsetup b/xCAT-genesis-scripts/usr/bin/remoteimmsetup
index 027797e5c..f71bf8341 100755
--- a/xCAT-genesis-scripts/usr/bin/remoteimmsetup
+++ b/xCAT-genesis-scripts/usr/bin/remoteimmsetup
@@ -4,9 +4,9 @@ if [ -z "$XCATDEST" ]; then
XCATDEST=$1
fi
if [ -z "$XCATDEST" ]; then
- for parm in `cat /proc/cmdline` ; do
- if echo $parm |grep xcatd= > /dev/null; then
- XCATDEST=`echo $parm |awk -F= '{print $2}'`
+ for parm in $(cat /proc/cmdline); do
+ if echo "$parm" |grep -q xcatd=; then
+ XCATDEST="$(echo "$parm" |awk -F= '{print $2}')"
fi
done
fi
@@ -15,7 +15,7 @@ for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
then break;
fi;
done
-BMCMAC=`ipmitool lan print $LANCHAN|grep ^MAC|awk '{print $4}'` #bmcconfig may opt to use DHCP, if so we need to feed up the mac address
+BMCMAC="$(ipmitool lan print "$LANCHAN"|grep ^MAC|awk '{print $4}')" #bmcconfig may opt to use DHCP, if so we need to feed up the mac address
#TODO: need a way to get the DUID the service processor may use, perhaps reserve that for 'ibmsetup' since spec doesn't touch ipv6?
echo "
@@ -35,9 +35,9 @@ while [ ! -f /tmp/remsetup.xml ] || grep error /tmp/remsetup.xml; do
echo -en " \r";
if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
- cat /tmp/bmcreq.xml | openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATDEST -quiet 2> /dev/null > /tmp/remsetup.xml
+ openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect "$XCATDEST" -quiet 2> /dev/null < /tmp/bmcreq.xml > /tmp/remsetup.xml
else
- cat /tmp/bmcreq.xml | openssl s_client -connect $XCATDEST -quiet 2> /dev/null > /tmp/remsetup.xml
+ openssl s_client -connect "$XCATDEST" -quiet 2> /dev/null < /tmp/bmcreq.xml > /tmp/remsetup.xml
fi
done
rm /tmp/bmcreq.xml
diff --git a/xCAT-genesis-scripts/usr/bin/restart b/xCAT-genesis-scripts/usr/bin/restart
index f5e79af3c..20803b595 100755
--- a/xCAT-genesis-scripts/usr/bin/restart
+++ b/xCAT-genesis-scripts/usr/bin/restart
@@ -1,41 +1,41 @@
#!/bin/bash
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
#Redhcp, do the xcat part again
-FORCENICS=`cat /restart|awk '{print $2}'`
+FORCENICS="$(awk '{print $2}' /restart)"
rm /restart
if [ ! -z "$FORCENICS" ]; then
echo "Forcing down nics aside from $FORCENICS due to discoverynics setting"
for pidfile in /var/run/dhclient.*.pid; do
- NIC=`echo $pidfile|awk -F. '{print $2}'`
- if [ ! -z "$NIC" ] && echo $NIC | egrep -v "$FORCENICS"; then
- dhclient -r -1 -cf /etc/dhclient.conf -pf $pidfile $NIC
- rm $pidfile
- ip link set $NIC down
+ NIC="$(echo "$pidfile"|awk -F. '{print $2}')"
+ if [ ! -z "$NIC" ] && echo "$NIC" | egrep -qv "$FORCENICS"; then
+ dhclient -r -1 -cf /etc/dhclient.conf -pf "$pidfile" "$NIC"
+ rm "$pidfile"
+ ip link set "$NIC" down
fi
done
for pidfile in /var/run/dhclient6.*.pid; do
- NIC=`echo $pidfile|awk -F. '{print $2}'`
- if [ ! -z "$NIC" ] && echo $NIC | egrep -v "$FORCENICS"; then
- dhclient -6 -r -1 -pf $pidfile -lf /var/lib/dhclient/dhclient6.leases $NIC
- rm $pidfile
- ip link set $NIC down
+ NIC="$(echo "$pidfile"|awk -F. '{print $2}')"
+ if [ ! -z "$NIC" ] && echo "$NIC" | egrep -qv "$FORCENICS"; then
+ dhclient -6 -r -1 -pf "$pidfile" -lf /var/lib/dhclient/dhclient6.leases "$NIC"
+ rm "$pidfile"
+ ip link set "$NIC" down
fi
done
fi
WAITING=1
while [ $WAITING -gt 0 ]; do
for pidfile in /var/run/dhclient.*.pid; do
- NIC=`echo $pidfile|awk -F. '{print $2}'`
- dhclient -r -1 -cf /etc/dhclient.conf -pf $pidfile $NIC
- ip -4 addr flush dev $NIC
- dhclient -cf /etc/dhclient.conf -nw -pf $pidfile $NIC
+ NIC="$(echo "$pidfile"|awk -F. '{print $2}')"
+ dhclient -r -1 -cf /etc/dhclient.conf -pf "$pidfile" "$NIC"
+ ip -4 addr flush dev "$NIC"
+ dhclient -cf /etc/dhclient.conf -nw -pf "$pidfile" "$NIC"
done
for pidfile in /var/run/dhclient6.*.pid; do
- NIC=`echo $pidfile|awk -F. '{print $2}'`
- dhclient -6 -r -1 -pf $pidfile -lf /var/lib/dhclient/dhclient6.leases $NIC
- ip -6 addr flush dev $NIC scope global
- ip -6 addr flush dev $NIC scope site
- dhclient -6 -pf $pidfile -nw -lf /var/lib/dhclient/dhclient6.leases $NIC
+ NIC="$(echo "$pidfile"|awk -F. '{print $2}')"
+ dhclient -6 -r -1 -pf "$pidfile" -lf /var/lib/dhclient/dhclient6.leases "$NIC"
+ ip -6 addr flush dev "$NIC" scope global
+ ip -6 addr flush dev "$NIC" scope site
+ dhclient -6 -pf "$pidfile" -nw -lf /var/lib/dhclient/dhclient6.leases "$NIC"
done
echo -en "Waiting 10 seconds for DHCP changes to take effect \r"
@@ -46,14 +46,14 @@ while [ $WAITING -gt 0 ]; do
# restart rsyslog after dhclient
if [ -f /var/run/syslogd.pid ]; then
- kill -TERM `cat /var/run/syslogd.pid`
+ kill -TERM "$(cat /var/run/syslogd.pid)"
fi
if [ -f /var/run/rsyslogd.pid ]; then
- kill -TERM `cat /var/run/rsyslogd.pid`
+ kill -TERM "$(cat /var/run/rsyslogd.pid)"
fi
sleep 3
- RSYSLOGD_VERSION=`rsyslogd -v | grep -m1 "rsyslogd" | tr -s ' ' | cut -d" " -f2 | cut -d"." -f1`
+ RSYSLOGD_VERSION="$(rsyslogd -v | grep -m1 "rsyslogd" | tr -s ' ' | cut -d" " -f2 | cut -d"." -f1)"
if [ $RSYSLOGD_VERSION -ge 8 ]; then
# Newer versions of rsyslogd do not support -c flag anymore
/sbin/rsyslogd
@@ -64,9 +64,9 @@ while [ $WAITING -gt 0 ]; do
WAITING=0
if [ ! -z "$FORCENICS" ]; then
#for nic in `ifconfig|grep HWaddr|awk '{print $1}'|egrep "$FORCENICS"`; do
- for nic in `ip -oneline link show |grep -i ether |awk -F ':' '{print $2}'|grep -o "[^ ]\+\( \+[^ ]\+\)*"|egrep "$FORCENICS"`; do
+ for nic in $(ip -oneline link show |grep -i ether |awk -F ':' '{print $2}'|grep -o "[^ ]\+\( \+[^ ]\+\)*"|egrep "$FORCENICS"); do
# if ! ifconfig $nic|grep "inet addr" > /dev/null; then
- if ! ip -4 -oneline addr show $nic|grep -i inet > /dev/null; then
+ if ! ip -4 -oneline addr show "$nic"|grep -qi inet; then
WAITING=1
fi
done