#!/bin/sh
# #################################################################################
# Exceed TurboX Connection Node
# © Rocket Software, Inc. or its affiliates. All Rights Reserved.
# ROCKET SOFTWARE, INC. CONFIDENTIAL
# #################################################################################
# msg.txt: Messages for all shell scripts in English
# #################################################################################

logIncident()
{
	if [ "${1}" = "1" ] ; then
		incidentCategory="INFORMATION"
	elif [ "${1}" = "2" ] ; then
		incidentCategory="WARNING"
	elif [ "${1}" = "3" ] ; then
		incidentCategory="FATAL ERROR"
	else
		incidentCategory="UNKNOWN"
	fi
	
	thisLogFile="${2}"
	smallTab="  "
	
	${ECHO} "${incidentCategory}: `basename ${0}`" >> "${thisLogFile}"
	
	if [ ! "${3}x" = "x" ] ; then
		${ECHO} "${smallTab}${3}" >> "${thisLogFile}"
	fi
	
	if [ ! "${4}x" = "x" ] ; then
		${ECHO} "${smallTab}${4}" >> "${thisLogFile}"
	fi
	
	if [ ! "${5}x" = "x" ] ; then
		${ECHO} "${smallTab}${5}" >> "${thisLogFile}"
	fi
	
	if [ ! "${6}x" = "x" ] ; then
		${ECHO} "${smallTab}${6}" >> "${thisLogFile}"
	fi
	
	if [ ! "${7}x" = "x" ] ; then
		${ECHO} "${smallTab}${7}" >> "${thisLogFile}"
	fi
	
	if [ ! "${8}x" = "x" ] ; then
		${ECHO} "${smallTab}${8}" >> "${thisLogFile}"
	fi
	
	if [ ! "${9}x" = "x" ] ; then
		${ECHO} "${smallTab}${9}" >> "${thisLogFile}"
	fi
	
	${ECHO} >> "${thisLogFile}"
}

logMigIncident()
{
	logIncident "1" "${migLogFile}" "${migMsg}"    
}

handleMigMsg()
{
	${ECHO}
	${ECHO} "${migMsg}"
	
	logMigIncident
}

mkNonExistingDir()
{
	if [ ! -d "${1}" ] ; then
		mkdir -p "${1}"
	fi
}

change_owner()
{
	chown $*
}

COMPANY="Rocket"
VERSION=
SRV_NAME="Exceed TurboX Connection Node"
PROD_NAME="${SRV_NAME}${VERSION}"
INFO="INFORMATION:       $0:       "
WARN="WARNING:           $0:       "
FATAL="FATAL ERROR:       $0:       "

INSTALLING="Installing $PROD_NAME"

# General Messages
UTILITY=utility
USAGE="usage"
LOGFILE_ARG="<log file>"
Q_CONTINUE="Continue [y]es or [n]o (<Enter> for no): \c"
WAIT_CONTINUE="Please press <Enter> to continue: \c"
PRESS_ENTER="Please press <Enter> to continue: \c"
ABORTING="Installation aborted"
INSTALL_FAILED="Installation failed (check $logfile for details)"
ERROR_EXECUTE="Error executing"
INCORRECT_ARGS="incorrect arguments"
EXECUTING="Executing"
FILE_NOTFOUND_SKIPPING="not found, skipping"
COULDNT_CREATE_CONFIG="Could not create necessary config file: "

TITLE_BAR="======================================="
MIG_TITLE_BAR="=================================="

LOG_TITLE="Creating Log File"
LOG_CANT_CREATE_LOG="Cannot create log file"
LOG_TO="Logging to"
LOG_HEADER_BEGIN="##########################################################################"
LOG_HEADER_BANNER="###        $PROD_NAME Installation Log                                    ###"
LOG_HEADER_END="##########################################################################"
LOG_DATE="Started on `date` by $USER"

CHECK_FILE_TITLE="Checking Installation Tree"
CHECK_FILES="Checking files..."
CHECK_FILES_DONE="Done checking files"
CHECK_CANT_FIND_DIRS="Cannot find necessary directories (problem un-taring?)"
CHECK_FOUND_DIRS="Found bin, conf, log and help dirs"
CHECK_SCRIPT_NOT_EXECUTABLE="Install scripts are not executable"
CHECK_SCRIPT_EXECUTABLE="Install scripts are executable"
CHECK_LOG_FOR_WARNING="Check log file for warnings !"
CHECK_NO_EXECUTE_PERM="Necessary files are missing or do not have execute permission."
CHECK_EXECUTE_PERM="This user has execute permission on binaries"

