summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-09-21 16:11:40 +0200
committerEndi S. Dewata <edewata@redhat.com>2016-09-21 16:11:40 +0200
commitda5d725379fff33a445c0b0a5c510b62e2485c88 (patch)
tree5e5184a9a721dfd2ce1822d448b563e8389f21e2
parent46f2537cf5947ced95d73cde6dbb165c461d6b0f (diff)
downloadpki-dev-da5d725379fff33a445c0b0a5c510b62e2485c88.tar.gz
pki-dev-da5d725379fff33a445c0b0a5c510b62e2485c88.tar.xz
pki-dev-da5d725379fff33a445c0b0a5c510b62e2485c88.zip
Fixed lunasa-del script.
-rwxr-xr-xtools/lunasa-del39
1 files changed, 26 insertions, 13 deletions
diff --git a/tools/lunasa-del b/tools/lunasa-del
index a5cfe8a..8f5837d 100755
--- a/tools/lunasa-del
+++ b/tools/lunasa-del
@@ -82,40 +82,53 @@ echo "Searching for objects with prefix: $prefix"
/usr/safenet/lunaclient/bin/cmu list -display handle,id,label -class certificate -password $password | while read cert
do
- label=$(echo $cert | cut -d' ' -f3 | cut -d= -f2)
+ label=$(echo $cert | sed 's/^.*label=\(.*\)$/\1/')
+
+ if [[ "$verbose" != "" ]]
+ then
+ echo "object: $label"
+ fi
if [[ "$label" == "$prefix"* ]]
then
- echo "object: $label"
+ echo "deleting object: $label"
- id=$(echo $cert | cut -d' ' -f2 | cut -d= -f2)
+ id=$(echo $cert | sed 's/^.*id=\([^ ]*\).*$/\1/')
echo " - id: $id"
- certHandle=$(echo $cert | cut -d' ' -f1 | cut -d= -f2)
+ certHandle=$(echo $cert | sed 's/^handle=\([^ ]*\).*$/\1/')
echo " - certificate: $certHandle"
- if [ "$run" == "1" ]
+ if [[ "$run" == "1" ]]
then
/usr/safenet/lunaclient/bin/cmu delete -handle $certHandle -force -password $password
fi
publicKey=$(/usr/safenet/lunaclient/bin/cmu list -display handle -id $id -class public -password $password)
- publicKeyHandle=$(echo $publicKey | cut -d' ' -f1 | cut -d= -f2)
- echo " - public key: $publicKeyHandle"
+ publicKeyHandle=$(echo $publicKey | sed 's/^handle=\([^ ]*\).*$/\1/')
- if [ "$run" == "1" ]
+ if [[ "$publicKeyHandle" != "" ]]
then
- /usr/safenet/lunaclient/bin/cmu delete -handle $publicKeyHandle -force -password $password
+ echo " - public key: $publicKeyHandle"
+
+ if [[ "$run" == "1" ]]
+ then
+ /usr/safenet/lunaclient/bin/cmu delete -handle $publicKeyHandle -force -password $password
+ fi
fi
privateKey=$(/usr/safenet/lunaclient/bin/cmu list -display handle -id $id -class private -password $password)
- privateKeyHandle=$(echo $privateKey | cut -d' ' -f1 | cut -d= -f2)
- echo " - private key: $privateKeyHandle"
+ privateKeyHandle=$(echo $privateKey | sed 's/^handle=\([^ ]*\).*$/\1/')
- if [ "$run" == "1" ]
+ if [[ "$privateKeyHandle" != "" ]]
then
- /usr/safenet/lunaclient/bin/cmu delete -handle $privateKeyHandle -force -password $password
+ echo " - private key: $privateKeyHandle"
+
+ if [[ "$run" == "1" ]]
+ then
+ /usr/safenet/lunaclient/bin/cmu delete -handle $privateKeyHandle -force -password $password
+ fi
fi
fi