Commit 7736e1fd authored by Mathis Rosenhauer's avatar Mathis Rosenhauer
Browse files

set -u

parent c5385f62
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
# Mathis Rosenhauer # Mathis Rosenhauer
# Deutsches Klimarechenzentrum GmbH # Deutsches Klimarechenzentrum GmbH
# Bundesstr. 45a # Bundesstr. 45a
# 20146 Hamburg Germany # 20146 Hamburg
# Germany
# #
# All rights reserved. # All rights reserved.
# #
...@@ -49,7 +50,7 @@ ...@@ -49,7 +50,7 @@
# TigerVNC and TightVNC are known to work. # TigerVNC and TightVNC are known to work.
# #
set -e set -eu
# Default settings # Default settings
...@@ -74,8 +75,9 @@ SVNC_VNCVIEWER="/usr/bin/vncviewer" ...@@ -74,8 +75,9 @@ SVNC_VNCVIEWER="/usr/bin/vncviewer"
# Uncomment this if you use TurboVNC as vncviewer # Uncomment this if you use TurboVNC as vncviewer
#readonly SVNC_VNC_OPTIONS="-extssh" #readonly SVNC_VNC_OPTIONS="-extssh"
# Frontend host. Must be directly accessible from client. Frontend # Frontend host. Must be directly accessible from client. The frontend
# and node where vnc server is running need a shared home file system. # and the node where vncserver is running need a shared home file
# system.
readonly SVNC_FRONTEND_HOST="mistral.dkrz.de" readonly SVNC_FRONTEND_HOST="mistral.dkrz.de"
# Copy vncpassword temporarily to the local workstation # Copy vncpassword temporarily to the local workstation
...@@ -105,7 +107,7 @@ clean_up () { ...@@ -105,7 +107,7 @@ clean_up () {
# Remove local vnc PasswordFile # Remove local vnc PasswordFile
if [[ ${SVNC_PASSWORD} = "true" ]]; then if [[ ${SVNC_PASSWORD} = "true" ]]; then
rm -f ${HOME}/vnc_passwd rm -f "${HOME}/vnc_passwd"
fi fi
exit exit
} }
...@@ -117,15 +119,16 @@ usage () { ...@@ -117,15 +119,16 @@ usage () {
} }
ssh_frontend () { 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" -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 () { parse_options () {
local option local option
while getopts 'A:g:q:t:u:v:x:' option while getopts 'A:g:q:t:u:v:x:' option; do
do
case ${option} in case ${option} in
A) SVNC_ACCTCODE="$OPTARG" A) SVNC_ACCTCODE="$OPTARG"
;; ;;
...@@ -142,7 +145,7 @@ parse_options () { ...@@ -142,7 +145,7 @@ parse_options () {
x) SVNC_VNC_OPTIONS="$OPTARG" x) SVNC_VNC_OPTIONS="$OPTARG"
;; ;;
?) usage ?) usage
exit 2 exit 1
;; ;;
esac esac
done done
...@@ -158,7 +161,7 @@ parse_options () { ...@@ -158,7 +161,7 @@ parse_options () {
if [[ -z ${SVNC_ACCTCODE} ]] || [[ -z ${SVNC_USERNAME} ]]; then if [[ -z ${SVNC_ACCTCODE} ]] || [[ -z ${SVNC_USERNAME} ]]; then
printf "ERROR: Please specify at least username and acctcode.\n\n" >&2 printf "ERROR: Please specify at least username and acctcode.\n\n" >&2
usage usage
exit 2 exit 1
fi fi
} }
...@@ -219,7 +222,7 @@ main () { ...@@ -219,7 +222,7 @@ main () {
vnc_host=${host_and_display%:*} vnc_host=${host_and_display%:*}
vnc_display=${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" -via ${SVNC_USERNAME}@${vnc_host}.dkrz.de"
if [[ ${SVNC_PASSWORD} = "true" ]]; then if [[ ${SVNC_PASSWORD} = "true" ]]; then
ssh_frontend "cat .vnc/passwd" > ${HOME}/vnc_passwd 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