LICENSE_TITLE="Licensing"
LICENSE_CONTINUE_Q="Please press <Enter> to view License Agreement: \c"
LICENSE_ACCEPTED="License accepted"
LICENSE_NOT_ACCEPTED="License not accepted"
LICENSE_ACCEPT_Q="Please press [y] to accept, [n] to decline or <Enter> to read again: \c"

ACTIVATION_TITLE="${SRV_NAME} Activation"
ACTIVATION_CONTINUE="Please press <Enter> to launch keymanager utility: \c"
ACTIVATION_NOKEYS1="No activation keys installed, you must provide a valid"
ACTIVATION_NOKEYS2="Activation Key to install this product"

ADMIN_TITLE="${SRV_NAME} Administrator"


PROXY_MANAGER_OPTS_TITLE="${SRV_NAME} Settings"
PROXY_MANAGER_RUN_SCRIPT="Calling $PROD_NAME install script"
PROXY_MANAGER_INSTALL_FAILED="$PROD_NAME installation failed"
PROXY_MANAGER_INSTALL_STOPPED="$PROD_NAME installation stopped by user (check log file for details)."

PROXY_INSTALL="Installing $PROD_NAME Proxy"
PROXY_RUN_SCRIPT="Calling $PROD_NAME Proxy install script"
PROXY_INSTALL_OK="$PROD_NAME Proxy installed successfully" 
PROXY_INSTALL_FAILED="$PROD_NAME Proxy installation failed"

PROD_INSTALL_OK="$PROD_NAME installed successfully"
PROD_INSTALL_TIME="Installation finished on `date`"
PROD_INSTALL_LAST_WORDS1="$PROD_NAME installed successfully."
PROD_INSTALL_LAST_WORDS2="Check log file for information and warnings:"

LAUNCHING_TITLE="Launching $SRV_NAME"
QUERY_LAUNCH_MGR0="Would you like to start Server now?"
QUERY_LAUNCH_MGR="[y]es or [n]o (<Enter> for no): \c"

GLOBXINIT_TITLE="Configure GlobalXinitrc"

MIGRATION_TITLE="$SRV_NAME Migration"
MIGRATION_RUN_SCRIPT="Calling migration script"

DS_WARNING="Please ensure that Remote Data Store is up to date."
DS_WARNING2="Please ensure Remote Data Store is up to date:"

BOOTTIME_TITLE="${SRV_NAME} Startup"
BOOTTIME_RUN_SCRIPT="Calling server startup script"

POPULATE_TEMPLATES_COMMON_DIRS="Populating Templates Common Files"
COPYING_FILES="Copying files..."

# Messages for ttxpminstall script
TTXPM_ENTER_CM_PORT="Please enter Server Port         ["
TTXPM_ENTER_CM_PORT2="]: \c"
TTXPM_ENTER_FIRST_DISPLAY="Please enter Starting Display ID    ["
TTXPM_ENTER_FIRST_DISPLAY2="]: \c"
TTXPM_BAD_PORT1="Please enter a port number between "
TTXPM_BAD_PORT2=" and "
TTXPM_BAD_FIRSTD1="Please enter a display number between "
TTXPM_BAD_FIRSTD2=" and "
TTXPM_USE_SSL="Enable SSL? [y]es or [n]o (<Enter> for no): \c"
TTXPM_FORCE_SSL_CLI="Allow Clients to Turn Off Proxy's SSL? [y]es or [n]o (<Enter> for no): \c"
TTXPM_SSL_NOTE1="For information about installing SSL certificates," 
TTXPM_SSL_NOTE2="please consult the documentation."
TTXPM_LOG_FORMAT_1="${SRV_NAME} can create logs in either HTML format or plain text"
TTXPM_LOG_FORMAT_2="Create logs in HTML format? [y]es or [n]o (<Enter> for no): \c"
TTXPM_OPTIONS="Selected Settings:"
TTXPM_CM_PORT_NUMBER="Server Port:         "
TTXPM_FIRST_DISPLAY="Starting Display ID: "
TTXPM_HTML_LOG="Log format: HTML"
TTXPM_TEXT_LOG="Log format: plain text"
TTXPM_SSL_ON="SSL: Enabled"
TTXPM_SSL_OFF="SSL: Disabled"
TTXPM_FORCE_SSL_ON="Allow Clients to Turn Off Proxy's SSL: No"
TTXPM_FORCE_SSL_OFF="Allow Clients to Turn Off Proxy's SSL: Yes"
TTXPM_SAVE_OPTIONS0="Would you like to proceed with these settings?"
TTXPM_SAVE_OPTIONS="[y]es, [r]edo or [q]uit (<Enter> for redo): \c"
TTXPM_CREATING_FILE="Creating file"
TTXPM_WARN_PORT_IN_USE1="Warning! Port number"
TTXPM_WARN_PORT_IN_USE2="may already be in use,"
TTXPM_WARN_PORT_IN_USE3="use this port anyway? [y]es or [n]o: \c"
TTXPM_BAD_PROXY_NOT_DIFFERENT="Port numbers must be different from those already chosen"
TTXPM_ENABLE_SUSPEND_R="Allow Clients to Suspend/Resume Sessions? [y]es or [n]o (<Enter> for no): \c"
TTXPM_SR_ON="Allow Clients to Suspend/Resume Sessions: Yes"
TTXPM_SR_OFF="Allow Clients to Suspend/Resume Sessions: No"



