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

Niklas' changes

parent e93bd495
No related branches found
No related tags found
No related merge requests found
......@@ -9,20 +9,23 @@
#
# The vncviewer client has to support the -via option. TightVNC is
# known to work.
#
# User defined variables
USERNAME=k202009
ACCTCODE=k20200
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
# End of user defined variables
GEOMETRY=${1:-'1920x1200'}
ssh ${USERNAME}@mistral.dkrz.de 'cat > vnc_runscript' \
<<'EOF_runscript'
ssh ${USERNAME}@mistral.dkrz.de 'cat > vnc_runscript' <<'EOF_runscript'
#!/bin/bash
ACCTCODE=$1
GEOMETRY=$2
TIME=$3
QOS=$4
JOBSCRIPT=$(mktemp job.XXXXX)
LOGFILE=$(mktemp out.XXXXX)
(
......@@ -30,6 +33,8 @@ cat <<EOF
#!/bin/bash
#SBATCH --partition=gpu
#SBATCH --ntasks=12
#SBATCH --qos=$QOS
#SBATCH --time=$TIME
#SBATCH --account=$ACCTCODE
#SBATCH --output=$LOGFILE
/opt/TurboVNC/bin/vncserver -fg -geometry $GEOMETRY
......@@ -39,8 +44,7 @@ EOF
JOB_ID=$(sbatch $JOBSCRIPT | grep -Eoe "\b[0-9]+$")
while [ -z $VNC_HOST_DISPLAY ]; do
sleep 1
VNC_HOST_DISPLAY=$(grep "started on display" $LOGFILE 2> /dev/null \
| grep -Eoe "\bmg[0-9]+:[0-9]$")
VNC_HOST_DISPLAY=$(grep "started on display" $LOGFILE 2> /dev/null | grep -Eoe "\bmg[0-9]+:[0-9]$")
done
rm -f $JOBSCRIPT
XVNC_PID=$(cat $HOME/.vnc/${VNC_HOST_DISPLAY}.pid)
......@@ -48,21 +52,29 @@ echo $JOB_ID $VNC_HOST_DISPLAY $LOGFILE $XVNC_PID
EOF_runscript
declare -a VARS
VARS=($(ssh mistral.dkrz.de "/bin/bash vnc_runscript $ACCTCODE $GEOMETRY"))
VARS=($(ssh ${USERNAME}@mistral.dkrz.de "/bin/bash vnc_runscript $ACCTCODE $GEOMETRY $TIME $QOS"))
JOB_ID=${VARS[0]}
VNC_HOST_DISPLAY=${VARS[1]}
LOGFILE=${VARS[2]}
XVNC_PID=${VARS[3]}
# Start VNC client
vncviewer -via mistral.dkrz.de $VNC_HOST_DISPLAY
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
else
$VNCVIEWER -via ${USERNAME}@mistral.dkrz.de $VNC_HOST_DISPLAY
fi
# Kill Xvnc process
VNC_HOST=$(echo $VNC_HOST_DISPLAY | cut -d':' -f1)
ssh -t ${USERNAME}@mistral.dkrz.de \
"ssh ${USERNAME}@$VNC_HOST \"kill $XVNC_PID\""
ssh ${USERNAME}@mistral.dkrz.de "ssh ${USERNAME}@$VNC_HOST \"kill $XVNC_PID\"" 2> /dev/null
# Clean up temp files and cancel job
RM_FILES="$LOGFILE ${LOGFILE}_DKRZepilog vnc_runscript"
ssh -t ${USERNAME}@mistral.dkrz.de \
"scancel $JOB_ID; sleep 1; rm -f $RM_FILES"
ssh ${USERNAME}@mistral.dkrz.de "scancel $JOB_ID; sleep 1; rm -f $RM_FILES" 2> /dev/null
# Remove local vnc PasswordFile
if [ "$PASSWORD" = true ] ; then
rm -f ~/.vnc/passwd
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