Repository: incubator-trafodion Updated Branches: refs/heads/master a07222ff3 -> b2b01f4d5
[TRAFODION-2826] Consolidate trafci defaults in trafci.sh script trafci is wrapper used mostly for development, but either script should pick up client configuration file if present to determine host and user. Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/d583e8b9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/d583e8b9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/d583e8b9 Branch: refs/heads/master Commit: d583e8b96778d8d114a2afe5c850c5622ec61151 Parents: 4b86c64 Author: Steve Varnau <[email protected]> Authored: Thu Nov 30 22:37:42 2017 +0000 Committer: Steve Varnau <[email protected]> Committed: Thu Nov 30 22:37:42 2017 +0000 ---------------------------------------------------------------------- core/conn/trafci/utils/trafci | 24 +++++------- core/conn/trafci/utils/trafci.sh-tmpl | 59 ++++++++++++++++++++++++++---- 2 files changed, 61 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d583e8b9/core/conn/trafci/utils/trafci ---------------------------------------------------------------------- diff --git a/core/conn/trafci/utils/trafci b/core/conn/trafci/utils/trafci index a70a89e..da68fec 100755 --- a/core/conn/trafci/utils/trafci +++ b/core/conn/trafci/utils/trafci @@ -28,20 +28,14 @@ if [[ $# -gt 0 ]]; then exit 1 fi -if [[ -r $DCS_INSTALL_DIR/bin/dcs-config.sh ]] -then - source $DCS_INSTALL_DIR/bin/dcs-config.sh +if [[ -z $TRAF_HOME && -r /etc/trafodion/conf/client_config ]]; then + source /etc/trafodion/conf/client_config fi -if [[ -n $DCS_MASTER_FLOATING_IP ]] -then - MASTER_NODE=$DCS_MASTER_FLOATING_IP -elif [[ -r $DCS_PRIMARY_MASTER ]] -then - MASTER_NODE=$(cat $DCS_PRIMARY_MASTER) -fi - -HNAME="${MASTER_NODE:-localhost}:${DCS_MASTER_PORT:-23400}" -UNAME=zz -PWORD=zz -$TRAF_HOME/trafci/bin/trafci.sh -h $HNAME -u $UNAME -p $PWORD +# If we have client config or server config, no arguments needed +if [[ -r /etc/trafodion/conf/client_config || -r "$DCS_INSTALL_DIR/conf/dcs-env.sh" ]]; then + $TRAF_HOME/trafci/bin/trafci.sh +else + # try localhost + $TRAF_HOME/trafci/bin/trafci.sh -h localhost:23400 +fi http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/d583e8b9/core/conn/trafci/utils/trafci.sh-tmpl ---------------------------------------------------------------------- diff --git a/core/conn/trafci/utils/trafci.sh-tmpl b/core/conn/trafci/utils/trafci.sh-tmpl index cb03e0e..eff97cc 100644 --- a/core/conn/trafci/utils/trafci.sh-tmpl +++ b/core/conn/trafci/utils/trafci.sh-tmpl @@ -20,6 +20,11 @@ # # @@@ END COPYRIGHT @@@ +if [[ -r /etc/trafodion/conf/client_config ]]; then + source /etc/trafodion/conf/client_config +elif [[ -z $TRAF_HOME ]]; then + echo "***Warning***: Missing TRAF_HOME in the environment. " +fi # # Classpath required for execution. Specifies the jar files containing @@ -145,6 +150,10 @@ while [ $# -gt 0 ]; do # {{ JLINE_ARG=$1 shift; JLINE_VALUE=$1 + elif [ "ci$OPT_VALUE" = "ci-h" -o "ci$OPT_VALUE" = "ci-host" ]; then + HOST_ARG=$1 + shift; + HOST_VALUE=$1 else UIMAINCLASS_PARAMS="$UIMAINCLASS_PARAMS $1" @@ -165,13 +174,20 @@ fi jcmd_opts="-classpath $TRAFCI_CLASSPATH $UIMAINCLASS_NAME $UIMAINCLASS_PARAMS " #echo "***DEBUG*** jcmd_opts = java $jcmd_opts $QUERY_OPTION \"$QUERY_ARG\" " -jusercred_opts="" -if [ ! -z "$USER_OPTION" ]; then +if [[ -n "$USER_OPTION" ]]; then jusercred_opts="$USER_ARG \"$USER_OPTION\"" +elif [[ "$TRAFODION_ENABLE_AUTHENTICATION" == "NO" ]]; then + jusercred_opts="-u \"zz\"" # dummy user, since auth not enabled +else + jusercred_opts="" # none, defaults to linux user ID fi -if [ ! -z "$PASSWORD_ARG" ]; then - jusercred_opts="$jusercred_opts $PASSWORD_ARG \"$PASSWORD_OPTION\"" +if [[ -n "$PASSWORD_ARG" ]]; then + jusercred_opts+=" $PASSWORD_ARG \"$PASSWORD_OPTION\"" +elif [[ "$TRAFODION_ENABLE_AUTHENTICATION" == "NO" ]]; then + jusercred_opts+=" -p \"zz\"" # dummy pw, since auth not enabled +# else +# default is to use encrypted pw file or prompt for password fi extention_opts="" @@ -180,14 +196,43 @@ if [ ! -z "$JLINE_ARG" ]; then else extention_opts="-Djline=no" fi + +if [[ -n "$HOST_ARG" ]]; then + # explicit command line option + host_opts="$HOST_ARG \"$HOST_VALUE\"" +elif [[ -n "$DCS_MASTER_FLOATING_IP" ]]; then + # client config DCS HA + host_opts="-h ${DCS_MASTER_FLOATING_IP}:${DCS_MASTER_PORT:-23400}" +elif [[ -n "$DCS_MASTER_QUORUM" ]]; then + # client config DCS non-HA + host_opts="-h ${DCS_MASTER_QUORUM}" +elif [[ -r "$DCS_INSTALL_DIR/conf/dcs-env.sh" ]]; then + # no client config, check for DCS server config + source "$DCS_INSTALL_DIR/conf/dcs-env.sh" + if [[ -n "$DCS_MASTER_FLOATING_IP" ]]; then + host_opts="-h ${DCS_MASTER_FLOATING_IP}:${DCS_MASTER_PORT:-23400}" + elif [[ -s "$DCS_PRIMARY_MASTER" ]]; then + host_opts="-h $(< $DCS_PRIMARY_MASTER):${DCS_MASTER_PORT:-23400}" + if [[ -s "$DCS_BACKUP_MASTERS" ]]; then + while read backup_master; do + if [[ -n "$backup_master" ]]; then + host_opts+=",${backup_master}:${DCS_MASTER_PORT:-23400}" + fi + done < "$DCS_BACKUP_MASTERS" + fi + fi +else + host_opts="" # default is to prompt for host +fi #echo "***DEBUG*** jusercred_opts = $jusercred_opts" #echo "***DEBUG*** extention_opts = $extention_opts" +#echo "***DEBUG*** host_opts = $host_opts" #echo "" -#echo "***DEBUG*** running command = java $jcmd_opts $jusercred_opts $QUERY_OPTION \"$QUERY_ARG\" " +#echo "***DEBUG*** running command = java $extention_opts $jcmd_opts $host_opts $jusercred_opts $QUERY_OPTION \"$QUERY_ARG\" " if [ ! -z "$QUERY_OPTION" ]; then - eval java $extention_opts $jcmd_opts $jusercred_opts $QUERY_OPTION \'"$QUERY_ARG"\' + eval java $extention_opts $jcmd_opts $host_opts $jusercred_opts $QUERY_OPTION \'"$QUERY_ARG"\' else - eval java $extention_opts $jcmd_opts $jusercred_opts + eval java $extention_opts $jcmd_opts $host_opts $jusercred_opts fi