# Messages for globxinit script
GLOB_AUTOCONF="Creating GlobalXinitrc..."
GLOB_BACKEDUP="Backed up existing copy of GlobalXinitrc"
GLOB_VIEW_FILE="Please press <Enter> to view GlobalXinitrc: \c"
GLOB_EDIT_FILE_1="This file is named"
GLOB_EDIT_FILE_2="Edit it to reflect local setup and preferences"
GLOB_USING_GLOB="Using Global Xinitrc startup mode"
GLOB_LINKED_1="Linked"
GLOB_LINKED_2="to"
GLOB_REMOVE_REPLACE_1="Remove or rename "
GLOB_REMOVE_REPLACE_2="and restart install"

# Messages for admin script
ADMIN_ENTER_UNAME1="Please enter Server Administrator Account name [root]: \c"
ADMIN_BAD_DIR="Could not create admin dir: "
ADMIN_BAD_FILE="Could not create admin file: "
ADMIN_SUCCESS="Added Administrator: "


# Messages for migration script
# EXISTINGSVR="${SRV_NAME} or Exceed onDemand Server"
EXISTINGSVR="Exceed TurboX Connection Node"
MIG_DO_MIGRATION_Q1="Would you like to migrate an existing Server installation? "
MIG_DO_MIGRATION_Q2="[y]es or [n]o (<Enter> for no): \c" 

MIG_WHERE_Q1="Please enter location of existing installation"
MIG_WHERE_Q2="["
MIG_WHERE_Q3="]: \c"
MIG_WHERE_Q4="\c"
MIG_WHERE_NODEFAULT_Q="Please enter location of existing installation:"

MIG_NO_SUCH_DIR1="Directory "
MIG_NO_SUCH_DIR2=" does not exist."
MIG_IS_CURRENT=" is the current directory."
MIG_FROM="Migrating settings from: "
MIG_DIR_NO_GOOD="No version of $SRV_NAME was installed at "
MIG_COPY_XINIT="Migrating GlobalXinitrc file."
MIG_BUP_GLOBXINIT="Backing up GlobalXinitrc file to "
MIG_COPY_USERSTNGS="Migrating default user settings file..."
MIG_BUP_USERSTNGS="Backing up default user settings file to "
MIG_COPY_GLOBAL_PROFILES="Migrating global profiles:"
MIG_BUP_GLOBAL_PROFILE1="Backing up existing global profile to: "
MIG_COPY_USER_DIRS="Migrating user settings and profiles:"
MIG_BUP_USER="Backing up existing user dir to: "
MIG_COPY_KEYS="Migrating SSL keys..."
MIG_BUP_SSL="Backing up existing SSL key to: "
MIG_NO_MIGRATION="No migration"
MIG_BUP_USERS_WARNING="Some existing user directories were backed up in the conf/users directory"
MIG_COPYING="Migrating " 
MIG_BACKINGUP1="Backing up "
MIG_BACKINGUP2=" to "
MIG_COPY_FONTS="Migrating fonts..."

