Skip to content
Snippets Groups Projects
Commit 7736e1fd authored by Mathis Rosenhauer's avatar Mathis Rosenhauer
Browse files

set -u

parent c5385f62
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,8 @@
# Mathis Rosenhauer
# Deutsches Klimarechenzentrum GmbH
# Bundesstr. 45a
# 20146 Hamburg Germany
# 20146 Hamburg
# Germany
#
# All rights reserved.
#
......@@ -49,7 +50,7 @@
# TigerVNC and TightVNC are known to work.
#
set -e
set -eu
# Default settings
......@@ -74,8 +75,9 @@ SVNC_VNCVIEWER="/usr/bin/vncviewer"
# Uncomment this if you use TurboVNC as vncviewer
#readonly SVNC_VNC_OPTIONS="-extssh"
# Frontend host. Must be directly accessible from client. Frontend
# and node where vnc server is running need a shared home file system.
# Frontend host. Must be directly accessible from client. The frontend
# and the node where vncserver is running need a shared home file
# system.
readonly SVNC_FRONTEND_HOST="mistral.dkrz.de"
# Copy vncpassword temporarily to the local workstation
......@@ -105,7 +107,7 @@ clean_up () {
# Remove local vnc PasswordFile
if [[ ${SVNC_PASSWORD} = "true" ]]; then
rm -f ${HOME}/vnc_passwd
rm -f "${HOME}/vnc_passwd"
fi
exit
}
......@@ -117,15 +119,16 @@ usage () {
}
ssh_frontend () {
local ssh_options="$2 -o ForwardX11=no \
local command="$1"
local extra_options="${2:-}"
local options="${extra_options} -o ForwardX11=no \
-o ControlPath=${ssh_socket_dir}/control:%h:%p:%r"
ssh ${ssh_options} "${SVNC_USERNAME}@${SVNC_FRONTEND_HOST}" "$1"
ssh ${options} "${SVNC_USERNAME}@${SVNC_FRONTEND_HOST}" "${command}"
}
parse_options () {
local option
while getopts 'A:g:q:t:u:v:x:' option
do
while getopts 'A:g:q:t:u:v:x:' option; do
case ${option} in
A) SVNC_ACCTCODE="$OPTARG"
;;
......@@ -142,7 +145,7 @@ parse_options () {
x) SVNC_VNC_OPTIONS="$OPTARG"
;;
?) usage
exit 2
exit 1
;;
esac
done
......@@ -158,7 +161,7 @@ parse_options () {
if [[ -z ${SVNC_ACCTCODE} ]] || [[ -z ${SVNC_USERNAME} ]]; then
printf "ERROR: Please specify at least username and acctcode.\n\n" >&2
usage
exit 2
exit 1
fi
}
......@@ -219,7 +222,7 @@ main () {
vnc_host=${host_and_display%:*}
vnc_display=${host_and_display#*:}
local vnc_options="${SVNC_VNC_OPTIONS} \
local vnc_options="${SVNC_VNC_OPTIONS:-} \
-via ${SVNC_USERNAME}@${vnc_host}.dkrz.de"
if [[ ${SVNC_PASSWORD} = "true" ]]; then
ssh_frontend "cat .vnc/passwd" > ${HOME}/vnc_passwd
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment