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
5a0accae
Commit
5a0accae
authored
6 years ago
by
Mathis Rosenhauer
Browse files
Options
Downloads
Patches
Plain Diff
Clean up
parent
39a2fb0d
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
+31
-16
31 additions, 16 deletions
start-vnc
with
31 additions
and
16 deletions
start-vnc
+
31
−
16
View file @
5a0accae
...
...
@@ -64,7 +64,7 @@ SVNC_ACCTCODE=""
#
# Specify your username on the login node if it is not your local
# username.
SVNC_USERNAME
=
$(
id
-un
)
SVNC_USERNAME
=
"
$(
id
-un
)
"
# Path to local vncviewer
#
...
...
@@ -142,17 +142,29 @@ clean_up () {
}
usage
()
{
printf
"Usage: %s [OPTIONS]
\n
"
$(
basename
$0
)
>
&2
printf
--
"-u username
\n
-A acctcode
\n
-g geometry
\n
-n nodes
\n
"
>
&2
printf
--
"-q qos
\n
-t time
\n
-v path_to_vncviewer
\n
"
>
&2
printf
--
"-x vncviewer_options
\n
"
>
&2
cat
<<
EOF
Usage:
$(
basename
"
$0
"
)
[OPTION]
Available values for OPTION include:
-A acctcode acctcode of job
-g geometry initial geometry of vnc window
-n nodes number of nodes
-q qos job qos
-t time job runtime
-u username use username for login
-v path path to vncviewer program
-x options addidtional options for vncviewer
EOF
}
ssh_frontend
()
{
local command
=
"
$1
"
local
extra_options
=
"
${
2
:-}
"
local
options
=
"
${
extra_options
}
-o ForwardX11=no
\
-o ControlPath=
${
ssh_socket_dir
}
/control:%h:%p:%r"
local
options
options
=
"
${
extra_options
}
-o ForwardX11=no
\
-o ControlPath=
${
ssh_socket_dir
}
/control:%h:%p:%r"
ssh
${
options
}
"
${
SVNC_USERNAME
}
@
${
SVNC_FRONTEND_HOST
}
"
"
${
command
}
"
}
...
...
@@ -208,10 +220,11 @@ prepare_vncserver () {
}
submit_vnc_job
()
{
local
sbatch_resources
if
[[
${
SVNC_NODES
}
=
"half"
]]
;
then
local
sbatch_resources
=
"#SBATCH --ntasks=24"
sbatch_resources
=
"#SBATCH --ntasks=24"
else
local
sbatch_resources
=
"#SBATCH --nodes=
${
SVNC_NODES
}
"
sbatch_resources
=
"#SBATCH --nodes=
${
SVNC_NODES
}
"
sbatch_resources+
=
$'
\n
#SBATCH --exclusive'
fi
ssh_frontend
"cd .startvnc && sbatch"
<<
EOF
...
...
@@ -236,8 +249,8 @@ logfile=\${HOME}/.startvnc/out.${job_id}
while [[ -z
\$
{host_and_display} ]]; do
sleep 1
if [[ -f
\$
{logfile} ]]; then
host_and_display=
\$
(grep -Po "started on display
\K
mg[0-9]+:[0-9]+"
\
\$
{logfile})
host_and_display=
"
\$
(grep -Po "started on display
\K
mg[0-9]+:[0-9]+"
\
\$
{logfile})
"
fi
printf "." >&2
done
...
...
@@ -250,22 +263,24 @@ main () {
parse_options
"
$@
"
trap
clean_up INT QUIT TERM ERR EXIT
ssh_socket_dir
=
$(
mktemp
-d
"
${
HOME
}
/.ssh/socket.XXXXX"
)
ssh_socket_dir
=
"
$(
mktemp
-d
"
${
HOME
}
/.ssh/socket.XXXXX"
)
"
ssh_frontend
""
"-MNf"
prepare_vncserver
echo
"Submitting vncserver job."
job_id
=
$(
submit_vnc_job
)
job_id
=
"
$(
submit_vnc_job
)
"
printf
"Waiting for job
${
job_id
}
to start"
>
&2
local
host_and_display
=
$(
get_vnc_host_and_display
"
$job_id
"
)
local
host_and_display
host_and_display
=
"
$(
get_vnc_host_and_display
"
$job_id
"
)
"
vnc_host
=
${
host_and_display
%
:
*
}
vnc_display
=
${
host_and_display
#*
:
}
echo
"Vncserver started on node
${
vnc_host
}
.dkrz.de display
\
:
${
vnc_display
}
."
local
vnc_options
=
"
${
SVNC_VNC_OPTIONS
:-}
\
-via
${
SVNC_USERNAME
}
@
${
vnc_host
}
.dkrz.de"
local
vnc_options
vnc_options
=
"
${
SVNC_VNC_OPTIONS
:-}
\
-via
${
SVNC_USERNAME
}
@
${
vnc_host
}
.dkrz.de"
if
[[
${
SVNC_PASSWORD
}
=
"true"
]]
;
then
echo
"Fetching password from frontend."
ssh_frontend
"cat .vnc/passwd"
>
${
HOME
}
/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