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
d99add0b
Commit
d99add0b
authored
7 years ago
by
Mathis Rosenhauer
Browse files
Options
Downloads
Patches
Plain Diff
Avoid using temp files
parent
6ddb72e5
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
+9
-22
9 additions, 22 deletions
startvnc
with
9 additions
and
22 deletions
startvnc
+
9
−
22
View file @
d99add0b
...
...
@@ -39,26 +39,21 @@ readonly SVNC_SSH_MUX="true" # use sharing of multiple ssh sessions
clean_up
()
{
trap
- ERR EXIT
set
+e
local
tmp_files
=
"
${
job_script_name
}
"
if
[[
${
vnc_host
}
]]
;
then
ssh_mistral
"ssh
${
vnc_host
}
\"
/opt/TurboVNC/bin/vncserver
\
-kill :
${
vnc_display
}
\"
"
fi
echo
"Removing job
and temporary files
."
echo
"Removing job."
if
[[
${
job_id
}
]]
;
then
tmp_files
=
"
${
tmp_files
}
out.
${
job_id
}
gethost.
${
job_id
}
"
ssh_mistral
"scancel -Q
${
job_id
}
; sleep 1
"
ssh_mistral
"scancel -Q
${
job_id
}
; sleep 1;
\
cd .startvnc && rm -f out.
${
job_id
}
"
else
echo
"Job ID not available. Make sure the vncjob is not running!"
ssh_mistral
"squeue -u
${
SVNC_USERNAME
}
"
fi
if
[[
-n
${
tmp_files
}
]]
;
then
ssh_mistral
"cd .startvnc && rm -f
${
tmp_files
}
"
fi
if
[[
${
SVNC_SSH_MUX
}
=
"true"
]]
;
then
ssh_mistral
""
"-O exit"
rmdir
"
${
ssh_socket_dir
}
"
...
...
@@ -125,7 +120,8 @@ parse_options () {
fi
}
check_vnc_password
()
{
prepare_vncserver
()
{
ssh_mistral
"mkdir -p .startvnc"
if
!
ssh_mistral
"test -s .vnc/passwd"
;
then
echo
"No VNC password found. Please set now."
ssh_mistral
"salloc -Q -n1 -pgpu -A
${
SVNC_ACCTCODE
}
-- /bin/bash -c
\
...
...
@@ -134,13 +130,8 @@ check_vnc_password () {
fi
}
get_job_script_name
()
{
ssh_mistral
"mkdir -p .startvnc && cd .startvnc && mktemp vncjob.XXXXX"
}
submit_vnc_job
()
{
local
job_script_name
=
"
$1
"
ssh_mistral
"cat > .startvnc/
${
job_script_name
}
"
<<
EOF
ssh_mistral
"cd .startvnc && sbatch"
<<
EOF
#!/bin/bash -l
#SBATCH --partition=gpu
#SBATCH --ntasks=12
...
...
@@ -153,13 +144,11 @@ submit_vnc_job () {
cd
\$
{HOME}
/opt/TurboVNC/bin/vncserver -fg -geometry "
${
SVNC_GEOMETRY
}
" -localhost
EOF
ssh_mistral
"cd .startvnc && sbatch
${
job_script_name
}
"
}
get_vnc_host_and_display
()
{
local
job_id
=
"
$1
"
ssh_mistral
"cat > .startvnc/gethost.
${
job_id
}
"
<<
EOF
#!/bin/bash
ssh_mistral
"/bin/bash"
<<
EOF
logfile=
\$
{HOME}/.startvnc/out.
${
job_id
}
while [[ -z
\$
{host_and_display} ]]; do
sleep 1
...
...
@@ -170,7 +159,6 @@ while [[ -z \${host_and_display} ]]; do
done
echo
\$
{host_and_display}
EOF
ssh_mistral
"/bin/bash .startvnc/gethost.
${
job_id
}
"
}
main
()
{
...
...
@@ -182,11 +170,10 @@ main () {
ssh_mistral
""
"-MNf"
fi
check_vnc_password
prepare_vncserver
job_script_name
=
$(
get_job_script_name
)
echo
"Submitting vncserver job."
job_id
=
$(
submit_vnc_job
"
${
job_script_name
}
"
)
job_id
=
$(
submit_vnc_job
)
echo
"Waiting for job
${
job_id
}
to start."
local
host_and_display
=
$(
get_vnc_host_and_display
"
$job_id
"
)
...
...
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