Commit 756529a0 authored by Dietmar Maurer's avatar Dietmar Maurer

spice-example-sh: improve error handling

parent 6b9f274b
#!/bin/bash #!/bin/bash
set -e
# needs pve-manager >= 3.1-44 # needs pve-manager >= 3.1-44
usage() { usage() {
...@@ -57,7 +59,9 @@ fi ...@@ -57,7 +59,9 @@ fi
NODE=${NODE%%\.*} NODE=${NODE%%\.*}
DATA=`curl -k -d "username=$USERNAME&password=$PASSWORD" https://$PROXY:8006/api2/json/access/ticket` DATA=$(curl -f -s -S -k -d "username=$USERNAME&password=$PASSWORD" https://$PROXY:8006/api2/json/access/ticket)
echo "AUTH OK"
TICKET=${DATA//\"/} TICKET=${DATA//\"/}
TICKET=${TICKET##*ticket:} TICKET=${TICKET##*ticket:}
...@@ -67,6 +71,6 @@ CSRF=${DATA//\"/} ...@@ -67,6 +71,6 @@ CSRF=${DATA//\"/}
CSRF=${CSRF##*CSRFPreventionToken:} CSRF=${CSRF##*CSRFPreventionToken:}
CSRF=${CSRF%%,*} CSRF=${CSRF%%,*}
curl -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" https://$PROXY:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy -d "proxy=$PROXY" > spiceproxy curl -f -s -S -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" https://$PROXY:8006/api2/spiceconfig/nodes/$NODE/qemu/$VMID/spiceproxy -d "proxy=$PROXY" > spiceproxy
remote-viewer spiceproxy remote-viewer spiceproxy
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment