frnmst-archives
/
qvm
Archived
1
0
Fork 0
Franco Masotti 4 years ago
parent
commit
1d921dbd20
  1. 20
      fbopt
  2. 16
      qvm

20
fbopt

@ -87,7 +87,7 @@ remote,vnc,mkdir-shared,nox,print-flags'
local install='false'
local nox='false'
local origin='false'
local remote=''
local remote='false'
local run='false'
local mkdir_shared='false'
local vnc='false'
@ -178,8 +178,8 @@ remote,vnc,mkdir-shared,nox,print-flags'
check_dependencies || exit ${?}
if [ "${attach}" = 'true' ]; then
[ "${remote}" = 'true' ] && place='remote' || place='local'
[ "${vnc}" = 'true' ] && display='vnc' || display=''
[ "${remote}" = 'remote' ] && place='remote' || place='local'
[ "${vnc}" = 'vnc' ] && display='vnc' || display=''
{ attach "${place}" "${display}"; return ${?}; }
fi
[ "${backup}" = 'true' ] && { backup; return ${?}; }
@ -187,10 +187,16 @@ remote,vnc,mkdir-shared,nox,print-flags'
[ "${delete}" = 'true' ] && { delete "${origin}"; return ${?}; }
[ "${install}" = 'true' ] && { installs "${vnc}"; return ${?}; }
if [ "${run}" = 'true' ]; then
[ "${vnc}" = 'vnc' ] && display='vnc'
[ "${nox}" = 'nox' ] && display='none'
[ -z "${display}" ] && display='gtk'
{ run "${display}" "${origin}"; return ${?}; }
if [ "${remote}" = 'remote' ]; then
# Start remote instance.
[ "${vnc}" = 'vnc' ] && display='vnc'
{ run_remote_instance "${display}"; return ${?}; }
else
[ "${vnc}" = 'vnc' ] && display='vnc'
[ "${nox}" = 'nox' ] && display='none'
[ -z "${display}" ] && display='gtk'
{ run "${display}" "${origin}"; return ${?}; }
fi
fi
[ "${mkdir_shared}" = 'true' ] && { mkdir_shared; return ${?}; }
}

16
qvm

@ -111,21 +111,13 @@ hostfwd=tcp::"${SSH_HOST_PORT}"-:"${SSH_GUEST_PORT}" \
-drive file="${vhd}" &
}
# -d, --default start the vm in headless mode and connect to it
# with SSH
# -h, --help print this help
# -u, --use-vnc start the vm in VNC mode and connect to it with the
# VNC client
#
# FIXME
#
# Start and connect to a remote QVM instance hosted on a different machine.
run_remote_instance()
{
local display="${1}"
if [ -z "$(ssh -l "${HOST_USERNAME}" "${HOST_IP_ADDRESS}" "pgrep qemu")" ]; then
if [ "${display}" = "use_vnc" ]; then
if [ "${display}" = 'vnc' ]; then
ssh -p ${SSH_EXPOSED_PORT} -l "${HOST_USERNAME}" "${HOST_IP_ADDRESS}" \
"cd "${HOST_QVM_SCRIPT_DIRECTORY}" && ./qvm --run-vnc" &
else
@ -135,10 +127,10 @@ run_remote_instance()
sleep ${SECONDS_BEFORE_CONNECTION_ATTEMPT}
fi
if [ "${display}" = "vnc" ]; then
"${local_path}"/qvm --remote &
if [ "${display}" = 'vnc' ]; then
"${local_path}"/qvm --attach --remote --vnc &
else
"${local_path}"/qvm --attach-remote
"${local_path}"/qvm --attach --remote
fi
}