|
|
@ -1,7 +1,9 @@ |
|
|
|
#!/bin/bash |
|
|
|
#!/bin/bash |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
echo "wsargs=$@" |
|
|
|
echo "wsargs=$@" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
domain_xml=$(</dev/stdin) |
|
|
|
guest_name="$1" |
|
|
|
guest_name="$1" |
|
|
|
operation="$2" |
|
|
|
operation="$2" |
|
|
|
|
|
|
|
|
|
|
@ -12,24 +14,35 @@ if [[ "$operation" == "started" || "$operation" == "stopped" ]] |
|
|
|
then |
|
|
|
then |
|
|
|
ws_open_flag="" |
|
|
|
ws_open_flag="" |
|
|
|
ws_port_flag="" |
|
|
|
ws_port_flag="" |
|
|
|
|
|
|
|
ws_suuid_flag="" |
|
|
|
|
|
|
|
|
|
|
|
if [[ "$operation" == "started" ]] |
|
|
|
if [[ "$operation" == "started" ]] |
|
|
|
then |
|
|
|
then |
|
|
|
ws_open_flag="--open" |
|
|
|
ws_open_flag="--open" |
|
|
|
|
|
|
|
|
|
|
|
# libvirt hooks cannot call anything related to libvirt, i.e., |
|
|
|
# Cannot call $ virsh vncdisplay... because libvirt hooks |
|
|
|
# virsh because a deadlock will happen. |
|
|
|
# cannot call anything related to libvirt, i.e., virsh, because |
|
|
|
server_vnc_port=$(grep "<graphics.*type=['\"]vnc['\"]" - | grep -oPm1 "(?<=port=['\"])\d+") |
|
|
|
# a deadlock will happen. |
|
|
|
|
|
|
|
server_vnc_port=$( grep "<graphics.*type=['\"]vnc['\"]" <<<$domain_xml | grep -oPm1 "(?<=port=['\"])\d+" ) |
|
|
|
ws_port_flag="--server-vnc-port ${server_vnc_port}" |
|
|
|
ws_port_flag="--server-vnc-port ${server_vnc_port}" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server_uuid=$( grep -oPm1 "(?<=<uuid>)[^\s]+(?=<)" <<<$domain_xml ) |
|
|
|
|
|
|
|
ws_suuid_flag="--server-uuid ${server_uuid}" |
|
|
|
|
|
|
|
|
|
|
|
local_host_uuid=$(</etc/anvil/host.uuid) |
|
|
|
local_host_uuid=$(</etc/anvil/host.uuid) |
|
|
|
|
|
|
|
|
|
|
|
update_sql="UPDATE servers SET server_host_uuid = '$local_host_uuid' WHERE server_name = '$guest_name';" |
|
|
|
update_sql="UPDATE servers SET server_host_uuid = '$local_host_uuid' WHERE server_name = '$guest_name';" |
|
|
|
echo "update=$update_sql" |
|
|
|
echo "wsupdate=$update_sql" |
|
|
|
anvil-access-module --query "$update_sql" --mode write |
|
|
|
anvil-access-module --query "$update_sql" --mode write |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
ws_command="striker-manage-vnc-pipes --server ${guest_name} --server-host-uuid local ${ws_port_flag} --component ws ${ws_open_flag}" |
|
|
|
ws_command_args="--server \"$guest_name\" $ws_suuid_flag --server-host-uuid local $ws_port_flag --component ws $ws_open_flag" |
|
|
|
echo "wscmd=$ws_command" |
|
|
|
echo "wscmd=$ws_command_args" |
|
|
|
$ws_command |
|
|
|
striker-manage-vnc-pipes --server "$guest_name" $ws_suuid_flag --server-host-uuid local $ws_port_flag --component ws $ws_open_flag |
|
|
|
|
|
|
|
echo "wscmd_exit=$?" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Don't interrupt libvirt regardless of whether websockify gets setup |
|
|
|
|
|
|
|
# successfully. |
|
|
|
|
|
|
|
exit 0 |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
} >>/var/log/anvil.log |
|
|
|