Advertisement
jekarl

LATCH unreg file

Nov 2nd, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.06 KB | None | 0 0
  1. #!/bin/bash
  2. if [ "$1" == "debug" ]; then set -x; fi
  3. applicationId="INSERT app ID HERE"                                                                                                                                                                                                                                      
  4. secretkey="INSERT secret key HERE"
  5. LATCH="/root/home/latch.accounts"
  6. account=`grep "^$USER:" $LATCH |cut -d: -f2`
  7. URL="/api/0.6/unpair/$account"
  8. if [ -z "$account" ]; then echo -e "Error.";  exit 0; fi
  9. requestSignature+="GET\n"
  10. date=`date -u '+%Y-%m-%d %H:%M:%S'`
  11. requestSignature+="$date\n\n$URL"
  12. signed=`echo -en "$requestSignature" | openssl dgst -sha1 -hmac "$secretkey" -binary|sed -e 's|.*= \(.*\)|\1|g'`
  13. b64signed=`echo -n "$signed"|base64`
  14. auth_header="Authorization:11PATHS $applicationId $b64signed"
  15. date_header="X-11Paths-Date: $date"
  16. JSON=`wget -q --no-check-certificate -O - --header "$auth_header" --header "$date_header" "https://latch.elevenpaths.com$URL"`
  17. grep -v "^$USER:" $LATCH > /tmp/$$.tmp
  18. mv /tmp/$$.tmp $LATCH
  19. echo -e "\nDone.\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement