From 50f9ca6e376be74ed4abbd6f5f83e66c5dd69951 Mon Sep 17 00:00:00 2001
From: Anne Philipp <anne.philipp@univie.ac.at>
Date: Sun, 8 Mar 2020 15:28:44 +0100
Subject: [PATCH] BUGFIX (ticket #263): Corrected installation check for
 parameters GATEWAY and DESTINATION

---
 Source/Python/Mods/checks.py | 11 ++++++++---
 Source/Python/install.py     | 20 ++++++++++----------
 setup.sh                     |  9 ++++++---
 3 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/Source/Python/Mods/checks.py b/Source/Python/Mods/checks.py
index e9bc5e0..5e0c65c 100644
--- a/Source/Python/Mods/checks.py
+++ b/Source/Python/Mods/checks.py
@@ -478,12 +478,17 @@ def check_queue(queue, gateway, destination, ecuid, ecgid):
 
     '''
     if queue in _config.QUEUES_LIST and \
-            (not gateway or not destination or
-             not ecuid or not ecgid):
-        raise ValueError('\nEnvironment variables GATEWAY, DESTINATION, ECUID '
+            (not ecuid or not ecgid):
+        raise ValueError('\nEnvironment variables ECUID '
                          'and ECGID were not set properly! \n '
                          'Please check for existence of file "ECMWF_ENV" '
                          'in the run directory!')
+    elif queue in _config.QUEUES_LIST and \
+             (not gateway or not destination):
+        print('WARNING: Parameters GATEWAY and DESTINATION were '
+              'not properly set for working on ECMWF server. \n'
+              'There will be no transfer of output files to the '
+              'local gateway server possible!')
     return
 
 def check_pathes(idir, odir, fpdir, fedir):
diff --git a/Source/Python/install.py b/Source/Python/install.py
index 9a3e17a..2ed782b 100755
--- a/Source/Python/install.py
+++ b/Source/Python/install.py
@@ -284,19 +284,19 @@ def check_install_conditions(c):
         sys.exit(1)
 
     if c.install_target and c.install_target != 'local':
-        if not c.ecgid or not c.ecuid or \
-           not c.gateway or not c.destination:
-            print('Please enter your ECMWF user id and group id as well ' +
-                  'as the \nname of the local gateway and the ectrans ' +
-                  'destination ')
-            print('with command line options --ecuid --ecgid \
-                   --gateway --destination')
+        if not c.ecgid or not c.ecuid:
+            print('Please enter your ECMWF user id and group id '
+                  ' with command line options --ecuid --ecgid')
             print('Try "' + sys.argv[0].split('/')[-1] + \
                   ' -h" to print usage information')
-            print('Please consult ecaccess documentation or ECMWF user \
-                   support for further details')
+            print('Please consult ecaccess documentation or ECMWF user '
+                  'support for further details.\n')
             sys.exit(1)
-
+        if not c.gateway or not c.destination:
+            print('WARNING: Parameters GATEWAY and DESTINATION were '
+                  'not properly set for working on ECMWF server. \n'
+                  'There will be no transfer of output files to the '
+                  'local gateway server possible!')
         if not c.installdir:
             c.installdir = '${HOME}'
     else: # local
diff --git a/setup.sh b/setup.sh
index 5adc7ad..ba5069a 100755
--- a/setup.sh
+++ b/setup.sh
@@ -30,7 +30,7 @@ MAKEFILE='makefile_ecgate'
 ECUID='<username>'
 ECGID='<groupID>'
 GATEWAY='<gatewayname>'
-DESTINATION='<name>@genericSftp'
+DESTINATION='<username>@genericSftp'
 INSTALLDIR=None
 JOB_TEMPLATE=''
 CONTROLFILE='CONTROL_EA5'
@@ -58,13 +58,16 @@ fi
 # CHECK FOR MORE PARAMETER 
 if [ "$TARGET" == "ecgate" ] || [ "$TARGET" == "cca" ]; then
   # check if necessary Parameters are set
-  if [ -z "$ECUID" ] || [ -z "$ECGID" ] || [ -z "$GATEWAY" ] || [ -z "$DESTINATION" ]; then
-    echo "ERROR: At least one of the following parameters are not set: ECUID, ECGID, GATEWAY, DESTINATION!"
+  if [ -z "$ECUID" ] || [ -z "$ECGID" ] || [ "$ECUID" == "<username>" ] || [ "$ECGID" == "<groupID>" ] ; then
+    echo "ERROR: At least one of the following parameters are not properly set: ECUID or ECGID!"
     echo "EXIT WITH ERROR"
     exit
   else
     parameterlist+=" --ecuid=$ECUID --ecgid=$ECGID --gateway=$GATEWAY --destination=$DESTINATION"
   fi
+  if [ -z "$GATEWAY" ] || [ -z "$DESTINATION" ] || [ "$GATEWAY" == "<gatewayname>" ] || [ "$DESTINATION" == "<username>@genericSftp" ] ; then
+    echo "WARNING: Not setting parameters GATEWAY and DESTINATION means there will be no file transfer to local gateway server."
+  fi
 fi
 if [ -n "$MAKEFILE" ]; then
   parameterlist+=" --makefile=$MAKEFILE"
-- 
GitLab