Skip to content
Snippets Groups Projects
Commit d8429d50 authored by Mathis Rosenhauer's avatar Mathis Rosenhauer
Browse files

Break lines below 80

parent 0ebc4d62
No related branches found
No related tags found
No related merge requests found
......@@ -16,15 +16,21 @@
set -e
# User defined variables
USERNAME=<user> # <-- Set here your account number
ACCTCODE=<project> # <-- Set here your project number
TIME=240 # <-- Set here the running time in minutes
QOS=normal # <-- Set here an alternative QOS if desired
GEOMETRY=${1:-'1920x1200'} # <-- Set here the resolution of your remote desktop window
VNCVIEWER=/usr/bin/vncviewer # <-- Set here the correct path to your local vncviewer, i.e. TightVNC
PASSWORD=true # <-- If enabled, the vncpassword will be temporarily copied to the local workstation (only works with TurboVNC)
# End of user defined variables
TIME=240 # <-- Set here the running time in
# minutes
QOS=normal # <-- Set here an alternative QOS
# if desired
GEOMETRY=${1:-'1920x1200'} # <-- Set here the resolution of
# your remote desktop window
VNCVIEWER=/usr/bin/vncviewer # <-- Set here the correct path to
# your local vncviewer, e.g.
# TurboVNC
PASSWORD=true # <-- If enabled, the vncpassword
# will be temporarily copied to
# the local workstation (only
# works with TurboVNC)
clean_up () {
trap - ERR
......@@ -38,20 +44,24 @@ clean_up () {
if [[ ${vnc_host_display} && ${xvnc_pid} ]]; then
# Kill Xvnc process. Mainly done to remove lock file.
local vnc_host=$(echo ${vnc_host_display} | cut -d':' -f1)
ssh ${USERNAME}@mistral.dkrz.de "ssh ${USERNAME}@${vnc_host} \"kill ${xvnc_pid}\"" 2> /dev/null
ssh ${USERNAME}@mistral.dkrz.de \
"ssh ${USERNAME}@${vnc_host} \"kill ${xvnc_pid}\"" 2> /dev/null
fi
if [[ ${job_id} ]]; then
# Clean up temp files and cancel job
tmp_files="${tmp_files} out.${job_id} out.${job_id}_DKRZepilog vnc_gethost.${job_id}"
ssh ${USERNAME}@mistral.dkrz.de "scancel ${job_id}; sleep 1" 2> /dev/null
tmp_files="${tmp_files} out.${job_id} out.${job_id}_DKRZepilog \
vnc_gethost.${job_id}"
ssh ${USERNAME}@mistral.dkrz.de \
"scancel ${job_id}; sleep 1" 2> /dev/null
else
echo "Job ID not available. Make sure the vncjob is not running!"
ssh ${USERNAME}@mistral.dkrz.de "squeue -u ${USERNAME}"
fi
if [[ ${tmp_files} ]]; then
ssh ${USERNAME}@mistral.dkrz.de "cd .startvnc && rm -f ${tmp_files}" 2> /dev/null
ssh ${USERNAME}@mistral.dkrz.de \
"cd .startvnc && rm -f ${tmp_files}" 2> /dev/null
fi
# Remove local vnc PasswordFile
......@@ -61,10 +71,13 @@ clean_up () {
exit
}
trap 'clean_up "${job_id}" "${vnc_host_display}" "${xvnc_pid}" "${job_script}"' INT QUIT TERM ERR
trap 'clean_up \"${job_id}\" \"${vnc_host_display}\" \"${xvnc_pid}\" \
\"${job_script}\"' INT QUIT TERM ERR
job_script=$(ssh ${USERNAME}@mistral.dkrz.de 'mkdir -p .startvnc && cd .startvnc && mktemp vncjob.XXXXX')
ssh ${USERNAME}@mistral.dkrz.de "mkdir -p .startvnc; cat > .startvnc/${job_script}" <<EOF
job_script=$(ssh ${USERNAME}@mistral.dkrz.de \
'mkdir -p .startvnc && cd .startvnc && mktemp vncjob.XXXXX')
ssh ${USERNAME}@mistral.dkrz.de \
"mkdir -p .startvnc; cat > .startvnc/${job_script}" <<EOF
#!/bin/bash
#SBATCH --partition=gpu
#SBATCH --ntasks=12
......@@ -78,7 +91,8 @@ cd \${HOME}
EOF
echo "Submitting Xvnc job."
job_id=$(ssh ${USERNAME}@mistral.dkrz.de "cd .startvnc && sbatch ${job_script}" | grep -Po "\b[0-9]+$")
job_id=$(ssh ${USERNAME}@mistral.dkrz.de \
"cd .startvnc && sbatch ${job_script}" | grep -Po "\b[0-9]+$")
ssh ${USERNAME}@mistral.dkrz.de "cat > .startvnc/vnc_gethost.${job_id}" <<EOF
#!/bin/bash
......@@ -87,19 +101,24 @@ LOGFILE=out.${job_id}
while [ -z \${vnc_host_display} ]; do
sleep 1
if [[ -f \${LOGFILE} ]]; then
vnc_host_display=\$(grep -Po "started on display \Kmg[0-9]+:[0-9]+" \${LOGFILE})
vnc_host_display=\$(grep -Po "started on display \Kmg[0-9]+:[0-9]+" \
\${LOGFILE})
fi
done
echo \${vnc_host_display}
EOF
echo "Waiting for job ${job_id} to start."
vnc_host_display=$(ssh ${USERNAME}@mistral.dkrz.de "/bin/bash .startvnc/vnc_gethost.${job_id}")
xvnc_pid=$(ssh ${USERNAME}@mistral.dkrz.de "cat .vnc/${vnc_host_display}.pid")
vnc_host_display=$(ssh ${USERNAME}@mistral.dkrz.de \
"/bin/bash .startvnc/vnc_gethost.${job_id}")
xvnc_pid=$(ssh ${USERNAME}@mistral.dkrz.de \
"cat .vnc/${vnc_host_display}.pid")
# Start VNC client
if [[ ${PASSWORD} == true ]]; then
scp ${USERNAME}@mistral.dkrz.de:~/.vnc/passwd ~/.vnc/passwd2
${VNCVIEWER} -via ${USERNAME}@mistral.dkrz.de ${vnc_host_display} -PasswordFile ~/.vnc/passwd2
${VNCVIEWER} -via ${USERNAME}@mistral.dkrz.de ${vnc_host_display} \
-PasswordFile ~/.vnc/passwd2
else
${VNCVIEWER} -via ${USERNAME}@mistral.dkrz.de ${vnc_host_display}
fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment