From da5d725379fff33a445c0b0a5c510b62e2485c88 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Wed, 21 Sep 2016 16:11:40 +0200 Subject: Fixed lunasa-del script. --- tools/lunasa-del | 39 ++++++++++++++++++++++++++------------- 1 file 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 -- cgit