mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-04-11 13:20:23 +00:00
Add -h|--help option.
This commit is contained in:
parent
12d03ea2ea
commit
3435265c5a
@ -15,8 +15,8 @@ else
|
||||
fi
|
||||
|
||||
#set parameter names and call getopts on inputsi, then parse/assign arguments
|
||||
SHORTOPTS=m:s:
|
||||
LONGOPTS=start-date:,end-date:,ip:,system-only,component-only,manufacturer:,serial:
|
||||
SHORTOPTS=m:s:h
|
||||
LONGOPTS=start-date:,end-date:,ip:,system-only,component-only,manufacturer:,serial:,help
|
||||
PARSED=$(getopt --options=$SHORTOPTS --longoptions=$LONGOPTS --name "$0" -- "$@")
|
||||
if [[ ${PIPESTATUS[0]} -ne 0 ]]
|
||||
then
|
||||
@ -30,6 +30,15 @@ system=
|
||||
component=
|
||||
manufacturer=
|
||||
serial=
|
||||
|
||||
helpText="\n\n\nHELP MENU\n\nThe following options are available:\n--start-date\t\t<yyyy-mm-dd>\tDefault: 1970-01-01\tThe earliest date to return validation reports from.\n"
|
||||
helpText+="--end-date\t\t<yyyy-mm-dd>\tDefault: current time\tThe latest date to return validation reports from.\n"
|
||||
helpText+="--ip\t\t\t<ACA address>\tDefault: localhost\tThe IP address where the ACA is located.\n"
|
||||
helpText+="--system-only\t\t\t\t\t\t\tReturn only system information from validation reports.\n"
|
||||
helpText+="--component-only\t\t\t\t\t\tReturn only component information from validation reports.\n"
|
||||
helpText+="-m|--manufacturer\t<manufacturer's name>\t\t\tReturn only the validation report of the device from this manufacturer.\n"
|
||||
helpText+="-s|--serial\t\t<serial number>\t\t\t\tReturn only the validation report of the device with this serial number.\n"
|
||||
|
||||
while true
|
||||
do
|
||||
case "$1" in
|
||||
@ -61,6 +70,10 @@ do
|
||||
serial="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
printf "$helpText"
|
||||
exit 0
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
@ -78,6 +91,8 @@ echo "start date: $startDate, end date: $endDate, ip: $ip, system: $system, comp
|
||||
endpoint="https://$ip:8443/HIRS_AttestationCAPortal/portal/validation-reports"
|
||||
echo "$endpoint"
|
||||
content=$(curl --insecure $endpoint/list)
|
||||
|
||||
#Parse JSON response for create times and device names
|
||||
rawTimes=$(jq -r '.data | map(.createTime | tostring) | join(",")' <<< "$content")
|
||||
createTimes=""
|
||||
for i in ${rawTimes//,/ }
|
||||
@ -85,6 +100,7 @@ do
|
||||
createTimes+="$(date -u +"%Y-%m-%d %H:%M:%S" -d @"$(($i/1000))"),"
|
||||
done
|
||||
deviceNames=$(jq -r '.data | map(.device.name) | join(",")' <<< "$content")
|
||||
|
||||
echo "Create times: $createTimes"
|
||||
echo "Device names: $deviceNames"
|
||||
curl --data "dateStart=$startDate&dateEnd=$endDate&createTimes=$createTimes&deviceNames=$deviceNames&system=$system&component=$component&manufacturer=$manufacturer&serial=$serial" --insecure $endpoint/download
|
||||
|
Loading…
x
Reference in New Issue
Block a user