vm_control_init
This commit is contained in:
commit
dc7e235922
|
@ -0,0 +1,52 @@
|
|||
#!/bin/sh
|
||||
|
||||
USERNAME="$1"
|
||||
PASSWORD="$2"
|
||||
REALM="$3"
|
||||
TARGET_VMID="$4"
|
||||
HOST="https://vmsrv01.viewanime.net"
|
||||
NODE="proxmox"
|
||||
|
||||
JQ=$(which jq)
|
||||
if [ -z "$JQ" ]; then
|
||||
echo "Please install jq!"; exit 0
|
||||
fi
|
||||
|
||||
CURL=$(which curl)
|
||||
if [ -z "$CURL" ]; then
|
||||
echo "Please install curl!"; exit 0
|
||||
fi
|
||||
|
||||
|
||||
if [ "$5" = "current" ]; then
|
||||
TARGET_ACTION="$5"
|
||||
|
||||
elif [ "$5" = "reset" ]; then
|
||||
TARGET_ACTION="$5"
|
||||
|
||||
elif [ "$5" = "resume" ]; then
|
||||
TARGET_ACTION="$5"
|
||||
|
||||
elif [ "$5" = "shutdown" ]; then
|
||||
TARGET_ACTION="$5"
|
||||
|
||||
elif [ "$5" = "start" ]; then
|
||||
TARGET_ACTION="$5"
|
||||
|
||||
elif [ "$5" = "stop" ]; then
|
||||
TARGET_ACTION="$5"
|
||||
|
||||
elif [ "$5" = "suspend" ]; then
|
||||
TARGET_ACTION="$5"
|
||||
|
||||
fi
|
||||
|
||||
|
||||
OUTPUT=$($CURL -s -k -d "username=$USERNAME@$REALM&password=$PASSWORD" "$HOST/api2/json/access/ticket")
|
||||
|
||||
TICKET=$(echo "$OUTPUT" | jq -r '.data | .ticket')
|
||||
CSRF=$(echo "$OUTPUT" | jq -r '.data | .CSRFPreventionToken')
|
||||
|
||||
START_TASK_DATA=$($CURL -s -k -b "PVEAuthCookie=$TICKET" -H "CSRFPreventionToken: $CSRF" -X POST $HOST/api2/json/nodes/$NODE/qemu/$TARGET_VMID/status/$TARGET_ACTION)
|
||||
|
||||
echo "$START_TASK_DATA" | $JQ
|
Loading…
Reference in New Issue