# messages for boottime startup script
BOOT_INFO_AUTOMATIC="Connection Node configured to start automatically as a system service.  Use 'otetxcn' command to manage this."
BOOT_CONFIRM="[y]es or [n]o (<Enter> for no): \c"
BOOT_CONFIRM_Y="[y]es or [n]o (<Enter> for yes): \c"
BOOT_OVERWRITE_Q1="init script already exists."
BOOT_OVERWRITE_Q2="Would you like to overwrite this script?"
BOOT_CREATE_Q1="Would you like to create another script?"
BOOT_ABORTING="Creating boot time startup script(s) aborted."
BOOT_LOGFILE="boottime.log"
BOOT_LOG_HEADER_BEGIN="#############################################################################"
BOOT_LOG_HEADER_BANNER="## $PROD_NAME list of boot time startup scripts and links                    ##"
BOOT_LOG_HEADER_END="#############################################################################"
BOOT_CANT_CREATE="Could not create script:"
BOOT_CANT_GET_UNIT_NAME="Could not find usable unit name"
BOOT_REMOVE_ORPHANED="Remove orphaned file pointing to non-existent installation?"
BOOT_REMOVE_EXTRA="Remove orphaned file pointing to this installation?"
BOOT_STOP_UNIT_ON_REMOVE="Unit won't be fully removed until it is stopped. Stop service (if running) now?"
BOOT_DISABLED_NOT_STOPPED="Note: Service is disabled on boot but is still running now."
BOOT_ALREADY_ENABLED="Bootstart is already enabled: "
BOOT_UPDATE_EXISTING="Updating existing unit file for this install path: "
BOOT_CREATED_UNIT="Created systemd unit"
BOOT_UPGRADE_SYSV="Upgrading SysV-generated unit file to pure systemd: "
BOOT_UPGRADE_SYSV_RENAME="Found unit name is already used. Using new unit name: "
BOOT_UPGRADE_SYSV_CLOBBER="A systemd unit with this name already exists, and can't find a suitable alternative name. Overwriting, after backup made:"
BOOT_FIXING_INIT_HEADERS="Fixing malformed LSB Init headers for: "
BOOT_RESTART_EXISTING="Service must be restarted.  (Existing sessions will not be affected.) Continue?"
BOOT_NO_RESTART_EXISTING="Bootstart not enabled."
BOOT_RESTART_FOR_SYSTEMD="Restart service so 'systemctl status' works?"
BOOT_NEED_RESTART_FOR_SYSTEMD="You may need to restart the service before it is fully recognized by systemd."
BOOT_UNIT_ALREADY_EXITS="Error: Systemd unit already exists:"
BOOT_PATH_RUNNING="Systemd service for this installation"
BOOT_DONE="${SRV_NAME} boot time startup script(s) created successfully."
BOOT_LOG_INFO="Check log file for the list of startup script(s):"
BOOT_START_MSG="${SRV_NAME} starting."
BOOT_START_MSG_LINUX="Starting ${SRV_NAME}" 
BOOT_STOP_MSG="${SRV_NAME} stopping."
BOOT_STOP_MSG_LINUX="Stopping ${SRV_NAME}" 

# messages for ecsbootstart and ecsbootstop script
BOOTSTART_BANNER="ecsbootstart - ${PROD_NAME}"
BOOTSTOP_BANNER="ecsbootstop - ${PROD_NAME}"
BOOT_NO_LOGFILE="Boot time startup script(s) are not installed or no log file exists."
BOOT_DO_BOOTSTOP_Q1="Would you like to remove Server boot time startup script(s) from the system?"
# BOOT_DO_BOOTSTOP_Q2="boot time startup script(s) from the system?"
BOOT_STOP_ABORTING="Removing boot time startup script(s) aborted."
BOOT_REMOVE_Q="The following file(s) will be removed from the system:"
BOOTSTOP_CONFIRM="Would you like to remove the file(s)?"
BOOT_CANT_ACCESS="Could not access to the log directory."
BOOT_STOP_DONE="Boot time startup script(s) have been removed from the system."

# messages for getsslinfo.sh
SSL_LIB_DETECT_TITLE="Detecting SSL libraries"
SSL_LIB_NOT_FOUND="SSL related libraries could not be found." 
SSL_LIB_NOT_FOUND0="SSL related libraries required to secure communications could not be found." 
SSL_LIB_NOT_FOUND01="The well known locations and library names used in the search are under"
SSL_LIB_NOT_FOUND1="To continue without SSL configured, please select [y]es."
SSL_LIB_NOT_FOUND2="Otherwise, please stop installation now and install SSL library first."
SSL_LIB_NOT_FOUND3="Continue [y]es or [n]o (<Enter> for no): \c" 
SSH_NOT_FOUND="ssh could not be found."
SSH_NOT_FOUND2="ssh could not be found in $PATH."

pre="    "
pre2="  "
