Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
ssh_scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sofiane Bendoukha
ssh_scripts
Commits
0ea299eb
Commit
0ea299eb
authored
8 years ago
by
Mathis Rosenhauer
Browse files
Options
Downloads
Patches
Plain Diff
Niklas' changes
parent
e93bd495
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
startvnc.sh
+80
-0
80 additions, 0 deletions
startvnc.sh
with
80 additions
and
0 deletions
startvnc
→
startvnc
.sh
+
80
−
0
View file @
0ea299eb
...
...
@@ -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
"
\b
mg[0-9]+:[0-9]$"
)
VNC_HOST_DISPLAY=
$(
grep
"started on display"
$LOGFILE
2> /dev/null |
grep
-Eoe
"
\b
mg[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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment