sg-ddns-update.sh 557 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash
  2. _DOMAIN=$1
  3. _PSK=$(<../host.psk)
  4. _DATE=$(date +%s)
  5. _SGVPN='10.0.4.2'
  6. #_SGVPN=''
  7. trim() {
  8. while read line; do
  9. if [[ "$line" == "${line//#}" && "$line" == "${line//-----}" ]]; then
  10. echo -n $line
  11. fi
  12. done <<< "$_PSK"
  13. }
  14. _MD5=$(trim | md5sum)
  15. _MD5=${_MD5// *}
  16. _DOMAIN=$(printf '%s' $_DOMAIN | base64)
  17. _JSON='{"jsonrpc": "2.0", "client": "'$_MD5'", "domain": "'$_DOMAIN'", "sgvpn": "'$_SGVPN'"}'
  18. #wget -q --post-data "data=$_JSON" https://superglue.it/ddns/update -O -
  19. curl -k -d "data=$_JSON" https://superglue.it/ddns/update