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
f1b8b704
Commit
f1b8b704
authored
8 years ago
by
Mathis Rosenhauer
Browse files
Options
Downloads
Patches
Plain Diff
Use constant
parent
d8429d50
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
+18
-21
18 additions, 21 deletions
startvnc.sh
with
18 additions
and
21 deletions
startvnc.sh
+
18
−
21
View file @
f1b8b704
...
...
@@ -32,6 +32,8 @@ PASSWORD=true # <-- If enabled, the vncpassword
# the local workstation (only
# works with TurboVNC)
MISTRAL
=
"
${
USERNAME
}
@mistral.dkrz.de"
clean_up
()
{
trap
- ERR
set
+e
...
...
@@ -44,24 +46,22 @@ 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
${
MISTRAL
}
"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
ssh
${
MISTRAL
}
"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
}
"
ssh
${
MISTRAL
}
"squeue -u
${
USERNAME
}
"
fi
if
[[
${
tmp_files
}
]]
;
then
ssh
${
USERNAME
}
@mistral.dkrz.de
\
"cd .startvnc && rm -f
${
tmp_files
}
"
2> /dev/null
ssh
${
MISTRAL
}
"cd .startvnc && rm -f
${
tmp_files
}
"
2> /dev/null
fi
# Remove local vnc PasswordFile
...
...
@@ -74,10 +74,9 @@ clean_up () {
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
${
MISTRAL
}
'mkdir -p .startvnc && cd .startvnc && mktemp vncjob.XXXXX'
)
ssh
${
MISTRAL
}
"mkdir -p .startvnc; cat > .startvnc/
${
job_script
}
"
<<
EOF
#!/bin/bash
#SBATCH --partition=gpu
#SBATCH --ntasks=12
...
...
@@ -91,10 +90,10 @@ 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
${
MISTRAL
}
"cd .startvnc && sbatch
${
job_script
}
"
\
|
grep
-Po
"
\b
[0-9]+$"
)
ssh
${
USERNAME
}
@mistral.dkrz.de
"cat > .startvnc/vnc_gethost.
${
job_id
}
"
<<
EOF
ssh
${
MISTRAL
}
"cat > .startvnc/vnc_gethost.
${
job_id
}
"
<<
EOF
#!/bin/bash
cd "
\$
{0%/*}"
LOGFILE=out.
${
job_id
}
...
...
@@ -109,18 +108,16 @@ 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
${
MISTRAL
}
"/bin/bash .startvnc/vnc_gethost.
${
job_id
}
"
)
xvnc_pid
=
$(
ssh
${
MISTRAL
}
"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
}
\
scp
${
MISTRAL
}
:~/.vnc/passwd ~/.vnc/passwd2
${
VNCVIEWER
}
-via
${
MISTRAL
}
${
vnc_host_display
}
\
-PasswordFile
~/.vnc/passwd2
else
${
VNCVIEWER
}
-via
${
USERNAME
}
@mistral.dkrz.de
${
vnc_host_display
}
${
VNCVIEWER
}
-via
${
MISTRAL
}
${
vnc_host_display
}
fi
clean_up
"
${
job_id
}
"
"
${
vnc_host_display
}
"
"
${
xvnc_pid
}
"
"
${
job_script
}
"
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