Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shellcheck improvements for genesis-scripts #4923

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions xCAT-genesis-scripts/usr/bin/bmcsetup
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
# Lenovo (c) 2016
#
Expand Down
8 changes: 4 additions & 4 deletions xCAT-genesis-scripts/usr/bin/diskdiscover
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
# source raidutils
#
###########################################
str_dir_name=`dirname $0`
. $str_dir_name/raidutils
str_dir_name="$(dirname "$0")"
. "$str_dir_name/raidutils"


############################################
Expand Down Expand Up @@ -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
111 changes: 43 additions & 68 deletions xCAT-genesis-scripts/usr/bin/dodiscovery
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down Expand Up @@ -90,36 +89,28 @@ if [ -r /sys/devices/virtual/dmi/id/product_name ]; then #x86
IAMAVM=1
MTM=VMware
else
MTM=`cat /sys/devices/virtual/dmi/id/product_name|awk -F'[' '{print $2}'|awk -F']' '{print $1}'`
MTM="$(awk -F'[' '{print $2}' /sys/devices/virtual/dmi/id/product_name |awk -F']' '{print $1}')"
if [ -z "$MTM" ]; then
FRU=`ipmitool fru print 0`
if [ $? -eq 0 ]; then
MTM=`echo "$FRU" | awk -F': ' '/Product Manufacturer/ {m=$2} /Product Name|Product Part Number/ {if (n==""||n=="NONE") {n=$2}} END {print m":"n}'`
MTM="$(echo "$FRU" | awk -F': ' '/Product Manufacturer/ {m=$2} /Product Name|Product Part Number/ {if (n==""||n=="NONE") {n=$2}} END {print m":"n}')"
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 </sys/devices/virtual/dmi/id/sys_vendor
read -r n </sys/devices/virtual/dmi/id/product_name
MTM="$m:$n"
fi
fi
SERIAL=`cat /sys/devices/virtual/dmi/id/product_serial`
fi
CPUCOUNT=`cat /proc/cpuinfo |grep "model name"|wc -l`
grep "model name" /proc/cpuinfo | while read line; do #to avoid pulling in tail, we do a goofy thing
echo $line > /tmp/cpumod
done
CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'`
read -r CPUCOUNT CPUTYPE < <(awk -F: 'BEGIN{c=0; n=""} /model name/{c=c+1; n=$2} END{printf "%d %s",c,n}' /proc/cpuinfo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the file, /proc/cpuinfo from a Power 8 test machine.

# cat /proc/cpuinfo
processor	: 0
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 1
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 2
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 3
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 4
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 5
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 6
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 7
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 8
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 9
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 10
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 11
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 12
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 13
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 14
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 15
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 16
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 17
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 18
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 19
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 20
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 21
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 22
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 23
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 24
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 25
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 26
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 27
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 28
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 29
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 30
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 31
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 32
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 33
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 34
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 35
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 36
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 37
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 38
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 39
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 40
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 41
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 42
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 43
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 44
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 45
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 46
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 47
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 48
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 49
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 50
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 51
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 52
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 53
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 54
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 55
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 56
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 57
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 58
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 59
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 60
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 61
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 62
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 63
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 64
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 65
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 66
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 67
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 68
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 69
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 70
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 71
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 72
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 73
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 74
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 75
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 76
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 77
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 78
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 79
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 80
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 81
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 82
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 83
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 84
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 85
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 86
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 87
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 88
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 89
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 90
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 91
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 92
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 93
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 94
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 95
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 96
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 97
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 98
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 99
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 100
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 101
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 102
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 103
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 104
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 105
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 106
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 107
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 108
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 109
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 110
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 111
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 112
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 113
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 114
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 115
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 116
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 117
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 118
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 119
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 120
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 121
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 122
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 123
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 124
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 125
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 126
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

processor	: 127
cpu		: POWER8 (raw), altivec supported
clock		: 3857.000000MHz
revision	: 2.0 (pvr 004d 0200)

timebase	: 512000000
platform	: PowerNV
model		: 8001-22C
machine		: PowerNV 8001-22C
firmware	: OPAL

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neo954 Can you confirm the value of CPUTYPE with the old code against the above? I get the same value with old code as with new code for the cpuinfo contents for P8 as above:

[samveen@development bin]$ grep -e "^cpu\s*:" /tmp/cpuinfo.P8 | while read line; do  echo $line > /tmp/cpumod ; done
[samveen@development bin]$ cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'
POWER8 (raw), altivec supported

UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /sys/devices/virtual/dmi/id/product_uuid`

elif [ -r /proc/device-tree/model ]; then #POWER
MTM=`cat /proc/device-tree/model -vT | sed -e 's/^.*,//' | sed -e 's/^[\t ]*//'| sed -e 's/[\t ]*\^@//'`
CPUCOUNT=`cat /proc/cpuinfo |grep -e "^cpu\s*:"|wc -l`
PLATFORM=`cat /proc/cpuinfo | grep -e "^platform\s*:" | awk '{print \$3}'`
grep -e "^cpu\s*:" /proc/cpuinfo | while read line; do #to avoid pulling in tail, we do a goofy thing
echo $line > /tmp/cpumod
done
CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'`
PLATFORM="$(awk '/^platform\s*:/{print $3}' /proc/cpuinfo)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the file, /proc/cpuinfo from a Power 7 Logical Partition.

# cat /proc/cpuinfo
processor	: 0
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 1
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 2
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 3
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 4
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 5
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 6
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 7
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 8
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 9
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 10
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 11
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 12
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 13
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 14
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

processor	: 15
cpu		: POWER7 (architected), altivec supported
clock		: 3550.000000MHz
revision	: 2.0 (pvr 003f 0200)

timebase	: 512000000
platform	: pSeries
model		: IBM,8233-E8B
machine		: CHRP IBM,8233-E8B

Copy link
Member Author

@samveen samveen Mar 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neo954 Can you confirm the output expected from the old code. I get CPUTYPE value POWER7 (architected), altivec supported from the old code too.

[samveen@dev bin]$ grep -e "^cpu\s*:" /tmp/cpuinfo.P7LP | while read line; do 
> echo $line > /tmp/cpumod 
> done
[samveen@dev bin]$ cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'
POWER7 (architected), altivec supported

read CPUCOUNT CPUTYPE < <(awk -F':' 'BEGIN{c=0; n=""} /^cpu\s*:/{c=c+1; n=$2} END{printf "%d %s",c,n}' /proc/cpuinfo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not going to work. Please see my test results below.

On ppc64le RHEL 7.4

# awk -F':' 'BEGIN{c=0; n=""} /^cpu\s*:/{c=c+1; n=$2} END{printf "%d %s",c,n}' /proc/cpuinfo
8  POWER8 (architected), altivec supported

On ppc64 RHEL 7.4

# awk -F':' 'BEGIN{c=0; n=""} /^cpu\s*:/{c=c+1; n=$2} END{printf "%d %s",c,n}' /proc/cpuinfo
16  POWER7 (architected), altivec supported

On x86-64 RHEL 7.4

# awk -F':' 'BEGIN{c=0; n=""} /^cpu\s*:/{c=c+1; n=$2} END{printf "%d %s",c,n}' /proc/cpuinfo
0
  • It does not work on x86-64
  • On ppc64le or ppc64, CPUTYPE will be assigned to something like POWER8 (architected), altivec supported. But for the original code, it will be assigned to POWER8.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neo954 Can you give me the output of cat /proc/cpuinfo for ppc64 and ppc64le machines? I have no access to a sample for them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, the file, /proc/cpuinfo from a Power 8 KVM guest.

# cat /proc/cpuinfo
processor	: 0
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 1
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 2
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

processor	: 3
cpu		: POWER8E (raw), altivec supported
clock		: 3425.000000MHz
revision	: 2.1 (pvr 004b 0201)

timebase	: 512000000
platform	: pSeries
model		: IBM pSeries (emulated by qemu)
machine		: CHRP IBM pSeries (emulated by qemu)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@neo954 Can you confirm the value of CPUTYPE with the old code against the above? I get the same value with old code as with new code for P8 KVM guest:

[samveen@development bin]$ grep -e "^cpu\s*:" /tmp/cpuinfo.P8KVMG | while read line; do  echo $line > /tmp/cpumod ; done
[samveen@development bin]$ cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'
POWER8E (raw), altivec supported

SERIAL=`cat /proc/device-tree/system-id -vT | sed -e 's/^.*,//' | sed -e 's/^[\t ]*//'| sed -e 's/[\t ]*\^@//'`
# For POWER servers, the /proc/sys/kernel/random/uuid is changing for each query, so use mtms + mac of first up nic as the UUID
#UUID=`sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/' /proc/sys/kernel/random/uuid`
Expand All @@ -128,36 +119,35 @@ elif [ -r /proc/device-tree/model ]; then #POWER
fi

# The MEMORY will look like this: 32868920
MEMORY=`cat /proc/meminfo |grep MemTotal|awk '{printf "%.0fMB\n", $2/1024}'`
MEMORY="$(awk '/MemTotal/{printf "%.0fMB\n", $2/1024}' /proc/meminfo)"

# The DISKSIZE will look like this: sda:960GB,sdb:960GB,sdc:480GB,sdd:480GB (sorted by major,minor)
DISKSIZE="$(grep -v name /proc/partitions |sort -g -k 1,2 |awk 'BEGIN{sep=""} /[^0-9]$/{printf("%s%s:%.0fGB", sep, $4, $3/1024^2) ; sep=","}')"

logger -s -t $log_label -p local4.info "Beginning echo information to discovery packet file..."
echo '<xcatrequest>' > /tmp/discopacket
echo "<command>findme</command>" >> /tmp/discopacket
echo "<sequential>1</sequential>" >> /tmp/discopacket
echo "<arch>$ARCH</arch>" >> /tmp/discopacket
echo "<xcatrequest>
<command>findme</command>
<sequential>1</sequential>
<arch>$ARCH</arch>" >/tmp/discopacket
if [ "$IAMAVM" = 1 ]; then
echo "<nodetype>virtual</nodetype>" >> /tmp/discopacket
fi
echo "<cpucount>$CPUCOUNT</cpucount>" >> /tmp/discopacket
echo "<cputype>$CPUTYPE</cputype>" >> /tmp/discopacket
echo "<memory>$MEMORY</memory>" >> /tmp/discopacket
echo "<disksize>$DISKSIZE</disksize>" >> /tmp/discopacket
echo "<cpucount>$CPUCOUNT</cpucount>
<cputype>$CPUTYPE</cputype>
<memory>$MEMORY</memory>
<disksize>$DISKSIZE</disksize>" >>/tmp/discopacket
if [ "$UUID" != "unknown" ]; then
echo "<uuid>$UUID</uuid>" >> /tmp/discopacket
fi

flag_mtm=`echo "$MTM" | sed 's/0//g'`
flag_mtm="${MTM//0}"
if [ "$flag_mtm" ] && [ "$MTM" != "unknown" ]; then
MTM=`echo $MTM | sed 's/\.//g'`
echo "<mtm>$MTM</mtm>" >> /tmp/discopacket
fi
flag_serial=`echo "$SERIAL" | sed 's/0//g'`
flag_serial="${SERIAL//0}"
if [ "$flag_serial" ] && [ "$SERIAL" != "unknown" ]; then
SERIAL=`echo $SERIAL | sed 's/\.//g'`
echo "<serial>$SERIAL</serial>" >> /tmp/discopacket
echo "<serial>${SERIAL//.}</serial>" >> /tmp/discopacket
fi
if [ "$PLATFORM" != "unknown" ]; then
echo "<platform>$PLATFORM</platform>" >> /tmp/discopacket
Expand Down Expand Up @@ -191,7 +181,7 @@ if [ -f "/usr/sbin/dmidecode" ]; then
if [ ${onboard#*.} = 0 ]; then
truncslot=${onboard%.*}
for obslot in `grep $truncslot /sys/class/net/*/device/uevent|sed -e s/.*=//`; do
if ! dmidecode -t 41|grep $obslot > /dev/null; then
if ! dmidecode -t 41|grep -q $obslot; then
obdevs=("${obdevs[@]}" $obslot)
fi
done
Expand All @@ -208,7 +198,7 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v
ADDRESS=`ip -4 -o a show dev $dev|awk '/global/{print $4}'`
MAC=`ip link show dev $dev|grep ether|awk '{print $2}'| tr /a-f/ /A-F/`
if [ "$MAC_OF_FIRST_UP_NIC" == "unknown" ]; then
MAC_OF_FIRST_UP_NIC=`echo $MAC | sed -e s/://g`
MAC_OF_FIRST_UP_NIC=${MAC//:}
fi
if [[ ! -z "$PCI_SLOT" && -f "/usr/sbin/dmidecode" ]]; then
SLOTNAME=`dmidecode -t 9|egrep '(Designation|Address)'|grep -B1 $PCI_SLOT|grep Designation|sed -e 's/.*Designation:[ ]*//'`
Expand All @@ -231,26 +221,16 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v
fi
fi
fi
echo "<mac>$DRIVER|$dev|$MAC|$ADDRESS</mac>" >> /tmp/discopacket
echo "<nic>" >> /tmp/discopacket
echo " <devname>$dev</devname>" >> /tmp/discopacket
echo " <driver>$DRIVER</driver>" >> /tmp/discopacket
if [ ! -z "$ADDRESS" ]; then
echo " <ip4address>$ADDRESS</ip4address>" >> /tmp/discopacket
fi
echo " <hwaddr>$MAC</hwaddr>" >> /tmp/discopacket
if [ ! -z "$PCI_SLOT" ]; then
echo " <pcidev>$PCI_SLOT</pcidev>" >> /tmp/discopacket
fi
if [ ! -z "$SLOTNAME" ]; then
echo " <location>$SLOTNAME</location>" >> /tmp/discopacket
fi
if [ ! -z "$ONBOARDINDEX" ]; then
echo " <onboardeth>$ONBOARDINDEX</onboardeth>" >> /tmp/discopacket
fi
if [ ! -z "$FIRMDESC" ]; then
echo " <firmdesc>$FIRMDESC</firmdesc>" >> /tmp/discopacket
fi
echo "<mac>$DRIVER|$dev|$MAC|$ADDRESS</mac>
<nic>
<devname>$dev</devname>
<driver>$DRIVER</driver>
${ADDRESS:+ <ip4address>$ADDRESS</ip4address>}
<hwaddr>$MAC</hwaddr>
${PCI_SLOT:+ <pcidev>$PCI_SLOT</pcidev>}
${SLOTNAME:+ <location>$SLOTNAME</location>}
${ONBOARDINDEX:+ <onboardeth>$ONBOARDINDEX</onboardeth>}
${FIRMDESC:+ <firmdesc>$FIRMDESC</firmdesc>}" >>/tmp/discopacket
myswitch=`lldptool -n -i $dev -t -V sysName|grep -v 'System Name TLV'|sed -e 's/^ *//'`
if [ ! -z "$myswitch" -a "$myswitch" != "Agent instance for device not found" ]; then
echo " <switchname>$myswitch</switchname>" >> /tmp/discopacket
Expand All @@ -271,32 +251,27 @@ for dev in `ip link|grep -B1 ether|grep UP|awk '{print $2}'|sed -e s/://|grep -v
echo "</nic>" >> /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>$UUID</uuid>" >> /tmp/discopacket
fi
echo "<xcatpubkey>$PUBKEY</xcatpubkey>" >> /tmp/discopacket #this is not secure to use by itself, switch sourced pubkey for security
echo "<sha512sig>" >> /tmp/discopacket
echo "</sha512sig>" >> /tmp/discopacket
echo "</xcatrequest>" >> /tmp/discopacket
#this is not secure to use by itself, switch sourced pubkey for security
echo "<xcatpubkey>$PUBKEY</xcatpubkey>
<sha512sig>
</sha512sig>
</xcatrequest>" >>/tmp/discopacket
openssl dgst -sha512 -out /tmp/discopacket.sha512 -sign /etc/xcat/privkey.pem /tmp/discopacket
openssl enc -e -a -in /tmp/discopacket.sha512 > /tmp/discopacket.b64sig
cat /tmp/discopacket |while read line; do
if [ "$line" = "</sha512sig>" ]; then
cat /tmp/discopacket.b64sig >> /tmp/discopacket.new
fi
echo $line >> /tmp/discopacket.new
done
mv /tmp/discopacket.new /tmp/discopacket
sed -i "/^<sha512sig>$/ r /tmp/discopacket.b64sig" /tmp/discopacket
logger -s -t $log_label -p local4.info "Discovery packet file is ready."
rm -f /tmp/discopacket.gz
gzip -9 /tmp/discopacket
if [ ! -z "$XCATMASTER" ]; then
logger -s -t $log_label -p local4.info "Sending the discovery packet to xCAT ($XCATMASTER:$XCATPORT)..."
(cat /tmp/discopacket.gz | udpcat.awk $XCATMASTER $XCATPORT ) &
logger -s -t $log_label -p local4.info "Sending the discovery packet to xCAT ($XCATMASTER:$XCATPORT)..."
(udpcat.awk $XCATMASTER $XCATPORT </tmp/discopacket.gz) &
fi
for dhcps in `grep dhcp-server /var/lib/dhclient/dhclient.leases|awk '{print $4}'|sed -s 's/;//'`; do
logger -s -t $log_label -p local4.info "Sending the discovery packet to xCAT ($dhcps:$XCATPORT)..."
(cat /tmp/discopacket.gz | udpcat.awk $dhcps $XCATPORT ) &
logger -s -t $log_label -p local4.info "Sending the discovery packet to xCAT ($dhcps:$XCATPORT)..."
(udpcat.awk $dhcps $XCATPORT </tmp/discopacket.gz) &
done

#record the time when the "findme request is sent to master"
Expand Down
2 changes: 1 addition & 1 deletion xCAT-genesis-scripts/usr/bin/dosysclone
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions xCAT-genesis-scripts/usr/bin/doxcat
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/bash
#
# 2013.02.07 Brian Elliott Finley <[email protected]>
# - Added slash in front of "var" in the NICSTOBRINGUP dhclient section.
Expand Down
86 changes: 41 additions & 45 deletions xCAT-genesis-scripts/usr/bin/getadapter
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ for n in /sys/class/net/*; do
continue
else
echo '<nic>' >> "$ADAPTERFILE"
tmp=`udevadm info /sys/class/net/"$nic" | grep " INTERFACE" | awk -F '=' '{print $2}'`
tmp="$(udevadm info "/sys/class/net/$nic" | grep " INTERFACE" | awk -F '=' '{print $2}')"
if [ -n "$tmp" ]; then
echo "<interface>$tmp</interface>" >> "$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" | grep ID_NET_NAME | awk -F '=' '{print $2}'|sort -u| tr -s "\n" "/" | sed "s/\/$//g")"
if [ -n "$tmp" ]; then
echo "<predictablename>$tmp</predictablename>" >> "$ADAPTERFILE"
fi
tmp=`udevadm info /sys/class/net/"$nic" | grep DEVPATH | awk -F 'devices' '{print $2}'`
tmp="$(udevadm info "/sys/class/net/$nic" | grep DEVPATH | awk -F 'devices' '{print $2}')"
if [ -n "$tmp" ]; then
echo "<pcilocation>${tmp%/net*}</pcilocation>" >> "$ADAPTERFILE"
fi
echo "<mac>`cat /sys/class/net/$nic/address`</mac>" >> "$ADAPTERFILE"
tmp=`udevadm info /sys/class/net/"$nic" | grep ID_VENDOR_FROM_DATABASE | awk -F '=' '{print $2}' | tr -s "\n" "/" | sed "s/\/$//g"`
echo "<mac>$(cat "/sys/class/net/$nic/address")</mac>" >> "$ADAPTERFILE"
tmp="$(udevadm info "/sys/class/net/$nic" | grep ID_VENDOR_FROM_DATABASE | awk -F '=' '{print $2}' | tr -s "\n" "/" | sed "s/\/$//g")"
if [ -n "$tmp" ]; then
echo "<vendor>$tmp</vendor>" >> "$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" | grep ID_MODEL_FROM_DATABASE | awk -F '=' '{print $2}')"
if [ -n "$tmp" ]; then
echo "<model>$tmp</model>" >> "$ADAPTERFILE"
fi
tmp=`ip link show $nic`
tmp="$(ip link show "$nic")"
if [ -n "$tmp" ]; then
tmp=${tmp#*state }
echo "<linkstate>${tmp% mode*}</linkstate>" >> "$ADAPTERFILE"
Expand All @@ -55,57 +55,53 @@ 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 '<nic>' >> "$ADAPTERFILE"
echo "<pcilocation>$pci</pcilocation>" >> "$ADAPTERFILE"
echo "<model>${tmp##*:}</model>" >> "$ADAPTERFILE"
echo '</nic>' >> "$ADAPTERFILE"
fi
tmp="$(lspci |grep "$pci")"
echo "<nic>
<pcilocation>$pci</pcilocation>
<model>${tmp##*:}</model>
</nic>" >> "$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 '<nic>' >> "$ADAPTERFILE"
echo "<pcilocation>$pci</pcilocation>" >> "$ADAPTERFILE"
echo "<model>${tmp##*: }</model>" >> "$ADAPTERFILE"
echo '</nic>' >> "$ADAPTERFILE"
fi
tmp="$(lspci |grep "$pci")"
echo "<nic>
<pcilocation>$pci</pcilocation>
<model>${tmp##*: }</model>
</nic>" >> "$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 '<nic>' >> "$ADAPTERFILE"
echo "<pcilocation>$pci</pcilocation>" >> "$ADAPTERFILE"
echo "<model>${tmp##*: }</model>" >> "$ADAPTERFILE"
echo '</nic>' >> "$ADAPTERFILE"
fi
tmp="$(lspci |grep "$pci")"
echo "<nic>
<pcilocation>$pci</pcilocation>
<model>${tmp##*: }</model>
</nic>" >> "$ADAPTERFILE"
fi
done

echo "</xcatrequest>" >> "$ADAPTERFILE"

#cat "$ADAPTERFILE"

if [ -f /etc/xcat/cert.pem -a -f /etc/xcat/certkey.pem ]; then #use client cert if available
SSL_CERT_OPTS=( -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem )
fi
if [ -n "$XCATMASTER" ]; 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 $XCATMASTER" >> "$SCANNICLOG"
openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $XCATMASTER:$XCATPORT <"$ADAPTERFILE" >>"$SCANNICLOG" 2>&1
else
echo "transmit scan result without customer certificate to $XCATMASTER" >> "$SCANNICLOG"
openssl s_client -connect $XCATMASTER:$XCATPORT <"$ADAPTERFILE" >>"$SCANNICLOG" 2>&1
fi
TARGET="$XCATMASTER"
else
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"
openssl s_client -key /etc/xcat/certkey.pem -cert /etc/xcat/cert.pem -connect $dhcps:$XCATPORT <"$ADAPTERFILE" >>"$SCANNICLOG" 2>&1
else
echo "transmit scan result without customer certificate to $dhcps" >> "$SCANNICLOG"
openssl s_client -connect $dhcps:$XCATPORT <"$ADAPTERFILE" >>"$SCANNICLOG" 2>&1
fi
TARGET="$(awk -F ' |;' '/dhcp-server/ { print $(NF-1) }' /var/lib/dhclient/dhclient.leases | tail -n 1)"
fi
if [ -n "$TARGET" ]; then
if [[ "${#SSL_CERT_OPTS[@]}" -gt 0 ]]; then #use client cert if available
echo "using /etc/xcat/certkey.pem and /etc/xcat/cert.pem to transmit scan result to $TARGET" >> "$SCANNICLOG"
else
echo "transmit scan result without customer certificate to $TARGET" >> "$SCANNICLOG"
fi
fi
openssl s_client "${SSL_CERT_OPTS[@]}" -connect "$TARGET:$XCATPORT" <"$ADAPTERFILE" >>"$SCANNICLOG" 2>&1
fi
Loading