Skip to content

Commit

Permalink
Try to detect ssh and telnet port
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Zeithaml <[email protected]>
  • Loading branch information
Martin-Zeithaml committed Aug 15, 2024
1 parent 497eaef commit 3372f4f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
33 changes: 33 additions & 0 deletions bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,39 @@ if [ "$ZWE_zowe_verifyCertificates" = "DISABLED" ]; then
export NODE_TLS_REJECT_UNAUTHORIZED=0
fi

# Check ssh and telnet port
if [ -z "${ZWED_SSH_PORT}" ]; then
if [ -e "/etc/ssh/sshd_config" ]; then
ssh_port=$(cat "/etc/ssh/sshd_config" | grep '^Port.*' | awk -F\ '{print $2}')
# Empty or non-numeric? Set default
if [ -z "${ssh_port}" ] || [ -z $(echo "${ssh_port}" | grep -E '^[0-9]{1,5}$') ]; then
export ZWED_SSH_PORT=22
else
# Out of range? Set default
if [ "${ssh_port}" -lt 1 ] || [ "${ssh_port}" -gt 65535 ]; then
export ZWED_SSH_PORT=22
else
export ZWED_SSH_PORT="${ssh_port}"
fi
fi
fi
fi

if [ -z "${ZWED_TN3270_PORT}" ]; then
if [ -e "/etc/services" ]; then
telnet_port=$(cat "/etc/services" | grep '^telnet' | awk -F\ '{print $2}' | awk -F/ '{print $1}')
if [ -z "${telnet_port}" ] || [ -z $(echo "${telnet_port}" | grep -E '^[0-9]{1,5}$') ]; then
export ZWED_TN3270_PORT=23
else
if [ "${telnet_port}" -lt 1 ] || [ "${telnet_port}" -gt 65535 ]; then
export ZWED_TN3270_PORT=23
else
export ZWED_TN3270_PORT="${telnet_port}"
fi
fi
fi
fi

# set production mode if applicable
export NODE_ENV=${NODE_ENV:-production}

Expand Down
4 changes: 2 additions & 2 deletions defaults/serverConfig/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ 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() }}
environments:
ZWED_SSH_PORT: 22
ZWED_TN3270_PORT: 23
ZWED_SSH_PORT: "${{ process.env.ZWED_SSH_PORT ? process.env.ZWED_SSH_PORT : 22 }}"
ZWED_TN3270_PORT: "${{ process.env.ZWED_TN3270_PORT ? process.env.ZWED_TN3270_PORT : 23 }}"
ZWED_TN3270_SECURITY: telnet
ZWED_SSH_HOST: ${{ zowe.externalDomains[0] }}
ZWED_TN3270_HOST: ${{ zowe.externalDomains[0] }}
Expand Down

0 comments on commit 3372f4f

Please sign in to comment.