-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathism_cmd
executable file
·27 lines (22 loc) · 991 Bytes
/
ism_cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# (c) Juergen Orth ;-)
# $Id: ism_cmd 93 2022-05-25 08:00:34Z HMBJOrth $
[ "$DEBUG" ] && set -x
# get common settings like ip address and user credentials (ISM, ISM_IP, ISM_FQDN, ISM_PORT, USER, PASSWD, CACERT)
DIR=${0%/*}
PROG=${0##*/}
. ${DIR}/.ism_env
# just a default cmd ==> w/o params get node list
METHOD=${1:-GET}
CMD=${2:-'nodes'}; shift 2
[ -r "$CACERT" ] && CERTOPT="--cacert $CACERT" || { CERTOPT="-k"; echo "unsecure mode!" >&2; }
if [ "$session_id" ]
then
# With Session ID (you have to run 'export session_id=$(ism_login)' before running this script and afterwards "ism_logout")
AUTH="X-Ism-Authorization: $session_id"
else
# w/o Session ID = One Time Authorization
AUTH="Authorization: ISM $(openssl enc -aes-256-cbc -e -base64 -pass pass:$ISM_IP -A -md md5 <<<$USER:$PASSWD 2>/dev/null)"
fi
curl "https://$ISM_FQDN:$ISM_PORT/ism/api/v2/$CMD" -X ${METHOD^^} -H "$AUTH" -H "Content-Type: application/JSON; charset=UTF-8" $CERTOPT $DEFAULTOPTIONS $@
echo