From de5eaeec957cbb7da7dc812646875236a399414f Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 11 May 2023 10:20:45 -0400 Subject: [PATCH 01/18] Update convert-env.sh Default to "saf" authentication in production by env config to prevent any fall-through to "fallback" auth when not desired, while still allowing dev installs to not need a mainframe to get started. Signed-off-by: 1000TurquoisePogs --- bin/utils/convert-env.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/utils/convert-env.sh b/bin/utils/convert-env.sh index 7ab584d..34d5fb8 100755 --- a/bin/utils/convert-env.sh +++ b/bin/utils/convert-env.sh @@ -412,3 +412,9 @@ fi if [ -z "$ZWE_components_app_server_instanceDir" ]; then export ZWED_instanceDir="$DESTINATION" fi + +if [ -z "$ZWE_components_app_server_dataserviceAuthentication_defaultAuthentication" ]; then + if [ -n "${ZWED_node_mediationLayer_enabled}" -o -n "${ZWED_agent_https_port}" -o -n "${ZWED_agent_http_port}" ]; then + ZWE_components_app_server_dataserviceAuthentication_defaultAuthentication="saf" + fi +fi From da35166c5e45d4853e3d760232626ee9c05c6fef Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Tue, 23 May 2023 15:21:58 -0400 Subject: [PATCH 02/18] Remove convert-env and as much env vars as possible to instead leverage defaults.yaml. simplify zlux args to align with zlux server changes Signed-off-by: 1000TurquoisePogs --- bin/app-server.sh | 93 +------ bin/configure.sh | 32 ++- bin/init/node-init.sh | 48 ++-- bin/init/workspace-init.sh | 30 +- bin/install-app.sh | 100 +++---- bin/start.sh | 77 +++++- bin/utils/convert-env.sh | 414 ---------------------------- bin/utils/setup-logs.sh | 8 +- bin/zssServer.sh | 2 +- defaults/serverConfig/defaults.yaml | 145 ++++++++++ defaults/serverConfig/zowe.yaml | 54 ---- lib/initInstance.js | 26 +- lib/zluxArgs.js | 199 +------------ lib/zluxCluster.js | 7 +- lib/zluxServer.js | 10 +- schemas/app-server-config.json | 23 ++ 16 files changed, 358 insertions(+), 910 deletions(-) delete mode 100755 bin/utils/convert-env.sh create mode 100644 defaults/serverConfig/defaults.yaml delete mode 100644 defaults/serverConfig/zowe.yaml diff --git a/bin/app-server.sh b/bin/app-server.sh index 7677de2..1277a7c 100755 --- a/bin/app-server.sh +++ b/bin/app-server.sh @@ -7,95 +7,4 @@ # # Copyright Contributors to the Zowe Project. - -# Required variables on shell: -# - ZWE_zowe_runtimeDirectory -# - ZWE_zowe_workspaceDirectory -# - NODE_HOME -# -# Optional variables on shell: -# - APIML_ENABLE_SSO -# - GATEWAY_PORT -# - DISCOVERY_PORT -# - ZWED_SSH_PORT -# - ZWED_TN3270_PORT -# - ZWED_TN3270_SECURITY - -if [ -z "${ZWE_zowe_runtimeDirectory}" ] -then - #this may be a dev environment, or backward compat, so stay in current dir and check node - . ./validate.sh -fi - -if [ ! -e "${dir}/utils/convert-env.sh" ] -then - if [ -n "$CONDA_PREFIX" ] - then - dir="$CONDA_PREFIX/share/zowe/app-server/zlux-app-server/bin" - cd $dir - fi -fi - -. ./utils/convert-env.sh -. ./init/node-init.sh - -if [ -e "$ZLUX_CONFIG_FILE" ] -then - CONFIG_FILE=$ZLUX_CONFIG_FILE -elif [ -e "$ZWE_CLI_PARAMETER_CONFIG" ] -then - CONFIG_FILE="$ZWE_CLI_PARAMETER_CONFIG" -elif [ -z "${ZWE_zowe_runtimeDirectory}" ] -then - #dev env or backwards compat, do late configure - # should we also export ZWE_zowe_workspaceDirectory=~/.zowe/zowe.yaml? - # potentially zowe.yaml in there could point workspaceDirectory elsewhere to cause further confusion - . ./init/workspace-init.sh - CONFIG_FILE=~/.zowe/zowe.yaml -fi - -# Will skip log trimming if ZWED_NODE_LOG_FILE already defined (such as by start.sh) -. ./utils/setup-logs.sh - -#Determined log file. Run node appropriately. -cd ../lib - -export ZOWE_LIB_DIR=$(pwd) -export ZLUX_ROOT_DIR=$(cd ../..; pwd) - -export "_CEE_RUNOPTS=XPLINK(ON),HEAPPOOLS(ON)" - -echo Show Environment -env - -if [ -z "$ZOWE_WORKING_DIR" ] -then - export ZOWE_WORKING_DIR=$ZOWE_LIB_DIR -else - echo "Server is about to start with a non default working directory. Working dir=$ZOWE_WORKING_DIR" -fi - -cd $ZOWE_WORKING_DIR - -export ZWED_NODE_LOG_FILE=$ZWED_NODE_LOG_FILE - -echo Starting node -if [ -z "$ZLUX_NO_CLUSTER" ] -then - ZLUX_SERVER_FILE=zluxCluster.js - if [ -z "$ZLUX_MIN_WORKERS" ] - then - export ZLUX_MIN_WORKERS=2 - fi -else - ZLUX_SERVER_FILE=zluxServer.js -fi - -if [ -z "$ZLUX_NO_LOGFILE" ]; then - __UNTAGGED_READ_MODE=V6 _BPX_JOBNAME=${ZOWE_PREFIX}DS ${NODE_BIN} --harmony ${ZOWE_LIB_DIR}/${ZLUX_SERVER_FILE} --config="${CONFIG_FILE}" "$@" 2>&1 | tee $ZWED_NODE_LOG_FILE -else - __UNTAGGED_READ_MODE=V6 _BPX_JOBNAME=${ZOWE_PREFIX}DS ${NODE_BIN} --harmony ${ZOWE_LIB_DIR}/${ZLUX_SERVER_FILE} --config="${CONFIG_FILE}" "$@" - echo "Ended with rc=$?" -fi - - +./start.sh diff --git a/bin/configure.sh b/bin/configure.sh index ec367a5..ec64045 100755 --- a/bin/configure.sh +++ b/bin/configure.sh @@ -22,10 +22,38 @@ if [ "${ZWE_RUN_ON_ZOS}" != "true" ]; then fi cd ${COMPONENT_HOME}/share/zlux-app-server/bin -. ./utils/convert-env.sh + +if [ -n "$ZWE_components_app_server_node_mediationLayer_enabled" -a -z "$ZWE_components_app_server_agent_mediationLayer_enabled" ]; then + if [ "${ZWE_RUN_ON_ZOS}" != "true" ]; then + zss_def_template="zss.apiml_static_reg.yaml.template" + zss_configured=false + if [ -n "${ZWE_components_app_server_agent_https_port}" ]; then + export ZSS_PORT="${ZWE_components_app_server_agent_https_port}" + export ZSS_PROTOCOL=https + zss_configured=true + elif [ -n "${ZWED_components_app_server_agent_http_port}" ]; then + export ZSS_PORT="${ZWE_components_app_server_http_port}" + export ZSS_PROTOCOL=http + zss_configured=true + fi + + if [ "${zss_configured}" = "true" ] && [ -n "${ZWE_STATIC_DEFINITIONS_DIR}" ]; then + zss_registration_yaml=${ZWE_STATIC_DEFINITIONS_DIR}/zss.apiml_static_reg_yaml_template.${ZWE_CLI_PARAMETER_HA_INSTANCE}.yml + zss_def="../${zss_def_template}" + zss_parsed_def=$( ( echo "cat <&1) + echo "${zss_parsed_def}" > "${zss_registration_yaml}" + chmod 770 "${zss_registration_yaml}" + fi + + unset ZSS_PORT + unset ZSS_PROTOCOL + fi +fi + + . ./init/node-init.sh cd ../lib -__UNTAGGED_READ_MODE=V6 $NODE_BIN initInstance.js +CONFIG_FILE=$ZWE_CLI_PARAMETER_CONFIG $NODE_BIN initInstance.js cd ${COMPONENT_HOME}/share/zlux-app-server/bin/init if [ "${ZWE_zowe_useConfigmgr}" = "true" ]; then diff --git a/bin/init/node-init.sh b/bin/init/node-init.sh index 2a77f9f..5b02005 100644 --- a/bin/init/node-init.sh +++ b/bin/init/node-init.sh @@ -1,37 +1,25 @@ -if [ -n "$NODE_HOME" ] -then - NODE_BIN=${NODE_HOME}/bin/node +#!/bin/sh +# This program and the accompanying materials are +# made available under the terms of the Eclipse Public License v2.0 which accompanies +# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html +# +# SPDX-License-Identifier: EPL-2.0 +# +# Copyright Contributors to the Zowe Project. + +if [ -n "$NODE_HOME" ]; then + export NODE_BIN=${NODE_HOME}/bin/node export PATH=${NODE_HOME}/bin:$PATH -elif [ -n "$ZOWE_NODE_HOME" ] -then - NODE_BIN=${ZOWE_NODE_HOME}/bin/node - export PATH=${ZOWE_NODE_HOME}/bin:$PATH else - NODE_BIN=node + export NODE_BIN=node fi -export NODE_BIN - -if [ ! -e "${ZWE_zowe_runtimeDirectory}/bin/internal/zowe-set-env.sh" ]; then - RUN_ON_ZOS=$(test `uname` = "OS/390" && echo "true") - if [ "${RUN_ON_ZOS}" = "true" ]; then - export "_CEE_RUNOPTS=XPLINK(ON),HEAPPOOLS(ON)" - export _BPXK_AUTOCVT=ON - export __UNTAGGED_READ_MODE=V6 - - nodeVersion="$(${NODE_BIN} --version)" - nodeMajorVersion=$(echo ${nodeVersion} | cut -c2-3) - if [ $nodeMajorVersion -ge "12" ] - then - export _TAG_REDIR_ERR=txt - export _TAG_REDIR_IN=txt - export _TAG_REDIR_OUT=txt - fi - - fi -else - . ${ZWE_zowe_runtimeDirectory}/bin/internal/zowe-set-env.sh -fi +export "_CEE_RUNOPTS=XPLINK(ON),HEAPPOOLS(ON)" +export _BPXK_AUTOCVT=ON +export __UNTAGGED_READ_MODE=V6 +export _TAG_REDIR_ERR=txt +export _TAG_REDIR_IN=txt +export _TAG_REDIR_OUT=txt export NODE_PATH=../..:../../zlux-server-framework/node_modules:$NODE_PATH diff --git a/bin/init/workspace-init.sh b/bin/init/workspace-init.sh index afefb59..59e2aa2 100644 --- a/bin/init/workspace-init.sh +++ b/bin/init/workspace-init.sh @@ -10,32 +10,4 @@ #ZLUX_CONFIG_FILE and ZWE_zowe_workspaceDirectory are for official Zowe environment use. #If none found, will assume dev environment and consider ~/.zowe/workspace as ZWE_zowe_workspaceDirectory -if [ -n "${ZWE_zowe_workspaceDirectory}" ] -then - if [ -e "${ZWE_zowe_workspaceDirectory}/app-server/serverConfig/zowe.yaml" ] - then - export CONFIG_FILE="${ZWE_zowe_workspaceDirectory}/app-server/serverConfig/zowe.yaml" - else - cd ../../lib - __UNTAGGED_READ_MODE=V6 $NODE_BIN initInstance.js - export CONFIG_FILE="${ZWE_zowe_workspaceDirectory}/app-server/serverConfig/zowe.yaml" - fi -elif [ -e "${HOME}/.zowe/workspace/app-server/serverConfig/zowe.yaml" ] -then - export CONFIG_FILE="${HOME}/.zowe/workspace/app-server/serverConfig/zowe.yaml" - if [ -z "${ZWE_zowe_logDirectory}" ]; then - export ZWE_zowe_logDirectory="${HOME}/.zowe/logs" - fi - mkdir -p ${ZWE_zowe_logDirectory} - export WORKSPACE_DIR="${HOME}/.zowe/workspace" -else - echo "No config file found, initializing..." - export WORKSPACE_DIR="${HOME}/.zowe/workspace" - if [ -z "${ZWE_zowe_logDirectory}" ]; then - export ZWE_zowe_logDirectory="${HOME}/.zowe/logs" - fi - mkdir -p ${ZWE_zowe_logDirectory} - cd ../../lib - __UNTAGGED_READ_MODE=V6 $NODE_BIN initInstance.js - export CONFIG_FILE="${HOME}/.zowe/workspace/app-server/serverConfig/zowe.yaml" -fi + diff --git a/bin/install-app.sh b/bin/install-app.sh index d72cc08..b535c3d 100755 --- a/bin/install-app.sh +++ b/bin/install-app.sh @@ -7,10 +7,9 @@ # # Copyright Contributors to the Zowe Project. -if [ $# -eq 0 ] - then - echo "Usage: $0 AppPath [PluginsDir]" - exit 1 +if [ $# -eq 0 ]; then + echo "Usage: $0 AppPath [PluginsDir]" + exit 1 fi setVars() { @@ -21,12 +20,7 @@ setVars() { . ${zlux_path}/zlux-app-server/bin/init/node-init.sh } -dir=$(cd `dirname $0` && pwd) -. ${dir}/utils/plugin-utils.sh -. ${dir}/utils/convert-env.sh - -if [ -n "${ZWE_zowe_workspaceDirectory}" -a -n "${ZWE_zowe_runtimeDirectory}" ] -then +if [ -n "${ZWE_zowe_workspaceDirectory}" -a -n "${ZWE_zowe_runtimeDirectory}" ]; then COMPONENT_HOME=${ZWE_zowe_runtimeDirectory}/components/app-server # containers only @@ -41,26 +35,24 @@ then if [ -z "$INSTALL_NO_NODE" ]; then zlux_path="$COMPONENT_HOME/share" setVars - if [ ! -d "${ZWE_zowe_workspaceDirectory}/app-server" ] - then + if [ ! -e "${ZWE_zowe_workspaceDirectory}/app-server/plugins/org.zowe.zlux.json" ]; then cd ${zlux_path}/zlux-app-server/lib - __UNTAGGED_READ_MODE=V6 $NODE_BIN initInstance.js + CONFIG_FILE=$ZWE_CLI_PARAMETER_CONFIG $NODE_BIN initInstance.js fi fi -elif [ -d "${dir}/../../zlux-server-framework" ] -then +else zlux_path=$(cd $(dirname "$0")/../..; pwd) setVars -elif [ -n "$CONDA_PREFIX" ] -then - zlux_path="$CONDA_PREFIX/share/zowe/app-server" - setVars fi +. ${zlux_path}/zlux-app-server/bin/utils/plugin-utils.sh + + + utils_path=$zlux_path/zlux-server-framework/utils -app_path=$(cd "$1"; pwd) -if [ $# -gt 1 ] -then +#app_path=$(cd "$1"; pwd) +app_path=$1 +if [ $# -gt 1 ]; then plugin_dir=$2 shift else @@ -75,13 +67,13 @@ if [ -z "$plugin_dir" ]; then fi mkdir -p $plugin_dir + # Installs a zowe plugin by finding its ID and writing the locator json WITHOUT using install-app.js # This is to be used in cases where there are issues using JS, or nodejs is not found. # Input: relative or fully qualified path to a directory containing a plugindir=$(cd `dirname $0` && pwd) installNojs() { id=$(getPluginID "${app_path}") - if [ -n "${id}" ] - then + if [ -n "${id}" ]; then echo "Found plugin=${id}" cat <${plugin_dir}/${id}.json @@ -92,53 +84,47 @@ cat <${plugin_dir}/${id}.json EOF echo "Plugin registration ended with rc=$?" - if [ -f "${plugin_dir}/${id}.json" ] - then + if [ -f "${plugin_dir}/${id}.json" ]; then chmod 0771 "${plugin_dir}/${id}.json" fi else - echo "Error: could not find plugin id for path=${app_path}" - exit 1 + echo "Error: could not find plugin id for path=${app_path}" + exit 1 fi } -if [ -n "$INSTALL_NO_NODE" ] -then - installNojs -else + +if [ -n "$INSTALL_NO_NODE" ]; then + installNojs +else cd $zlux_path/zlux-app-server/bin echo "Testing if node exists" type ${NODE_BIN} rc=$? - if [ $rc -ne 0 ] - then + if [ $rc -ne 0 ]; then installNojs else -# normal case follows -if [ -z "$ZLUX_INSTALL_LOG_DIR" ] -then - if [ -d "${ZWE_zowe_logDirectory}" ] - then - ZLUX_INSTALL_LOG_DIR="$ZWE_zowe_logDirectory" - fi -fi + # normal case follows + if [ -z "$ZLUX_INSTALL_LOG_DIR" ]; then + if [ -d "${ZWE_zowe_logDirectory}" ]; then + ZLUX_INSTALL_LOG_DIR="$ZWE_zowe_logDirectory" + fi + fi -PLUGIN_LOG_FILE=/dev/null -if [ ! -z "$ZLUX_INSTALL_LOG_DIR" ] -then - if [ ! -d "$ZLUX_INSTALL_LOG_DIR" ] - then - echo "Will make log directory $ZLUX_INSTALL_LOG_DIR" - mkdir -p $ZLUX_INSTALL_LOG_DIR - fi - PLUGIN_LOG_FILE="$ZLUX_INSTALL_LOG_DIR/install-app.log" -fi + PLUGIN_LOG_FILE=/dev/null + if [ ! -z "$ZLUX_INSTALL_LOG_DIR" ]; then + if [ ! -d "$ZLUX_INSTALL_LOG_DIR" ]; then + echo "Will make log directory $ZLUX_INSTALL_LOG_DIR" + mkdir -p $ZLUX_INSTALL_LOG_DIR + fi + PLUGIN_LOG_FILE="$ZLUX_INSTALL_LOG_DIR/install-app.log" + fi -echo "Running app-server plugin registration. Log=$PLUGIN_LOG_FILE" -echo "utils_path=${utils_path}\napp_path=${app_path}" -echo "plugin_dir=${plugin_dir}" -{ __UNTAGGED_READ_MODE=V6 ${NODE_BIN} ${utils_path}/install-app.js -i "$app_path" -p "$plugin_dir" $@ 2>&1 ; echo "Plugin registration ended with rc=$?" ; } | tee -a $PLUGIN_LOG_FILE -fi + echo "Running app-server plugin registration. Log=$PLUGIN_LOG_FILE" + echo "utils_path=${utils_path}\napp_path=${app_path}" + echo "plugin_dir=${plugin_dir}" + { ${NODE_BIN} ${utils_path}/install-app.js -i "$app_path" -p "$plugin_dir" $@ 2>&1 ; echo "Plugin registration ended with rc=$?" ; } | tee -a $PLUGIN_LOG_FILE + fi fi diff --git a/bin/start.sh b/bin/start.sh index 749ef50..b963d9f 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -12,19 +12,9 @@ # - ZWE_zowe_runtimeDirectory # - ZWE_zowe_workspaceDirectory # - NODE_HOME -# -# Optional variables on shell: -# - APIML_ENABLE_SSO -# - GATEWAY_PORT -# - DISCOVERY_PORT -# - ZWED_SSH_PORT -# - ZWED_TN3270_PORT -# - ZWED_TN3270_SECURITY - -if [ -n "${ZWE_zowe_runtimeDirectory}" ] -then - #not a dev env +if [ -n "${ZWE_zowe_runtimeDirectory}" ]; then + # not a dev env COMPONENT_HOME=${ZWE_zowe_runtimeDirectory}/components/app-server # containers only @@ -35,11 +25,68 @@ then fi cd ${COMPONENT_HOME}/share/zlux-app-server/bin + ZLUX_APP_SERVER_DIR=$COMPONENT_HOME/share/zlux-app-server +else + # dev env + . ./validate.sh + COMPONENT_HOME=$(cd ../..; pwd) + ZLUX_APP_SERVER_DIR=$COMPONENT_HOME/zlux-app-server fi +# used for relativeTo plugins +export ZLUX_ROOT_DIR=$COMPONENT_HOME +. ./init/node-init.sh . ./utils/setup-logs.sh -# Done to prevent app-server from making a logfile since we will be making one here instead. -export ZLUX_NO_LOGFILE=1 +# Get config path or fail +if [ -z "${ZWE_CLI_PARAMETER_CONFIG}" ]; then + echo "ZWE_CLI_PARAMETER_CONFIG is not defined. Only defaults will be used." + echo "To customize, rerun script with it defined to a list of paths to zowe.yaml files such as FILE(/yaml1.yaml):FILE(/path/to/yaml2.yaml)" + if [ -e "${HOME}/.zowe/zowe.yaml" ]; then + echo "Found and using ${HOME}/.zowe/zowe.yaml" + else + mkdir -p ${HOME}/.zowe + cp ${ZLUX_APP_SERVER_DIR}/defaults/serverConfig/defaults.yaml ${HOME}/.zowe/zowe.yaml + fi + CONFIG_FILE="FILE(${HOME}/.zowe/zowe.yaml):FILE(${ZLUX_APP_SERVER_DIR}/defaults/serverConfig/defaults.yaml)" +else + CONFIG_FILE="FILE(${ZWE_CLI_PARAMETER_CONFIG}):FILE(${ZLUX_APP_SERVER_DIR}/defaults/serverConfig/defaults.yaml)" +fi + +if [ -z "${ZWE_zowe_runtimeDirectory}" ]; then + # dev env or backwards compat, do late configure + if [ -z "${ZWE_zowe_workspaceDirectory}" ]; then + export ZWE_zowe_workspaceDirectory="${HOME}/.zowe/workspace" + fi + if [ ! -e "${ZWE_zowe_workspaceDirectory}/app-server/plugins/org.zowe.zlux.json}" ]; then + cd ${ZLUX_APP_SERVER_DIR}/lib + $NODE_BIN initInstance.js + fi +fi + +if [ -z "$ZLUX_NO_CLUSTER" ]; then + ZLUX_SERVER_FILE=zluxCluster.js + export ZLUX_MIN_WORKERS=${ZLUX_MIN_WORKERS:-2} +else + ZLUX_SERVER_FILE=zluxServer.js +fi + +if [ "$ZWE_zowe_verifyCertificates" = "DISABLED" ]; then + export NODE_TLS_REJECT_UNAUTHORIZED=0 +fi + +# set production mode if applicable +export NODE_ENV=${NODE_ENV:-production} -./app-server.sh 2>&1 | tee $ZWED_NODE_LOG_FILE +echo Show Environment +env + +cd ${ZLUX_APP_SERVER_DIR}/lib +echo Starting node + +if [ -z "$ZLUX_NO_LOGFILE" ]; then + _BPX_JOBNAME=${ZWE_zowe_job_prefix}DS ${NODE_BIN} ${ZWED_FLAGS} ${ZLUX_APP_SERVER_DIR}/lib/${ZLUX_SERVER_FILE} --config="${CONFIG_FILE}" "$@" 2>&1 | tee $ZWED_NODE_LOG_FILE +else + _BPX_JOBNAME=${ZWE_zowe_job_prefix}DS ${NODE_BIN} ${ZWED_FLAGS} ${ZLUX_APP_SERVER_DIR}/lib/${ZLUX_SERVER_FILE} --config="${CONFIG_FILE}" "$@" + echo "Ended with rc=$?" +fi diff --git a/bin/utils/convert-env.sh b/bin/utils/convert-env.sh deleted file mode 100755 index 7ab584d..0000000 --- a/bin/utils/convert-env.sh +++ /dev/null @@ -1,414 +0,0 @@ -#!/bin/sh -# This program and the accompanying materials are -# made available under the terms of the Eclipse Public License v2.0 which accompanies -# this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html -# -# SPDX-License-Identifier: EPL-2.0 -# -# Copyright Contributors to the Zowe Project. - -OSNAME=$(uname) - -convert_v2_to_v1() { - while read old_name new_name; do - old_val=$(eval echo "\$${old_name}") - new_val=$(eval echo "\$${new_name}") - if [ -z "${old_val}" -a -n "${new_val}" ]; then - export "${old_name}=${new_val}" - fi - done <&1) - echo "${zss_parsed_def}" > "${zss_registration_yaml}" - chmod 770 "${zss_registration_yaml}" - export ZWED_agent_mediationLayer_enabled="true" - else - export ZWED_agent_mediationLayer_enabled="false" - fi - - unset ZSS_PORT - unset ZSS_PROTOCOL - fi -fi - -# Check if Caching Service is enabled -if [ "$ZWED_node_mediationLayer_enabled" = "true" -a "${ZWE_components_caching_service_enabled}" = "true" ]; then - export ZWED_node_mediationLayer_cachingService_enabled="true" -fi - -# eureka hostname handling -if [ -z "$ZWED_node_hostname" ]; then - if [ -n "$ZWE_INTERNAL_HOST" ]; then - export ZWED_node_hostname=$ZWE_INTERNAL_HOST - elif [ -n "$ZOWE_EXPLORER_HOST" ]; then - export ZWED_node_hostname=$ZOWE_EXPLORER_HOST - fi -fi - -if [ -n "$ZOWE_LOOPBACK_ADDRESS" ] -then - if [ -n "$ZOWE_IP_ADDRESS" ] - then - if [ "$BIND_TO_LOOPBACK" = "true" ] - then - export ZWED_node_https_ipAddresses="${ZOWE_LOOPBACK_ADDRESS},${ZOWE_IP_ADDRESS}", - fi - fi - export ZWED_node_loopbackAddress=$ZOWE_LOOPBACK_ADDRESS -fi - -if [ -z "$ZWED_node_https_ipAddresses" ] -then - if [ -n "$ZOWE_IP_ADDRESS" ] - then - export ZWED_node_https_ipAddresses="${ZOWE_IP_ADDRESS}", - fi -fi - -# certificates -if [ "$ZWE_zowe_verifyCertificates" = "DISABLED" ]; then - export ZWED_node_allowInvalidTLSProxy=true - export NODE_TLS_REJECT_UNAUTHORIZED=0 -fi - -if [ -z "$ZWED_node_https_certificates" ] -then - if [ "$KEYSTORE_TYPE" = "JCERACFKS" ] - then - #, at end turns it into an array - export ZWED_node_https_certificates="${KEYSTORE}&${KEY_ALIAS}", - elif [ -n "$KEYSTORE_CERTIFICATE" ] - then - #, at end turns it into an array - export ZWED_node_https_certificates=$KEYSTORE_CERTIFICATE, - fi -fi - -if [ -z "$ZWED_node_https_certificateAuthorities" ] -then - if [ "$KEYSTORE_TYPE" = "JCERACFKS" ] - then - #, at end turns it into an array - if [ -n "$EXTERNAL_ROOT_CA" ] - then - export ZWED_node_https_certificateAuthorities="${ZWE_zowe_certificate_pem_certificateAuthorities}","${TRUSTSTORE}&${EXTERNAL_ROOT_CA}" - else - export ZWED_node_https_certificateAuthorities="${ZWE_zowe_certificate_pem_certificateAuthorities}", - fi - elif [ -n "$KEYSTORE_CERTIFICATE_AUTHORITY" ] - then - #, at end turns it into an array - if [ -n "$EXTERNAL_CERTIFICATE_AUTHORITIES" ] - then - export ZWED_node_https_certificateAuthorities=${KEYSTORE_CERTIFICATE_AUTHORITY},${EXTERNAL_ROOT_CA},$(echo "$EXTERNAL_CERTIFICATE_AUTHORITIES" | tr " " ",") - else - export ZWED_node_https_certificateAuthorities=${KEYSTORE_CERTIFICATE_AUTHORITY},${EXTERNAL_ROOT_CA}, - fi - fi -fi - -if [ -z "$ZWED_node_https_keys" ] -then - if [ "$KEYSTORE_TYPE" = "JCERACFKS" ] - then - #, at end turns it into an array - export ZWED_node_https_keys="${KEYSTORE}&${KEY_ALIAS}", - elif [ -n "$KEYSTORE_KEY" ] - then - #, at end turns it into an array - export ZWED_node_https_keys=$KEYSTORE_KEY, - fi -fi - -#SSO -if [ -z "$ZWED_agent_jwt_fallback" ] -then - if [ -n "$SSO_FALLBACK_TO_NATIVE_AUTH" ] - then - export ZWED_agent_jwt_fallback=$SSO_FALLBACK_TO_NATIVE_AUTH - fi -fi - -# app server -if [ -z "$ZWED_SERVER_HTTPS_PORT" -a -n "$ZOWE_ZLUX_SERVER_HTTPS_PORT" ] -then - export ZWED_SERVER_HTTPS_PORT="${ZOWE_ZLUX_SERVER_HTTPS_PORT}" -fi -if [ -z "$ZWED_node_https_port" ] -then - if [ -n "$ZWED_SERVER_HTTPS_PORT" ] - then - export ZWED_node_https_port=$ZWED_SERVER_HTTPS_PORT - fi -fi -if [ -z "$ZWED_productDir" ] -then - if [ -n "$ROOT_DIR" ] - then - COMPONENT_HOME=${ROOT_DIR}/components/app-server - - # containers only - if [ "${ZWE_RUN_ON_ZOS}" != "true" ]; then - if [ -f "/component/manifest.yaml" ]; then - COMPONENT_HOME=/component - if [ -z "$ZWED_node_pluginScanIntervalSec" ]; then - # container needs plugin scanning logic on - export ZWED_node_pluginScanIntervalSec=60 - fi - fi - fi - export ZWED_productDir=$COMPONENT_HOME/share/zlux-app-server/defaults - fi -fi - -# v2 alias mapping -if [ -z "$ZWED_NODE_LOG_FILE" -a -n "$ZLUX_NODE_LOG_FILE" ] -then - export ZWED_NODE_LOG_FILE="${ZLUX_NODE_LOG_FILE}" -fi -if [ -z "$ZWED_NODE_LOG_DIR" -a -n "$ZLUX_NODE_LOG_DIR" ] -then - export ZWED_NODE_LOG_DIR="${ZLUX_NODE_LOG_DIR}" -fi -if [ -z "$ZWED_NODE_LOGS_TO_KEEP" -a -n "$ZLUX_NODE_LOGS_TO_KEEP" ] -then - export ZWED_NODE_LOGS_TO_KEEP="${ZLUX_NODE_LOGS_TO_KEEP}" -fi -if [ -z "$ZWED_SSH_PORT" -a -n "$ZOWE_ZLUX_SSH_PORT" ] -then - export ZWED_SSH_PORT="${ZOWE_ZLUX_SSH_PORT}" -fi -if [ -z "$ZWED_TN3270_PORT" -a -n "$ZOWE_ZLUX_TELNET_PORT" ] -then - export ZWED_TN3270_PORT="${ZOWE_ZLUX_TELNET_PORT}" -fi -if [ -z "$ZWED_TN3270_SECURITY" -a -n "$ZOWE_ZLUX_SECURITY_TYPE" ] -then - export ZWED_TN3270_SECURITY="${ZOWE_ZLUX_SECURITY_TYPE}" -fi -if [ -z "$ZWED_SSH_HOST" -a -n "$ZOWE_ZLUX_SSH_HOST" ] -then - export ZWED_SSH_HOST="${ZOWE_ZLUX_SSH_HOST}" -fi -if [ -z "$ZWED_TN3270_HOST" -a -n "$ZOWE_ZLUX_TELNET_HOST" ] -then - export ZWED_TN3270_HOST="${ZOWE_ZLUX_TELNET_HOST}" -fi -if [ -z "$ZWED_TN3270_ROW" -a -n "$ZOWE_ZLUX_TN3270_ROW" ] -then - export ZWED_TN3270_ROW="${ZOWE_ZLUX_TN3270_ROW}" -fi -if [ -z "$ZWED_TN3270_COL" -a -n "$ZOWE_ZLUX_TN3270_COL" ] -then - export ZWED_TN3270_COL="${ZOWE_ZLUX_TN3270_COL}" -fi -if [ -z "$ZWED_TN3270_MOD" -a -n "$ZOWE_ZLUX_TN3270_MOD" ] -then - export ZWED_TN3270_MOD="${ZOWE_ZLUX_TN3270_MOD}" -fi -if [ -z "$ZWED_TN3270_CODEPAGE" -a -n "$ZOWE_ZLUX_TN3270_CODEPAGE" ] -then - export ZWED_TN3270_CODEPAGE="${ZOWE_ZLUX_TN3270_CODEPAGE}" -fi -# zss -if [ -z "$ZWES_SERVER_PORT" -a -n "$ZOWE_ZSS_SERVER_PORT" ] -then - export ZWES_SERVER_PORT="${ZOWE_ZSS_SERVER_PORT}" -fi -if [ -z "$ZWES_SERVER_TLS" -a -n "$ZOWE_ZSS_SERVER_TLS" ] -then - export ZWES_SERVER_TLS="${ZOWE_ZSS_SERVER_TLS}" -fi -if [ "$ZWES_SERVER_TLS" = "false" ] -then - # HTTP - if [ -z "$ZWED_agent_http_port" -a -n "$ZWES_SERVER_PORT" ] - then - export ZWED_agent_http_port="${ZWES_SERVER_PORT}" - fi -else - # HTTPS - if [ -z "$ZWED_agent_https_port" -a -n "$ZWES_SERVER_PORT" ] - then - export ZWED_agent_https_port="${ZWES_SERVER_PORT}" - fi - if [ -z "$ZWED_agent_host" -a -n "$ZOWE_EXPLORER_HOST" ] - then - export ZWED_agent_host="${ZOWE_EXPLORER_HOST}" - fi -fi -if [ -z "$ZWES_XMEM_SERVER_NAME" -a -n "$ZOWE_ZSS_XMEM_SERVER_NAME" ] -then - export ZWES_XMEM_SERVER_NAME="${ZOWE_ZSS_XMEM_SERVER_NAME}" -fi -if [ -z "$ZWED_privilegedServerName" ] -then - if [ -n "$ZWES_XMEM_SERVER_NAME" ] - then - export ZWED_privilegedServerName=$ZWES_XMEM_SERVER_NAME - fi -fi -if [ -z "$ZWES_LOG_FILE" -a -n "$ZSS_LOG_FILE" ] -then - export ZWES_LOG_FILE="${ZSS_LOG_FILE}" -fi -if [ -z "$ZWES_LOG_DIR" -a -n "$ZSS_LOG_DIR" ] -then - export ZWES_LOG_DIR="${ZSS_LOG_DIR}" -fi -if [ -z "$ZWES_LOGS_TO_KEEP" -a -n "$ZSS_LOGS_TO_KEEP" ] -then - export ZWES_LOGS_TO_KEEP="${ZSS_LOGS_TO_KEEP}" -fi -# cert verification -if [ -z "$ZWED_node_allowInvalidTLSProxy" -a -n "$VERIFY_CERTIFICATES" ]; then - if [ "$VERIFY_CERTIFICATES" = "false" ]; then - export ZWED_node_allowInvalidTLSProxy="true" - fi -fi - -# set production mode if applicable -if [ -n "$ROOT_DIR" -a -z "$NODE_ENV" ]; then - export NODE_ENV=production -fi - -# v2 logging -if [ -n "$ZWE_zowe_logDirectory" ]; then - if [ -z "$ZWED_NODE_LOG_DIR" ]; then - export ZWED_NODE_LOG_DIR="$ZWE_zowe_logDirectory" - fi - if [ -z "$ZWES_LOG_DIR" ]; then - export ZWES_LOG_DIR="$ZWE_zowe_logDirectory" - fi -fi - -if [ -n "$ZWE_zowe_workspaceDirectory" ] -then - WORKSPACE_LOCATION=$ZWE_zowe_workspaceDirectory -else - WORKSPACE_LOCATION="$HOME/.zowe/workspace" -fi -DESTINATION="$WORKSPACE_LOCATION/app-server" - - -if [ -z "$ZWE_components_app_server_productDir" ]; then - if [ -n "${ZWE_zowe_runtimeDirectory}" ]; then - export ZWED_productDir=$(cd "$ZWE_zowe_runtimeDirectory/components/app-server/share/zlux-app-server/defaults" && pwd) - else - export ZWED_productDir=$(cd "$PWD/../defaults" && pwd) - fi -fi -if [ -z "$ZWE_components_app_server_siteDir" ]; then - export ZWED_siteDir="$DESTINATION/site" -fi -if [ -z "$ZWE_components_app_server_groupsDir" ]; then - export ZWED_groupsDir="$DESTINATION/groups" -fi -if [ -z "$ZWE_components_app_server_usersDir" ]; then - export ZWED_usersDir="$DESTINATION/users" -fi -if [ -z "$ZWE_components_app_server_pluginsDir" ]; then - export ZWED_pluginsDir="$DESTINATION/plugins" -fi -if [ -z "$ZWE_components_app_server_instanceDir" ]; then - export ZWED_instanceDir="$DESTINATION" -fi diff --git a/bin/utils/setup-logs.sh b/bin/utils/setup-logs.sh index 7d7890a..634cba1 100644 --- a/bin/utils/setup-logs.sh +++ b/bin/utils/setup-logs.sh @@ -7,7 +7,6 @@ # # Copyright Contributors to the Zowe Project. - if [ -n "$ZWED_NODE_LOG_FILE" ] then if [ -n "$ZWED_NODE_LOG_DIR" ] @@ -20,7 +19,9 @@ else then if [ -d "$ZWE_zowe_logDirectory" ] then - ZWED_NODE_LOG_DIR=${ZWE_zowe_logDirectory} + ZWED_NODE_LOG_DIR=${ZWE_zowe_logDirectory} + elif [ -n "${HOME}" ]; then + ZWED_NODE_LOG_DIR="${HOME}/.zowe/logs" else ZWED_NODE_LOG_DIR="../log" fi @@ -91,7 +92,6 @@ fi echo ZWED_NODE_LOG_FILE=${ZWED_NODE_LOG_FILE} -export ZLUX_LOG_PATH=$ZWED_NODE_LOG_FILE if [ ! -e $ZWED_NODE_LOG_FILE ] then @@ -114,3 +114,5 @@ then echo file "$ZWED_NODE_LOG_FILE" is not writable. Logging disabled. ZWED_NODE_LOG_FILE=/dev/null fi + +export ZWED_NODE_LOG_FILE diff --git a/bin/zssServer.sh b/bin/zssServer.sh index 28a3c55..82ac43f 100755 --- a/bin/zssServer.sh +++ b/bin/zssServer.sh @@ -164,7 +164,7 @@ fi #Determined log file. Run zssServer. export dir=`dirname "$0"` cd $ZSS_SCRIPT_DIR -_BPX_SHAREAS=NO _BPX_JOBNAME=${ZOWE_PREFIX}SZ ./zssServer "${CONFIG_FILE}" 2>&1 | tee $ZWES_LOG_FILE +_BPX_SHAREAS=NO _BPX_JOBNAME=${ZWE_zowe_job_prefix}SZ ./zssServer "${CONFIG_FILE}" 2>&1 | tee $ZWES_LOG_FILE # This program and the accompanying materials are # made available under the terms of the Eclipse Public License v2.0 which accompanies # this distribution, and is available at https://www.eclipse.org/legal/epl-v20.html diff --git a/defaults/serverConfig/defaults.yaml b/defaults/serverConfig/defaults.yaml new file mode 100644 index 0000000..54d9617 --- /dev/null +++ b/defaults/serverConfig/defaults.yaml @@ -0,0 +1,145 @@ +zowe: + workspaceDirectory: ${{ process.env.HOME + '/.zowe/workspace' }} + externalDomains: ${{ function a() { if (process.env.ZWE_zowe_externalDomains) { return process.env.ZWE_zowe_externalDomains.split(','); } else { return [ os.hostname() ] } }; a() }} + envrionments: + ZWED_SSH_PORT: 22 + ZWED_TN3270_PORT: 23 + ZWED_TN3270_SECURITY: telnet + ZWED_SSH_HOST: ${{ zowe.externalDomains[0] }} + ZWED_TN3270_HOST: ${{ zowe.externalDomains[0] }} + ZWED_TN3270_ROW: 24 + ZWED_TN3270_COL: 80 + #5=Dynamic + ZWED_TN3270_MOD: "5" + # + # ZWED_TN3270_CODEPAGE: +components: + app-server: + node: + hostname: "${{ function a(){ if (process.env.ZWE_INTERNAL_HOST) { return process.env.ZWE_INTERNAL_HOST; } else if (process.env.ZWE_haInstance_hostname) { return process.env.ZWE_haInstance_hostname; } else { return undefined; } }; a() }}" + https: + ipAddresses: "${{ function a(){ + if (process.env.ZOWE_LOOPBACK_ADDRESS && process.env.BIND_TO_LOOPBACK == 'true') { + return [ process.env.ZOWE_LOOPBACK_ADDRESS , '0.0.0.0' ]; + } else { return ['0.0.0.0'] } }; + a() }}" + port: "${{ function a(){ + if (process.env.ZWED_SERVER_HTTPS_PORT) { + return Number(process.env.ZWED_SERVER_HTTPS_PORT); + } else if (components['app-server'].port) { + return components['app-server'].port; + } else { return Number(7556); } }; + a() }}" + keys: '${{ function a() { + if (zowe.certificate?.keystore?.type == "JCERACFKS") { + return [ zowe.certificate.keystore.file+"&"+zowe.certificate.keystore.alias ]; + } else if (zowe.certificate?.pem?.key) { + return [ zowe.certificate.pem.key ]; + } else { + return [ "../defaults/serverConfig/zlux.keystore.key" ]; } }; + a() }}' + certificates: '${{ function a(){ + if (zowe.certificate?.keystore?.type == "JCERACFKS") { + return [ zowe.certificate.keystore.file+"&"+zowe.certificate.keystore.alias ]; + } else if (zowe.certificate?.pem?.certificate) { + return [ zowe.certificate.pem.certificate ]; + } else { + return [ "../defaults/serverConfig/zlux.keystore.cer" ]; } }; + a() }}' + certificateAuthorities: '${{ function a() { + if(zowe.certificate?.pem?.certificateAuthorities) { + return [zowe.certificate.pem.certificateAuthorities]; + } else { return ["../defaults/serverConfig/apiml-localca.cer"]; } }; + a() }}' + loopbackAddress: "${{ function a(){ if (process.env.ZOWE_LOOPBACK_ADDRESS) { return process.env.ZOWE_LOOPBACK_ADDRESS; } else { return undefined; } }; a() }}" + mediationLayer: + server: + hostname: ${{ zowe.externalDomains[0] }} + gatewayHostname: ${{ zowe.externalDomains[0] }} + port: ${{ components.discovery.port }} + gatewayPort: ${{ zowe.externalPort }} + isHttps: true + cachingService: + enabled: ${{ components['app-server'].node.mediationLayer.enabled && components['caching-service'].enabled }} + enabled: ${{ components.gateway.enabled && components.discovery.enabled }} + headers: + X-frame-Options: + override: true + value: sameorigin + allowInvalidTLSProxy: ${{ zowe.verifyCertificates == 'DISABLED' }} + noChild: false + noPrompt: false + productCode: "ZLUX" + rootRedirectURL: '/ZLUX/plugins/org.zowe.zlux.bootstrap/web/' + pluginScanIntervalSec: "${{ os.platform == 'zos' ? undefined : 60 }}" + readBodyLimit: 102400 + checkReferrer: + enabled: "${{ process.env.ZWE_CHECK_REFERRER ? process.env.ZWE_CHECK_REFERRER : false }}" + hosts: "${{ process.env.ZWE_REFERRER_HOSTS ? process.env.ZWE_REFERRER_HOSTS.toLowerCase().split(',') : process.env.ZWE_REFERER_HOSTS ? process.env.ZWE_REFERER_HOSTS.toLowerCase().split(',') : [] }}" + # All paths relative to zlux-app-server/bin + # In real installations, these values will be configured during the install. + productDir: ${{ function a(){ if (zowe.runtimeDirectory) { return zowe.runtimeDirectory+'/components/app-server/share/zlux-app-server/defaults'; } else { return '../defaults'; } }; a() }} + instanceDir: ${{ zowe.workspaceDirectory }}/app-server + siteDir: ${{ components['app-server'].instanceDir }}/site + groupsDir: ${{ components['app-server'].instanceDir }}/groups + usersDir: ${{ components['app-server'].instanceDir }}/users + pluginsDir: ${{ components['app-server'].instanceDir }}/plugins + dataserviceAuthentication: + # this specifies the default authentication type for dataservices that didn't specify which type to use. These dataservices therefore should not expect a particular type of authentication to be used. + defaultAuthentication: fallback + rbac: false + instanceID: ${{ zowe.rbacProfileIdentifier }} + cookieIdentifier: ${{ zowe.cookieIdentifier }} + # Specifies the default language for the server framework logging + logLanguage: en + zss: + # section used to define a connection to a server that can handle native or high privilege commands that the app server cannot + agent: + http: "${{ function a(){ if (components.zss.tls == false && components.zss.port) { return { port: components.zss.port }; } else { return undefined; } }; a() }}" + https: "${{ function a(){ if (components.zss.tls != false && components.zss.port) { return { port: components.zss.port }; } else { return undefined; } }; a() }}" + host: "${{ function a(){ if (components.zss.tls != false && process.env.ZWE_haInstance_hostname) { return process.env.ZWE_haInstance_hostname; } }; a() }}" + mediationLayer: + enabled: "${{ function a(){ if (os.platform == 'zos' && components['app-server'].node.mediationLayer?.enabled == true) { return true; } else if (components['app-server'].agent?.https?.port || components['app-server'].agent?.http?.port) { return true; } else { return false; } }; a() }}" + + # # for the app server to know, not the agent + # host: localhost + # # used by the agent + # http: + # ipAddresses: + # - 127.0.0.1 + # port: 7557 + # attls: false + gateway: + enabled: false #${{ components.gateway.enabled && components.zss.enabled }} + name: zss + prefix: "/api/v1" + rootServices: + - url: '/login' + method: '*' + requiresAuth: false + - url: '/logout' + method: '*' + requiresAuth: false + - url: '/unixfile' + method: '*' + - url: '/datasetContents' + method: '*' + - url: '/jes' + method: '*' + - url: '/VSAMdatasetContents' + method: '*' + - url: '/datasetMetadata' + method: '*' + - url: '/omvs' + method: '*' + - url: '/ras' + method: '*' + - url: '/security-mgmt' + method: '*' + - url: '/saf-auth' + method: '*' + - url: '/password' + method: '*' + requiresAuth: false + - url: '/user-info' + method: '*' diff --git a/defaults/serverConfig/zowe.yaml b/defaults/serverConfig/zowe.yaml deleted file mode 100644 index 6e0db3b..0000000 --- a/defaults/serverConfig/zowe.yaml +++ /dev/null @@ -1,54 +0,0 @@ -components: - app-server: - node: - https: - ipAddresses: - - 0.0.0.0 - port: 7556 - # pfx (string), keys, certificates, certificateAuthorities, and certificateRevocationLists are all valid here. - keys: - - "../defaults/serverConfig/zlux.keystore.key" - certificates: - - "../defaults/serverConfig/zlux.keystore.cer" - certificateAuthorities: - - "../defaults/serverConfig/apiml-localca.cer" - mediationLayer: - server: - hostname: localhost - port: 10011 - gatewayPort: 10012 - isHttps: true - enabled: false - headers: - X-frame-Options: - override: true - value: sameorigin - # All paths relative to zlux-app-server/bin - # In real installations, these values will be configured during the install. - # productDir: "../defaults" - # siteDir: "../deploy/site" - # instanceDir: "../deploy/instance" - # groupsDir: "../deploy/instance/groups" - # usersDir: "../deploy/instance/users" - # pluginsDir: "../defaults/plugins" - dataserviceAuthentication: - # this specifies the default authentication type for dataservices that didn't specify which type to use. These dataservices therefore should not expect a particular type of authentication to be used. - defaultAuthentication: fallback - rbac: false - # Specifies the default language for the server framework logging - logLanguage: en - zss: - # section used to define a connection to a server that can handle native or high privilege commands that the app server cannot - # agent: - # # for the app server to know, not the agent - # host: localhost - # # used by the agent - # http: - # ipAddresses: - # - 127.0.0.1 - # port: 7557 - # attls: false - # gateway: - # name: zss - # prefix: "/api/v1" - # enabled: false diff --git a/lib/initInstance.js b/lib/initInstance.js index da1cf12..4aa2b1f 100644 --- a/lib/initInstance.js +++ b/lib/initInstance.js @@ -11,29 +11,35 @@ const fs = require('fs'); const path = require('path'); const argParser = require('../../zlux-server-framework/utils/argumentParser'); -const jsonUtils = require('../../zlux-server-framework/lib/jsonUtils'); const mergeUtils = require('../../zlux-server-framework/utils/mergeUtils'); +const yamlConfig = require('../../zlux-server-framework/utils/yamlConfig'); const initUtils = require('./initUtils'); -const upgradeInstance = require('./upgradeInstance'); +//const upgradeInstance = require('./upgradeInstance'); const os = require('os'); const ncp = require('ncp').ncp; const { execSync } = require('child_process'); const mkdirp = require('mkdirp'); +const haInstanceId = yamlConfig.getCurrentHaInstanceId(); +let config = {}; +if (process.env.CONFIG_FILE) { + config = yamlConfig.parseZoweDotYaml(process.env.CONFIG_FILE, haInstanceId); +} +const envConfig = argParser.environmentVarsToObject("ZWED_"); +if (Object.keys(envConfig).length > 0) { + config = mergeUtils.deepAssign(config, envConfig); +} - -//Where are we: dev environment? Official install? -const workspaceLocation = process.env.WORKSPACE_DIR && process.env.WORKSPACE_DIR != '""' - ? process.env.WORKSPACE_DIR - : process.env.ZWE_zowe_workspaceDirectory && process.env.ZWE_zowe_workspaceDirectory != '""' - ? process.env.ZWE_zowe_workspaceDirectory - : path.join(process.env.HOME, '.zowe', 'workspace'); +const workspaceLocation = config.zowe && config.zowe.workspaceDirectory + ? config.zowe.workspaceDirectory + : process.env.ZWE_zowe_workspaceDirectory; const destination = path.join(workspaceLocation, 'app-server'); + const versionLocation = path.join(destination, 'component.json'); -let config = argParser.environmentVarsToObject("ZWED_"); + config.productDir = path.join(__dirname, '..', 'defaults'); diff --git a/lib/zluxArgs.js b/lib/zluxArgs.js index d420624..77101a8 100644 --- a/lib/zluxArgs.js +++ b/lib/zluxArgs.js @@ -18,70 +18,24 @@ const mergeUtils = require('zlux-server-framework/utils/mergeUtils'); const yamlConfig = require('zlux-server-framework/utils/yamlConfig'); const mkdirp = require('mkdirp'); const cluster = require('cluster'); -const PRODUCT_CODE = 'ZLUX'; - -const DEFAULT_CONFIG = { - "productDir":"../defaults", - "siteDir":"../deploy/site", - "instanceDir":"../deploy/instance", - "groupsDir":"../deploy/instance/groups", - "usersDir":"../deploy/instance/users", - "pluginsDir":"../defaults/plugins", - - "node": { - "rootRedirectURL": '/' + PRODUCT_CODE + '/plugins/org.zowe.zlux.bootstrap/web/', - "allowInvalidTLSProxy": false, - "noChild": false, - "noPrompt": false, - "https": { - "ipAddresses": ["0.0.0.0"], - "port": 7556, - "keys": ["../defaults/serverConfig/zlux.keystore.key"], - "certificates": ["../defaults/serverConfig/zlux.keystore.cer"] - } - }, - "dataserviceAuthentication": { - "rbac": false, - "defaultAuthentication": "fallback" - } -}; const MVD_ARGS = [ new argParser.CLIArgument(null, 'D', argParser.constants.ARG_TYPE_JSON), - new argParser.CLIArgument('config', 'c', argParser.constants.ARG_TYPE_VALUE), - new argParser.CLIArgument('hostServer', 'h', argParser.constants.ARG_TYPE_VALUE), - new argParser.CLIArgument('hostPort', 'P', argParser.constants.ARG_TYPE_VALUE), - new argParser.CLIArgument('port', 'p', argParser.constants.ARG_TYPE_VALUE), - new argParser.CLIArgument('securePort', 's', argParser.constants.ARG_TYPE_VALUE), - new argParser.CLIArgument('noPrompt', null, argParser.constants.ARG_TYPE_FLAG), - new argParser.CLIArgument('noChild', null, argParser.constants.ARG_TYPE_FLAG), - new argParser.CLIArgument('allowInvalidTLSProxy', null, - argParser.constants.ARG_TYPE_VALUE), - new argParser.CLIArgument('mlUser', 'mu', argParser.constants.ARG_TYPE_VALUE), - new argParser.CLIArgument('mlPass', 'mp', argParser.constants.ARG_TYPE_VALUE) + new argParser.CLIArgument('config', 'c', argParser.constants.ARG_TYPE_VALUE) ]; -var config; -let agentHost = undefined; -let agentPort = undefined; var commandArgs = process.argv.slice(2); var argumentParser = argParser.createParser(MVD_ARGS); var userInput = argumentParser.parse(commandArgs); -var noPrompt = false; -var allowInvalidTLS = false; const haInstanceId = yamlConfig.getCurrentHaInstanceId(); -const componentOrder = ['zss', 'app-server']; // from lower to higher priority if (!userInput.config) { console.log('ZWED5018E - Missing one or more parameters required to run.\nConfig file was '+userInput.config); process.exit(-1); } -let configJSON = DEFAULT_CONFIG; //Overall config is a result of a heirarchy of overrides from defaults. -//CLI args > CLI -D arg > Env vars > YAML file > builtin defaults -const userConfig = yamlConfig.getConfig(userInput.config, haInstanceId, componentOrder); -//Config JSON overrides hardcoded defaults -configJSON = mergeUtils.deepAssign(configJSON, userConfig || {}); +//CLI -D arg > Env vars > YAML file +let configJSON = yamlConfig.parseZoweDotYaml(userInput.config, haInstanceId); function getSafeToPrintEnvironment(env) { const keys = Object.keys(env).filter(key => { @@ -118,156 +72,17 @@ if(process.env.overrideFileConfig !== "false"){ } else { console.log("ZWED5017I - Using config JSON, discarding CLI args"); } -const forceHttpForAgent = (process.env['ZWES_SERVER_TLS'] === 'false'); -let useHttpsForAgent = !forceHttpForAgent; -if (configJSON.agent) { - if (!forceHttpForAgent && configJSON.agent.https && configJSON.agent.https.port) { - useHttpsForAgent = true; - agentPort = Number(configJSON.agent.https.port); - } else if (configJSON.agent.http && configJSON.agent.http.port) { - useHttpsForAgent = false; - agentPort = Number(configJSON.agent.http.port); - } else { - console.warn(`ZWED5006W - Invalid server configuration. Agent specified without http or https port`); - } - if(configJSON.agent.host){ - agentHost = configJSON.agent.host; - } -} else if (configJSON.zssPort) { - agentPort = Number(configJSON.zssPort); -} -if(configJSON.node.noChild === true){ - delete configJSON.node.childProcesses; -} -if(configJSON.node.allowInvalidTLSProxy){ - allowInvalidTLS = true; -} -//finally, specific CLI flags override any above -if(process.env.overrideFileConfig !== "false"){ - let eUser = userInput.mlUser; - let ePass = userInput.mlPass; - if(eUser && ePass){ - configJSON.node.mediationLayer.enabled = true; - configJSON.node.mediationLayer.instance.instanceId = `${configJSON.node.mediationLayer.instance.app}:${Math.floor(Math.random() * 9999)}`; - configJSON.node.mediationLayer.eureka.serviceUrls.default = [`http://${eUser}:${ePass}@${configJSON.node.mediationLayer.server.hostname}:${configJSON.node.mediationLayer.server.port}/eureka/apps/`]; - } - if (userInput.hostPort) { - agentPort = Number(userInput.hostPort); - } - if(userInput.noPrompt){ - noPrompt = true; - } - if(noPrompt){ - configJSON.node.noPrompt = true; - } - if (userInput.hostServer) { - agentHost = userInput.hostServer; - } - if (userInput.port) { - if (!configJSON.node.http) { configJSON.node.http = {}; } - configJSON.node.http.port = Number(userInput.port); - } - if (userInput.securePort && configJSON.node.https) { - configJSON.node.https.port = Number(userInput.securePort); - } - if (userInput.noChild) { - configJSON.node.noChild = true; - delete configJSON.node.childProcesses; - } - if (userInput.allowInvalidTLSProxy !== undefined) { - allowInvalidTLS = (userInput.allowInvalidTLSProxy === 'true'); - } -} - -if (agentHost && agentPort) { - configJSON.agent = configJSON.agent || {}; - configJSON.agent.host = agentHost; - if (useHttpsForAgent) { - configJSON.agent.https = configJSON.agent.https || {}; - configJSON.agent.https.port = agentPort; - configJSON.agent.http = {}; - } else { - configJSON.agent.http = configJSON.agent.http || {}; - configJSON.agent.http.port = agentPort; - configJSON.agent.https = {}; - } -} -const startUpConfig = { - proxiedHost: agentHost, - proxiedPort: agentPort, - allowInvalidTLSProxy: allowInvalidTLS -}; -const appConfig = { - productCode: PRODUCT_CODE, - rootRedirectURL: configJSON.node.rootRedirectURL -}; -if (startUpConfig.proxiedHost && startUpConfig.proxiedPort) { - appConfig.rootServices = configJSON.agent && Array.isArray(configJSON.agent.rootServices) - ? configJSON.agent.rootServices - : [{ - method: '*', - url: '/login', - requiresAuth: false - }, - { - method: '*', - url: '/logout', - requiresAuth: false - }, - { - method: '*', - url: '/unixfile' - }, - { - method: '*', - url: '/datasetContents' - }, - { - method: '*', - url: '/jes' - }, - { - method: '*', - url: '/VSAMdatasetContents' - }, - { - method: '*', - url: '/datasetMetadata' - }, - { - method: '*', - url: '/omvs' - }, - { - method: '*', - url: '/ras' - }, - { - method: '*', - url: '/security-mgmt' - }, - { - method: '*', - url: '/saf-auth' - }, - { - method: '*', - url: '/password', - requiresAuth: false - }, - { - method: '*', - url: '/user-info' - } - ]; +if(configJSON.components['app-server'].node.noChild === true){ + delete configJSON.components['app-server'].node.childProcesses; } + if (cluster.isMaster) { console.log('\nZWED5018I - Initializing with configuration:\n',JSON.stringify(configJSON, null, 2)); } module.exports = function() { - return {appConfig: appConfig, configJSON: configJSON, startUpConfig: startUpConfig, configLocation: userInput.config} + return {configJSON: configJSON, configLocation: userInput.config} } /* diff --git a/lib/zluxCluster.js b/lib/zluxCluster.js index d32dd19..fe2770a 100644 --- a/lib/zluxCluster.js +++ b/lib/zluxCluster.js @@ -11,12 +11,11 @@ 'use strict'; const clusterManager = require('zlux-server-framework/lib/clusterManager').clusterManager; -const {appConfig, configJSON, startUpConfig, configLocation} = require('./zluxArgs')(); +const {configJSON, configLocation} = require('./zluxArgs')(); -clusterManager.start(appConfig, configJSON, startUpConfig, configLocation); +clusterManager.start(configJSON, configLocation); -//run as: -//node --harmony zluxCluster.js --config=../deploy/instance/ZLUX/serverConfig/zluxserver.json -h -P +//run with start.sh /* This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies diff --git a/lib/zluxServer.js b/lib/zluxServer.js index 91eed1a..5c89881 100644 --- a/lib/zluxServer.js +++ b/lib/zluxServer.js @@ -13,19 +13,15 @@ 'use strict'; const ProxyServer = require('zlux-server-framework'); -const {appConfig, configJSON, startUpConfig, configLocation} = require('./zluxArgs')(); -const proxyServer = new ProxyServer(appConfig, configJSON, startUpConfig, configLocation); +const {configJSON, configLocation} = require('./zluxArgs')(); +const proxyServer = new ProxyServer(configJSON, configLocation); proxyServer.start().then(() => { console.log("ZWED5019I - Started") }).catch(e => { console.log("ZWED5019E - Could not start the server: ", e) }); -// run as: -// node --harmony mvdServer.js --config=../config/zluxserver.json [--hostServer=] [--hostPort=#] - - - +//run with start.sh /* This program and the accompanying materials are made available under the terms of the Eclipse Public License v2.0 which accompanies diff --git a/schemas/app-server-config.json b/schemas/app-server-config.json index fb64eb9..c3f118a 100644 --- a/schemas/app-server-config.json +++ b/schemas/app-server-config.json @@ -140,6 +140,29 @@ } } }, + "readBodyLimit": { + "type": "number", + "description": "Controls the default value for the maximum amount of bytes to accept when reading an HTTP body", + "default": 102400 + }, + "checkReferrer": { + "deprecated": true, + "enabled": { + "type": boolean", + "deprecated": true, + "default": false, + "description": "Controls whether or not the server will block requests that dont have a valid referrer. This should not be needed due to using same-site cookies for the same purpose" + }, + "hosts": { + "type": "array", + "deprecated": true, + "description": "A list of hostnames that the server is hosted on so that if it sees referrers with any of these hostnames, the HTTP requests will be approved rather than rejected", + "items": { + "type": "string", + "description": "A hostname or IP as seen from a browser" + } + } + }, "internalRouting": { "type": "boolean", "description": "Controls if app-server should call one REST API from another by using a network call over a loopback address, or issue the request internal to the server by mimicking a network request", From 89611dda401b60cd7a9cfcda394b21b814ccac9e Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 25 May 2023 15:13:03 -0400 Subject: [PATCH 03/18] Update app-server-config.json Signed-off-by: 1000TurquoisePogs --- schemas/app-server-config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/schemas/app-server-config.json b/schemas/app-server-config.json index 03dba4b..e815562 100644 --- a/schemas/app-server-config.json +++ b/schemas/app-server-config.json @@ -148,7 +148,7 @@ "checkReferrer": { "deprecated": true, "enabled": { - "type": boolean", + "type": "boolean", "deprecated": true, "default": false, "description": "Controls whether or not the server will block requests that dont have a valid referrer. This should not be needed due to using same-site cookies for the same purpose" From fbf4b9e879918152361244d6ef7ec602eb3efb61 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 25 May 2023 15:20:35 -0400 Subject: [PATCH 04/18] Update start.sh Signed-off-by: 1000TurquoisePogs --- bin/start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/start.sh b/bin/start.sh index 467cc26..352dd26 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -98,6 +98,7 @@ fi if [ -z "${ZWED_FLAGS}" ]; then ZWED_FLAGS="${ZLUX_DNS_ORDER} --harmony " +fi if [ -z "$ZLUX_NO_LOGFILE" ]; then _BPX_JOBNAME=${ZWE_zowe_job_prefix}DS \ From 13667113293230475630c807f33b0ef948f07bac Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 25 May 2023 15:40:38 -0400 Subject: [PATCH 05/18] Update start.sh Signed-off-by: 1000TurquoisePogs --- bin/start.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/start.sh b/bin/start.sh index 352dd26..bd21b79 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -24,16 +24,19 @@ if [ -n "${ZWE_zowe_runtimeDirectory}" ]; then fi fi - cd ${COMPONENT_HOME}/share/zlux-app-server/bin - ZLUX_APP_SERVER_DIR=$COMPONENT_HOME/share/zlux-app-server + # used for relativeTo plugins + export ZLUX_ROOT_DIR=$COMPONENT_HOME/share else # dev env . ./validate.sh COMPONENT_HOME=$(cd ../..; pwd) - ZLUX_APP_SERVER_DIR=$COMPONENT_HOME/zlux-app-server + + # used for relativeTo plugins + export ZLUX_ROOT_DIR=$COMPONENT_HOME fi -# used for relativeTo plugins -export ZLUX_ROOT_DIR=$COMPONENT_HOME + +ZLUX_APP_SERVER_DIR=${ZLUX_ROOT_DIR}/zlux-app-server +cd ${ZLUX_APP_SERVER_DIR}/bin . ./init/node-init.sh . ./utils/setup-logs.sh From bc5581f9103068aa79e06e0a1d581426ec1f9fae Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 25 May 2023 15:57:59 -0400 Subject: [PATCH 06/18] Update defaults.yaml Signed-off-by: 1000TurquoisePogs --- defaults/serverConfig/defaults.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/defaults/serverConfig/defaults.yaml b/defaults/serverConfig/defaults.yaml index d4b79dc..5bec5d0 100644 --- a/defaults/serverConfig/defaults.yaml +++ b/defaults/serverConfig/defaults.yaml @@ -99,8 +99,7 @@ components: https: "${{ function a(){ if (components.zss.tls != false && components.zss.port) { return { port: components.zss.port }; } else { return undefined; } }; a() }}" host: "${{ function a(){ if (components.zss.tls != false && process.env.ZWE_haInstance_hostname) { return process.env.ZWE_haInstance_hostname; } }; a() }}" mediationLayer: - enabled: "${{ function a(){ if (os.platform == 'zos' && components['app-server'].node.mediationLayer?.enabled == true) { return true; } else if (components['app-server'].agent?.https?.port || components['app-server'].agent?.http?.port) { return true; } else { return false; } }; a() }}" - + enabled: "${{ components['app-server'].node.mediationLayer.enabled }}" # # for the app server to know, not the agent # host: localhost # # used by the agent From 07b20048f78d88eb7399f8c64645ce45596d8b1d Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 25 May 2023 16:09:16 -0400 Subject: [PATCH 07/18] Update defaults.yaml Signed-off-by: 1000TurquoisePogs --- defaults/serverConfig/defaults.yaml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/defaults/serverConfig/defaults.yaml b/defaults/serverConfig/defaults.yaml index 5bec5d0..0880d02 100644 --- a/defaults/serverConfig/defaults.yaml +++ b/defaults/serverConfig/defaults.yaml @@ -100,18 +100,7 @@ components: host: "${{ function a(){ if (components.zss.tls != false && process.env.ZWE_haInstance_hostname) { return process.env.ZWE_haInstance_hostname; } }; a() }}" mediationLayer: enabled: "${{ components['app-server'].node.mediationLayer.enabled }}" - # # for the app server to know, not the agent - # host: localhost - # # used by the agent - # http: - # ipAddresses: - # - 127.0.0.1 - # port: 7557 - # attls: false - gateway: - enabled: false #${{ components.gateway.enabled && components.zss.enabled }} - name: zss - prefix: "/api/v1" + serviceName: "zss" rootServices: - url: '/login' method: '*' From 3bd476a76b35c6a53ce45d68d691926377a462d3 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Fri, 26 May 2023 13:36:26 -0400 Subject: [PATCH 08/18] Update defaults.yaml Signed-off-by: 1000TurquoisePogs --- defaults/serverConfig/defaults.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/defaults/serverConfig/defaults.yaml b/defaults/serverConfig/defaults.yaml index 0880d02..02c3df8 100644 --- a/defaults/serverConfig/defaults.yaml +++ b/defaults/serverConfig/defaults.yaml @@ -15,6 +15,7 @@ zowe: # ZWED_TN3270_CODEPAGE: components: app-server: + debug: false node: hostname: "${{ function a(){ if (process.env.ZWE_INTERNAL_HOST) { return process.env.ZWE_INTERNAL_HOST; } else if (process.env.ZWE_haInstance_hostname) { return process.env.ZWE_haInstance_hostname; } else { return undefined; } }; a() }}" https: @@ -92,6 +93,8 @@ components: cookieIdentifier: ${{ zowe.cookieIdentifier }} # Specifies the default language for the server framework logging logLanguage: en + logLevels: + _zsf.*: "${{ components['app-server'].debug === true ? 5 : 2 }}" zss: # section used to define a connection to a server that can handle native or high privilege commands that the app server cannot agent: From e7094d9d76e5dfb5b00d71a9caef46af5bdf98db Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Fri, 26 May 2023 15:26:55 -0400 Subject: [PATCH 09/18] Update internal-install.sh Signed-off-by: 1000TurquoisePogs --- bin/internal-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/internal-install.sh b/bin/internal-install.sh index 022e5a3..51f9b0b 100644 --- a/bin/internal-install.sh +++ b/bin/internal-install.sh @@ -79,4 +79,5 @@ mkdir -p zlux-app-server/defaults/ZLUX/pluginStorage/org.zowe.zlux.ng2desktop/ui cp -f ${ZWED_INSTALL_DIR}/files/zlux/config/pinnedPlugins.json zlux-app-server/defaults/ZLUX/pluginStorage/org.zowe.zlux.ng2desktop/ui/launchbar/plugins/ mkdir -p zlux-app-server/defaults/ZLUX/pluginStorage/org.zowe.zlux.bootstrap/plugins cp -f ${ZWED_INSTALL_DIR}/files/zlux/config/allowedPlugins.json zlux-app-server/defaults/ZLUX/pluginStorage/org.zowe.zlux.bootstrap/plugins/ +rm zlux-app-server/defaults/plugins/* cp -f ${ZWED_INSTALL_DIR}/files/zlux/config/plugins/* zlux-app-server/defaults/plugins From 9f859026b6d371eb0957a9e234016089df730c55 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Tue, 30 May 2023 13:32:05 -0400 Subject: [PATCH 10/18] Update defaults.yaml Default to saf when possible Signed-off-by: 1000TurquoisePogs --- defaults/serverConfig/defaults.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/defaults/serverConfig/defaults.yaml b/defaults/serverConfig/defaults.yaml index 02c3df8..cc76d81 100644 --- a/defaults/serverConfig/defaults.yaml +++ b/defaults/serverConfig/defaults.yaml @@ -87,7 +87,7 @@ components: pluginsDir: ${{ components['app-server'].instanceDir }}/plugins dataserviceAuthentication: # this specifies the default authentication type for dataservices that didn't specify which type to use. These dataservices therefore should not expect a particular type of authentication to be used. - defaultAuthentication: fallback + defaultAuthentication: "${{ function a(){ if ((components.zss?.enabled == true) || (components.gateway?.enabled == true)) { return 'saf'; } else { return 'fallback'; } }; a() }}" rbac: false instanceID: ${{ zowe.rbacProfileIdentifier }} cookieIdentifier: ${{ zowe.cookieIdentifier }} From 6db9d1cea45f1b7af966ed07f3172792738c4682 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Mon, 5 Jun 2023 15:33:15 -0400 Subject: [PATCH 11/18] Update node-init.sh Signed-off-by: 1000TurquoisePogs --- bin/init/node-init.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/init/node-init.sh b/bin/init/node-init.sh index 5b02005..663d1df 100644 --- a/bin/init/node-init.sh +++ b/bin/init/node-init.sh @@ -14,6 +14,9 @@ else export NODE_BIN=node fi +# These are used on z/OS and ignored elsewhere. +# Some are already applied by zwe, but in dev, we add them. +# They control text encoding primarily. export "_CEE_RUNOPTS=XPLINK(ON),HEAPPOOLS(ON)" export _BPXK_AUTOCVT=ON export __UNTAGGED_READ_MODE=V6 From 605e8ad26958361b113a05ecb1ccd4ad921a3572 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Mon, 5 Jun 2023 15:43:43 -0400 Subject: [PATCH 12/18] Update start.sh Signed-off-by: 1000TurquoisePogs --- bin/start.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/start.sh b/bin/start.sh index bd21b79..6ad6106 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -44,7 +44,8 @@ cd ${ZLUX_APP_SERVER_DIR}/bin # Get config path or fail if [ -z "${ZWE_CLI_PARAMETER_CONFIG}" ]; then echo "ZWE_CLI_PARAMETER_CONFIG is not defined. Only defaults will be used." - echo "To customize, rerun script with it defined to a list of paths to zowe.yaml files such as FILE(/yaml1.yaml):FILE(/path/to/yaml2.yaml)" + echo "To customize, rerun script with it defined to a list of paths to zowe.yaml files such as ZWE_CLI_PARAMETER_CONFIG=FILE(/yaml1.yaml):FILE(/path/to/yaml2.yaml)" + echo "FILE items specified on the right of the list will have properties overridden by FILE items on the left of the list, resulting in one merged configuration" if [ -e "${HOME}/.zowe/zowe.yaml" ]; then echo "Found and using ${HOME}/.zowe/zowe.yaml" else From c2f43b354af969d6c7809228484f975a4da34aad Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Mon, 5 Jun 2023 15:45:04 -0400 Subject: [PATCH 13/18] Update start.sh Signed-off-by: 1000TurquoisePogs --- bin/start.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/start.sh b/bin/start.sh index 6ad6106..c8d5510 100755 --- a/bin/start.sh +++ b/bin/start.sh @@ -54,6 +54,7 @@ if [ -z "${ZWE_CLI_PARAMETER_CONFIG}" ]; then fi CONFIG_FILE="FILE(${HOME}/.zowe/zowe.yaml):FILE(${ZLUX_APP_SERVER_DIR}/defaults/serverConfig/defaults.yaml)" else + # Note in production, ZWE_CLI_PARAMETER_CONFIG is already a merged file, so no concern about PARMLIB here. CONFIG_FILE="FILE(${ZWE_CLI_PARAMETER_CONFIG}):FILE(${ZLUX_APP_SERVER_DIR}/defaults/serverConfig/defaults.yaml)" fi From ca16bf7116001a58398f1eb350ba356a54e76536 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Mon, 5 Jun 2023 15:47:11 -0400 Subject: [PATCH 14/18] Update defaults.yaml Signed-off-by: 1000TurquoisePogs --- defaults/serverConfig/defaults.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/defaults/serverConfig/defaults.yaml b/defaults/serverConfig/defaults.yaml index cc76d81..0be83b0 100644 --- a/defaults/serverConfig/defaults.yaml +++ b/defaults/serverConfig/defaults.yaml @@ -1,7 +1,7 @@ zowe: workspaceDirectory: ${{ process.env.HOME + '/.zowe/workspace' }} externalDomains: ${{ function a() { if (process.env.ZWE_zowe_externalDomains) { return process.env.ZWE_zowe_externalDomains.split(','); } else { return [ os.hostname() ] } }; a() }} - envrionments: + environments: ZWED_SSH_PORT: 22 ZWED_TN3270_PORT: 23 ZWED_TN3270_SECURITY: telnet @@ -48,7 +48,9 @@ components: return [ "../defaults/serverConfig/zlux.keystore.cer" ]; } }; a() }}' certificateAuthorities: '${{ function a() { - if(zowe.certificate?.pem?.certificateAuthorities) { + if (zowe.certificate?.truststore?.type == "JCERACFKS") { + return [ zowe.certificate.truststore.file ]; + } else if(zowe.certificate?.pem?.certificateAuthorities) { return [zowe.certificate.pem.certificateAuthorities]; } else { return ["../defaults/serverConfig/apiml-localca.cer"]; } }; a() }}' From 070c960353d725f538ece54d37d46b20ba0a1915 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Thu, 8 Jun 2023 16:38:22 -0400 Subject: [PATCH 15/18] Update defaults.yaml Add zss agent section to app-server section Signed-off-by: 1000TurquoisePogs --- defaults/serverConfig/defaults.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/defaults/serverConfig/defaults.yaml b/defaults/serverConfig/defaults.yaml index 0be83b0..6a0451f 100644 --- a/defaults/serverConfig/defaults.yaml +++ b/defaults/serverConfig/defaults.yaml @@ -97,6 +97,7 @@ components: logLanguage: en logLevels: _zsf.*: "${{ components['app-server'].debug === true ? 5 : 2 }}" + agent: ${{ components.zss.agent }} zss: # section used to define a connection to a server that can handle native or high privilege commands that the app server cannot agent: From 0af67af5d654f6029b4b49758b705f88e36ab363 Mon Sep 17 00:00:00 2001 From: sanchi-t Date: Mon, 19 Jun 2023 23:58:27 +0530 Subject: [PATCH 16/18] Added troubleshooting in zowe.yaml file Signed-off-by: sanchi-t --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 204ca8a..74639a5 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,11 @@ app-server.bat When the App Server has started, one of the messages you will see as bootstrapping completes is that the server is listening on the HTTP/s port. Now, the server is ready for use. +### Troubleshooting +If you encounter an error message saying `No config file found, initializing`, it means that the App Server could not find a configuration file in the expected location. + +To fix this issue, you need to create a zowe.yaml file in the following directory: `%USERPROFILE%\.zowe\workspace\app-server\serverConfig`. You can use [this](https://github.com/zowe/zlux-app-server/blob/v2.x/staging/defaults/serverConfig/zowe.yaml) template as a starting point. + ### Server Logs When the server starts, it writes logs to a text file. On z/OS, Unix, and Linux, the server also logs to the terminal via stdout. To view the entire logs, you can find the log file within the location specified by the zowe server configuration parameter `zowe.logDirectory`, but will default to `~/.zowe/logs` or `%USERPROFILE%/.zowe/logs` (Windows) if not specified. The log file starts with "appServer" and the filename may also include a timestamp. From 1950cdddb9fb090466945dc0ca41055f84c94a95 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Wed, 21 Jun 2023 09:30:37 -0400 Subject: [PATCH 17/18] Add way to debug yaml config parsing Signed-off-by: 1000TurquoisePogs --- lib/zluxArgs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/zluxArgs.js b/lib/zluxArgs.js index 77101a8..c914fe7 100644 --- a/lib/zluxArgs.js +++ b/lib/zluxArgs.js @@ -35,7 +35,8 @@ if (!userInput.config) { } //Overall config is a result of a heirarchy of overrides from defaults. //CLI -D arg > Env vars > YAML file -let configJSON = yamlConfig.parseZoweDotYaml(userInput.config, haInstanceId); +//Hack for enabling debug of this process... we need to read config before config is parsed, using env var here. env var translation misses _ and . and - +let configJSON = yamlConfig.parseZoweDotYaml(userInput.config, haInstanceId, Number(process.env['ZWE_components_app_server_logLevels_zsf_bootstrap'])>3); function getSafeToPrintEnvironment(env) { const keys = Object.keys(env).filter(key => { From 5b7966fe1fcef7333867b913964fa05bcb042238 Mon Sep 17 00:00:00 2001 From: 1000TurquoisePogs Date: Mon, 26 Jun 2023 15:26:47 -0400 Subject: [PATCH 18/18] Update CHANGELOG.md Signed-off-by: 1000TurquoisePogs --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4c6628..b6f1bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to the Zlux App Server package will be documented in this file. +## v2.10.0 + +- Enhancement: Migrated app-server configuration options into a "defaults.yaml" file which adheres to the schema of the Zowe config. This allows users to see the default behaviors more clearly, and can serve as an example by which users can customize their Zowe config to override such defaults. (#247) +- Bugfix: Fixed the URLs app-server would print in the logs describing where it was accessible from. Messages were incorrectly pointing at the discovery server instead of the gateway server. (#247) + ## v2.9.0 - Bugfix: Recognizers from multiple plugins could not be merged due to an error in the merge code execution at startup.