Commit 5a0accae authored by Mathis Rosenhauer's avatar Mathis Rosenhauer

Clean up

parent 39a2fb0d
......@@ -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 \Kmg[0-9]+:[0-9]+" \
\${logfile})
host_and_display="\$(grep -Po "started on display \Kmg[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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment