-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcontroller-0.1_delinstance.sh
executable file
·34 lines (27 loc) · 1.11 KB
/
controller-0.1_delinstance.sh
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
28
29
30
31
32
33
34
#!/bin/bash
if [ -f "num_instances" ]; then
num_ccp=$(cat num_instances)
else
exit
fi
if [ $num_ccp = "0" ]; then
exit
fi
ccp_name="cybr_ccp_"
iter=`expr 4 - $(expr length $(expr $num_ccp + 1))`
for ((i=0; i<iter; i++));
do
ccp_name=$ccp_name"0"
done
ccp_name=$ccp_name$(expr $num_ccp)
echo $(expr $num_ccp - 1) > num_instances
docker rm -f $ccp_name
vol_dir="/home/rob/volumes/$ccp_name"
rm -rf $vol_dir
pvwapass=$(/opt/CARKaim/sdk/clipasswordsdk GetPassword -p "AppDescs.AppID=ProvAuth" -p "Query=Safe=ProvAuth;Object=ProvAuth" -o Password)
pvwauser=$(/opt/CARKaim/sdk/clipasswordsdk GetPassword -p "AppDescs.AppID=ProvAuth" -p "Query=Safe=ProvAuth;Object=ProvAuth" -o PassProps.UserName)
pvwaurl="https://components.cyberarkdemo.com/PasswordVault"
logonurl="$pvwaurl/API/auth/Cyberark/Logon"
deluserurl="$pvwaurl/WebServices/PIMServices.svc/Users"
token=$(curl -s -X POST -H "Content-Type: application/json" -k -d "{'username':'$pvwauser','password':'$pvwapass'}" $logonurl | tr -d \")
curl -s -k -X DELETE -H "Content-Type: application/json" -H "Authorization: $token" $deluserurl"/Prov_"$ccp_name