Commit 7305b84d authored by Mathis Rosenhauer's avatar Mathis Rosenhauer

start-vnc: make killing vncserver optional

parent aa6ec008
......@@ -111,33 +111,40 @@ readonly SVNC_FRONTEND_HOST="mistral.dkrz.de"
#
# If your vncviewer client has trouble with TurboVNC's password format
# then disable this option (set to "false" or comment).
readonly SVNC_PASSWORD="true"
readonly SVNC_PASSWORD=true
# Kill vncserver job running if script ends for some reason
readonly SVNC_KILLSERVER=true
clean_up () {
trap - ERR EXIT
set +e
if [[ -n ${vnc_host:-} ]]; then
echo "Killing vncserver :${vnc_display} on ${vnc_host}."
ssh_frontend "ssh ${vnc_host} \"/opt/TurboVNC/bin/vncserver \
-kill :${vnc_display}\""
fi
if [[ -n ${job_id:-} ]]; then
echo "Removing job ${job_id}."
ssh_frontend "scancel -Q ${job_id}; sleep 1; \
rm -f .startvnc/out.${job_id}"
if ${SVNC_KILLSERVER}; then
if [[ -n ${vnc_host:-} ]]; then
echo "Killing vncserver :${vnc_display} on ${vnc_host}."
ssh_frontend "ssh ${vnc_host} \"/opt/TurboVNC/bin/vncserver \
-kill :${vnc_display}\""
fi
if [[ -n ${job_id:-} ]]; then
echo "Removing job ${job_id}."
ssh_frontend "scancel -Q ${job_id}; sleep 1; \
rm -f .startvnc/out.${job_id}"
else
echo "Job ID not available. Make sure the vncjob is not running!"
ssh_frontend "squeue -u ${SVNC_USERNAME}"
fi
else
echo "Job ID not available. Make sure the vncjob is not running!"
ssh_frontend "squeue -u ${SVNC_USERNAME}"
echo "Kept job ${job_id} running."
fi
ssh_frontend "" "-O exit"
rmdir "${ssh_socket_dir}"
# Remove local vnc PasswordFile
if [[ ${SVNC_PASSWORD} = "true" ]]; then
if ${SVNC_PASSWORD}; then
rm -f "vnc_passwd"
fi
exit
......@@ -288,21 +295,21 @@ main () {
echo "Vncserver started on node ${vnc_host}.dkrz.de display \
:${vnc_display}."
local vnc_port_local=$((5900 + RANDOM % 100))
# WSL doesn't seem to detect used ports so randomize
# local port to reduce risk of masking.
local vnc_port_local=$((5900 + RANDOM % 100))
local vnc_port_remote=$(( 5900 + vnc_display ))
while ! ssh -o ForwardX11=no \
-o StrictHostKeyChecking=accept-new \
-L "${vnc_port_local}:localhost:${vnc_port_remote}" \
-Nf \
"${SVNC_USERNAME}@${vnc_host}.dkrz.de"; do
until ssh -o ForwardX11=no \
-o StrictHostKeyChecking=accept-new \
-L "${vnc_port_local}:localhost:${vnc_port_remote}" \
-Nf \
"${SVNC_USERNAME}@${vnc_host}.dkrz.de"; do
vnc_port_local=$((5900 + RANDOM % 100))
echo "Trying local port ${vnc_port_local}."
done
local client_options
client_options="${SVNC_CLIENT_OPTIONS:-}"
if [[ ${SVNC_PASSWORD} = "true" ]]; then
if ${SVNC_PASSWORD}; then
echo "Fetching password from frontend."
ssh_frontend "cat .vnc/passwd" > vnc_passwd
client_options+=" -passwd vnc_passwd"
......
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