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
7305b84d
Commit
7305b84d
authored
5 years ago
by
Mathis Rosenhauer
Browse files
Options
Downloads
Patches
Plain Diff
start-vnc: make killing vncserver optional
parent
aa6ec008
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
start-vnc
+28
-21
28 additions, 21 deletions
start-vnc
with
28 additions
and
21 deletions
start-vnc
+
28
−
21
View file @
7305b84d
...
...
@@ -111,33 +111,40 @@ readonly SVNC_FRONTEND_HOST="mistral.dkrz.de"
#
# If your vncviewer client has trouble with TurboVNC's password format
# then disable this option (set to "false" or comment).
readonly
SVNC_PASSWORD
=
"true"
readonly
SVNC_PASSWORD
=
true
# Kill vncserver job running if script ends for some reason
readonly
SVNC_KILLSERVER
=
true
clean_up
()
{
trap
- ERR EXIT
set
+e
if
[[
-n
${
vnc_host
:-}
]]
;
then
echo
"Killing vncserver :
${
vnc_display
}
on
${
vnc_host
}
."
ssh_frontend
"ssh
${
vnc_host
}
\"
/opt/TurboVNC/bin/vncserver
\
-kill :
${
vnc_display
}
\"
"
fi
if
[[
-n
${
job_id
:-}
]]
;
then
echo
"Removing job
${
job_id
}
."
ssh_frontend
"scancel -Q
${
job_id
}
; sleep 1;
\
rm -f .startvnc/out.
${
job_id
}
"
if
${
SVNC_KILLSERVER
}
;
then
if
[[
-n
${
vnc_host
:-}
]]
;
then
echo
"Killing vncserver :
${
vnc_display
}
on
${
vnc_host
}
."
ssh_frontend
"ssh
${
vnc_host
}
\"
/opt/TurboVNC/bin/vncserver
\
-kill :
${
vnc_display
}
\"
"
fi
if
[[
-n
${
job_id
:-}
]]
;
then
echo
"Removing job
${
job_id
}
."
ssh_frontend
"scancel -Q
${
job_id
}
; sleep 1;
\
rm -f .startvnc/out.
${
job_id
}
"
else
echo
"Job ID not available. Make sure the vncjob is not running!"
ssh_frontend
"squeue -u
${
SVNC_USERNAME
}
"
fi
else
echo
"Job ID not available. Make sure the vncjob is not running!"
ssh_frontend
"squeue -u
${
SVNC_USERNAME
}
"
echo
"Kept job
${
job_id
}
running."
fi
ssh_frontend
""
"-O exit"
rmdir
"
${
ssh_socket_dir
}
"
# Remove local vnc PasswordFile
if
[[
${
SVNC_PASSWORD
}
=
"true"
]]
;
then
if
${
SVNC_PASSWORD
}
;
then
rm
-f
"vnc_passwd"
fi
exit
...
...
@@ -288,21 +295,21 @@ main () {
echo
"Vncserver started on node
${
vnc_host
}
.dkrz.de display
\
:
${
vnc_display
}
."
local
vnc_port_local
=
$((
5900
+
RANDOM
%
100
))
# WSL doesn't seem to detect used ports so randomize
# local port to reduce risk of masking.
local
vnc_port_local
=
$((
5900
+
RANDOM
%
100
))
local
vnc_port_remote
=
$((
5900
+
vnc_display
))
while
!
ssh
-o
ForwardX11
=
no
\
-o
StrictHostKeyChecking
=
accept-new
\
-L
"
${
vnc_port_local
}
:localhost:
${
vnc_port_remote
}
"
\
-Nf
\
"
${
SVNC_USERNAME
}
@
${
vnc_host
}
.dkrz.de"
;
do
until
ssh
-o
ForwardX11
=
no
\
-o
StrictHostKeyChecking
=
accept-new
\
-L
"
${
vnc_port_local
}
:localhost:
${
vnc_port_remote
}
"
\
-Nf
\
"
${
SVNC_USERNAME
}
@
${
vnc_host
}
.dkrz.de"
;
do
vnc_port_local
=
$((
5900
+
RANDOM
%
100
))
echo
"Trying local port
${
vnc_port_local
}
."
done
local
client_options
client_options
=
"
${
SVNC_CLIENT_OPTIONS
:-}
"
if
[[
${
SVNC_PASSWORD
}
=
"true"
]]
;
then
if
${
SVNC_PASSWORD
}
;
then
echo
"Fetching password from frontend."
ssh_frontend
"cat .vnc/passwd"
>
vnc_passwd
client_options+
=
" -passwd vnc_passwd"
...
...
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