Ticket #468: Enable-init_wms-with-connect-file-parameter.patch

File Enable-init_wms-with-connect-file-parameter.patch, 6.2 KB (added by abeccati, 11 years ago)

connect file as parameter to init script

  • applications/rasgeo/wms-import/utilities/init_wms.sh

    From 160c254e65e1259bffdb20a8cc1c82f156d3b225 Mon Sep 17 00:00:00 2001
    From: Alan Beccati <beccati@rasdaman.com>
    Date: Fri, 30 Aug 2013 11:31:02 +0200
    Subject: [PATCH] ticket:468 Enable init_wms with connect file parameter
    
    ---
     .../rasgeo/wms-import/utilities/init_wms.sh        |   47 +++++++++++++++++---
     1 file changed, 42 insertions(+), 5 deletions(-)
     mode change 100644 => 100755 applications/rasgeo/wms-import/utilities/add_wms_service.sh
     mode change 100644 => 100755 applications/rasgeo/wms-import/utilities/drop_wms.sh
     mode change 100644 => 100755 applications/rasgeo/wms-import/utilities/fill_pyramid.sh
     mode change 100644 => 100755 applications/rasgeo/wms-import/utilities/init_wms.sh
    
    diff --git a/applications/rasgeo/wms-import/utilities/add_wms_service.sh b/applications/rasgeo/wms-import/utilities/add_wms_service.sh
    old mode 100644
    new mode 100755
    diff --git a/applications/rasgeo/wms-import/utilities/drop_wms.sh b/applications/rasgeo/wms-import/utilities/drop_wms.sh
    old mode 100644
    new mode 100755
    diff --git a/applications/rasgeo/wms-import/utilities/fill_pyramid.sh b/applications/rasgeo/wms-import/utilities/fill_pyramid.sh
    old mode 100644
    new mode 100755
    diff --git a/applications/rasgeo/wms-import/utilities/init_wms.sh b/applications/rasgeo/wms-import/utilities/init_wms.sh
    old mode 100644
    new mode 100755
    index caa7ae0..a5996a8
    a b  
    3333        PYRAMID_ARG='-l'
    3434        HOST_ARG='-h'
    3535        PORT_ARG='-p'
     36        CONNFILE_ARG='-c'
    3637        ME="$( basename $0 )"
    3738        USAGE="
    38         usage: $ME <layerName> <collName> <crs> [$PYRAMID_ARG <pyramidLevels>] [$HOST_ARG <host>] [$PORT_ARG <port>]
     39        usage: $ME <layerName> <collName> <crs> [$PYRAMID_ARG <pyramidLevels>] [$HOST_ARG <host>] [$PORT_ARG <port>] [$CONNFILE_ARG <path_to_rasconnect>]
    3940        where
    4041                <layerName>     the arbitrary name for the /new/ WMS layer;
    4142                <collName>      must be an existing collection in rasdaman (but not already a published WMS coverage);
     
    4546                <host:port>     of the WMS (->Petascope): important for for pluggin the WMS service into client softwares [default localhost:8080].
    4647                                Argument are considered if this is the first WMS layer that is added,
    4748                                hence no WMS service has previously been defined.
     49                <path_to_rasconnect>    metadata db connection info (see ./rasgeo/README),
     50                                defaults to $HOME/.rasdaman/rasconnect
    4851        "
    4952        # In case the usage changes, consequently adjust these values:
    5053        MIN_ARGS=3
    51         MAX_ARGS=9
     54        MAX_ARGS=11
    5255#
    5356# DESCRIPTION
    5457#       Given an existing 2D coverage in rasdaman, the script fetches its metadata
     
    7679#       2008-may-02     P.Baumann       metadata now in database
    7780#       2012-jun-01     pcampalani      Backporting for Petascope: automatic fetch of collection metadata
    7881#                                       and petascopedb sync.
     82#       2013-aug-29     A.Beccati       connection file as a parameter to allow calling script from other user context or from a web server profile
    7983#
    8084# TODO:
    8185#    - add option to cutomize the style: currently the layer are limited to RGB and Grey sets, "as is".
     
    8791# --- DEFAULTS ------------------------------------------------------
    8892# --- values here can (and should) be adjusted to local choices -----
    8993
    90 # user / password for logging in to rasdaman
    9194# (defined here so that they do not appear in command line)
    92 USER=rasadmin
     95# Added also to dbconnect file so that no hardcoded values are used
     96# TODO: keeping them initialized here for backward compatibility,
     97# remove from there (they'll be overwritten by connect file) as soon as
     98# new connect file is deployed officially (might require migration,
     99# warning already added)
     100USER=rasadmin
    93101PASSWD=rasadmin
    94102
    95103# script directory
    SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"  
    102110      HOST_KEY=host
    103111    PGPORT_KEY=pgport
    104112 RASDBNAME_KEY=rasdbname
     113   RASUSER_KEY=rasuser # user for RASBASE (not used here)
     114 RASPASSWD_KEY=raspassword # user password for RASBASE (not used here)
     115      USER_KEY=rasloginuser # user for logging in to rasdaman
     116    PASSWD_KEY=rasloginpassword # password for logging in to rasdaman
    105117PETADBNAME_KEY=petadbname
    106118  PETAUSER_KEY=petauser
    107119PETAPASSWD_KEY=petapassword
    while [ $# -gt 0 ]; do  
    309321          $PYRAMID_ARG) LEVELS_STRING="$2";  shift;;
    310322          $HOST_ARG)    PETASCOPE_HOST="$2"; shift;;
    311323          $PORT_ARG)    PETASCOPE_PORT="$2"; shift;;
     324          $CONNFILE_ARG)   CONNECT_FILE="$2" ; shift;;
    312325        esac
    313326        shift
    314327done
    fi  
    324337    RAS_HOST=$(cat $CONNECT_FILE  | grep $HOST_KEY       | "$AWK" 'BEGIN { FS="=" }; { print $2 }')
    325338     PG_PORT=$(cat $CONNECT_FILE  | grep $PGPORT_KEY     | "$AWK" 'BEGIN { FS="=" }; { print $2 }')
    326339  RASDB_NAME=$(cat $CONNECT_FILE  | grep $RASDBNAME_KEY  | "$AWK" 'BEGIN { FS="=" }; { print $2 }')
    327 PETADB_NAME="$(cat $CONNECT_FILE  | grep $PETADBNAME_KEY | "$AWK" 'BEGIN { FS="=" }; { print $2 }')"
     340  RASUSER=$(cat $CONNECT_FILE  | grep $RASUSER_KEY  | "$AWK" 'BEGIN { FS="=" }; { print $2 }')
     341  RASPASSWD=$(cat $CONNECT_FILE  | grep $RASPASSWD_KEY  | "$AWK" 'BEGIN { FS="=" }; { print $2 }')
     342
     343  #TODO: remove check and defaults after deprecation of old format, rename without T
     344  TUSER=$(cat $CONNECT_FILE  | grep $USER_KEY  | "$AWK" 'BEGIN { FS="=" }; { print $2 }')
     345  TPASSWD=$(cat $CONNECT_FILE  | grep $PASSWD_KEY  | "$AWK" 'BEGIN { FS="=" }; { print $2 }')
     346 
     347  #TODO: remove check and defaults after deprecation of old format
     348  if [ -z "$TUSER" ] ; then
     349    echo "$ME: WARNING: Parameter $USER_KEY missing from connect file: $CONNECT_FILE , please update it!"
     350    echo "$ME: Using default $USER_KEY = $USER"
     351  else
     352    USER="$TUSER"
     353  fi
     354
     355  #TODO: remove check and defaults after deprecation of old format
     356  if [ -z "$TPASSWD" ] ; then
     357    echo "$ME: WARNING: Parameter $PASSWD_KEY missing from connect file: $CONNECT_FILE , please update it!"
     358    echo "$ME: Using default $PASSWD_KEY = $PASSWD"
     359  else
     360    PASSWD="$TPASSWD"
     361  fi
     362
     363
     364 PETADB_NAME="$(cat $CONNECT_FILE  | grep $PETADBNAME_KEY | "$AWK" 'BEGIN { FS="=" }; { print $2 }')"
    328365    PETAUSER=$(cat $CONNECT_FILE  | grep $PETAUSER_KEY   | "$AWK" 'BEGIN { FS="=" }; { print $2 }')
    329366  PETAPASSWD=$(cat $CONNECT_FILE  | grep $PETAPASSWD_KEY | "$AWK" 'BEGIN { FS="=" }; { print $2 }')
    330367