Skip to content

Instantly share code, notes, and snippets.

@lokulin
Created September 13, 2015 06:27
Show Gist options
  • Save lokulin/7e733e6d00641e1ce17f to your computer and use it in GitHub Desktop.
Save lokulin/7e733e6d00641e1ce17f to your computer and use it in GitHub Desktop.
Get the vpn status from a QNAP appliance and return a JSON string
#!/usr/bin/env bash
BASE_URI="https://127.0.0.1/cgi-bin"
USER=""
ENCPWD=""
sid=$(curl --silent "${BASE_URI}/authLogin.cgi?user=${USER}&pwd=${ENCPWD}" | xmlstarlet sel -t -v "QDocRoot/authSid" -)
function get_status {
curl --silent "${BASE_URI}/application/appRequest.cgi?subfunc=vpn_client&sid=${sid}" |
xmlstarlet sel -t \
-o '{"status":' -v "QDocRoot/func/ownContent/OpenVPNClient/Data/status" \
-o ',"tx":' -v "QDocRoot/func/ownContent/OpenVPNClient/Data/tx" \
-o ',"rx":' -v "QDocRoot/func/ownContent/OpenVPNClient/Data/rx" \
-o ',"timestamp":' -v "QDocRoot/func/ownContent/OpenVPNClient/Data/timestamp" -o "}
" -
}
get_status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment