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
1e955f73
Commit
1e955f73
authored
8 years ago
by
Mathis Rosenhauer
Browse files
Options
Downloads
Patches
Plain Diff
Handle no password set, use vncserver for killing
parent
eed9fdf8
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
+16
-14
16 additions, 14 deletions
startvnc.sh
with
16 additions
and
14 deletions
startvnc.sh
+
16
−
14
View file @
1e955f73
...
...
@@ -37,41 +37,38 @@ MISTRAL="${USERNAME}@mistral.dkrz.de"
clean_up
()
{
trap
- ERR EXIT
set
+e
local
job_id
=
"
$1
"
local
vnc_host_display
=
"
$2
"
local
xvnc_pid
=
"
$3
"
local
tmp_files
=
"
$4
"
local
tmp_files
=
${
job_script
}
echo
"Removing job and temporary files."
if
[[
${
vnc_host_display
}
&&
${
xvnc_pid
}
]]
;
then
if
[[
${
vnc_host_display
}
]]
;
then
# Kill Xvnc process. Mainly done to remove lock file.
local
vnc_host
=
${
vnc_host_display
%
:
*
}
ssh
${
MISTRAL
}
"ssh
${
USERNAME
}
@
${
vnc_host
}
\"
kill
${
xvnc_pid
}
\"
"
\
2> /dev/null
local
vnc_display
=
${
vnc_host_display
#*
:
}
ssh
${
MISTRAL
}
"ssh
${
USERNAME
}
@
${
vnc_host
}
\
\"
/opt/TurboVNC/bin/vncserver -kill :
${
vnc_display
}
\"
"
fi
if
[[
${
job_id
}
]]
;
then
# Clean up temp files and cancel job
tmp_files
=
"
${
tmp_files
}
out.
${
job_id
}
vnc_gethost.
${
job_id
}
"
ssh
${
MISTRAL
}
"scancel
${
job_id
}
; sleep
5"
2> /dev/null
ssh
${
MISTRAL
}
"scancel
-Q
${
job_id
}
; sleep
1"
else
echo
"Job ID not available. Make sure the vncjob is not running!"
ssh
${
MISTRAL
}
"squeue -u
${
USERNAME
}
"
fi
if
[[
${
tmp_files
}
]]
;
then
ssh
${
MISTRAL
}
"cd .startvnc && rm -f
${
tmp_files
}
"
2> /dev/null
ssh
${
MISTRAL
}
"cd .startvnc && rm -f
${
tmp_files
}
"
fi
# Remove local vnc PasswordFile
if
[[
${
PASSWORD
}
=
true
]]
;
then
rm
-f
~/.vnc/passwd2
rm
-f
~/.vnc/passwd2
fi
exit
}
trap
'clean_up \"${job_id}\" \"${vnc_host_display}\" \"${xvnc_pid}\" \
\"${job_script}\"'
INT QUIT TERM ERR EXIT
trap
clean_up INT QUIT TERM ERR EXIT
job_script
=
$(
ssh
${
MISTRAL
}
\
'mkdir -p .startvnc && cd .startvnc && mktemp vncjob.XXXXX'
)
...
...
@@ -83,6 +80,7 @@ ssh ${MISTRAL} "cat > .startvnc/${job_script}" <<EOF
#SBATCH --time=
${
TIME
}
#SBATCH --account=
${
ACCTCODE
}
#SBATCH --output=out.%j
##SBATCH --dkrzepilog=0
cd
\$
{HOME}
/opt/TurboVNC/bin/vncserver -fg -geometry
${
GEOMETRY
}
...
...
@@ -96,11 +94,12 @@ ssh ${MISTRAL} "cat > .startvnc/vnc_gethost.${job_id}" <<EOF
#!/bin/bash
cd "
\$
{0%/*}"
LOGFILE=out.
${
job_id
}
while [ -z
\$
{vnc_host_display} ]; do
while [
[
-z
\$
{vnc_host_display}
]] && [[ -z
\$
{set_password} ]
]; do
sleep 1
if [[ -f
\$
{LOGFILE} ]]; then
vnc_host_display=
\$
(grep -Po "started on display
\K
mg[0-9]+:[0-9]+"
\
\$
{LOGFILE})
set_password=
\$
(grep -i password
\$
{LOGFILE})
fi
done
echo
\$
{vnc_host_display}
...
...
@@ -108,7 +107,10 @@ EOF
echo
"Waiting for job
${
job_id
}
to start."
vnc_host_display
=
$(
ssh
${
MISTRAL
}
"/bin/bash .startvnc/vnc_gethost.
${
job_id
}
"
)
xvnc_pid
=
$(
ssh
${
MISTRAL
}
"cat .vnc/
${
vnc_host_display
}
.pid"
)
if
[[
-z
${
vnc_host_display
}
]]
;
then
echo
-e
"
\n
Set a password for vncserver before starting the client!
\n
"
exit
fi
# Start VNC client
if
[[
${
PASSWORD
}
=
true
]]
;
then
...
...
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