#!/bin/bash -p

# Finn Magnusson , finn.magnusson@ericsson.com

######################################################################################
#                                                                                    #
#  Ericsson AB 2010    - All Rights Reserved                                        #
#                                                                                    #
# The copyright to the computer program(s) herein is the property   of Ericsson AB,  #
# Sweden. The programs may be used and/or copied only with the written permission    #
# from Ericsson AB or in accordance with the terms and  conditions stipulated in the #
# agreement/contract under which the program(s) have been supplied.                  #
#                                                                                    #
######################################################################################

##########################################################################
# Moshell folders location  (DO NOT EDIT)
##########################################################################
moshell_version="18.0g"
moshelldir=`dirname "$0"`
if [[ $moshelldir != /* ]] ; then moshelldir=`pwd`/$moshelldir ; fi
commonjardir="$moshelldir/commonjars"
sitefiledir="$moshelldir/sitefiles"

##########################################################################
# FOLLOWING SETTINGS ARE CUSTOMIZABLE BY EACH USER.
# If changes need to be made to the default values, it is recommended to do it in
# one of the following files:
#     moshell/jarxml/moshellrc (settings will apply to all users)
#     ~/.moshellrc             (settings will apply to own user only)
# It's also possible to specify a uservariable on session basis:
#     at moshell startup with "-v" option
#     or from within moshell, using the "uv" command
##########################################################################

#===============================================================================
# The list of uservariables that can only be set in the file moshell/moshell and cannot be overridden by user settings
#===============================================================================
#uv_blacklist=moscommandlog,moscommanddir,command_restriction,blocked_commands

#===============================================================================
# Check if the moshell version is up to date. The latest moshell version available on utran01 server is checked at startup.
# A warning is printed if the current version is less than the newest version. This check is available from 10.0c onwards.
# 0=no check, 1=warning only, 2=exit if old version
# Default is 1 for moshell, and 0 for AMOS (since contact to utran01 server is necessary for the check)
#===============================================================================
moshellversion_check=1

#===============================================================================
# Check if the moshell version is not too old. Only done in case moshell version check could not be done (eg no contact to utran01 server)
# If the number of weeks between now and the release date of the current moshell version is greater than moshell_max_age then a warning is printed.
# 0=no check. Default 15 weeeks.
#===============================================================================
moshell_max_age=15

#===============================================================================
# Check if enough free disk space and RAM memory on the workstation:
# 0=no check, 1=warning only, 2=exit if not enough space
# Default is ram_check=0/disk_check=1 for moshell, and ram_check=disk_check=2 for AMOS
#===============================================================================
disk_check=1
ram_check=0

#===============================================================================
# The minimum free disk space and RAM memory
# Default 1G (1 Gigabyte)
# Syntax: G for gigabytes, M for megabytes, K for kilobytes
#===============================================================================
disk_limit=1G
ram_limit=1G

#===============================================================================
# The maximum number of allowed moshell sessions 
# - max_sessions: max number of sessions allowed per user
# - max_sessions_all: total number of allowed sessions on the workstations
# Default 0 = unlimited number of sessions
#===============================================================================
max_sessions=0
max_sessions_all=0

#===============================================================================
# Catch CTRL-C
#  - 0: dont catch CTRL-C
#  - 1: (default) CTRL-C run while the moshell prompt is idle is disabled, to avoid accidentally killing the moshell session while trying to copy text to clipboard
#===============================================================================
catch_ctrl_c=1

#================================================================================
# jarxml directory (to store MOM files and jar files which are fetched from the node)
#================================================================================
jarxmldir=$moshelldir/jarxml

#================================================================================
# Path to java. Java version must be 1.4.2 or higher.
# The java_options can be used to pass on any options to the java process , eg "-mx1g" to set the maximum heap size
# To specify several java options, use comma sign as separator between the options. Eg: -mx1g,-ms1g
#================================================================================
java="/usr/bin/java"
java_options="-mx1g"

#================================================================================
# Setting the java property jacorb.security.ssl.client.cipher_suites when corba_class>=3
#   - use_jacorb_ciphers=0  => cipher_suites will not be set
#   - use_jacorb_ciphers=1  => cipher_suites will be set to the following defaults: TLS_RSA_WITH_AES_128_CBC_SHA if CPP<=17.Q3 and not set if CPP>=17.Q4
#   - use_jacorb_ciphers=2  => cipher_suites will be set to the value of the uservariable "jacorb_ciphers"
#================================================================================
use_jacorb_ciphers=1
jacorb_ciphers=""

#================================================================================
# Path to perl, used for commands pmr, pmx, steg, fclean
# Note: cannot be changed with the uv command, only from moshellrc file or -v option at startup
#================================================================================
perl="/usr/bin/perl"

#================================================================================
# IPDATABASE FILE : to specify node names and node passwords, see example in moshell/examples/ipdatabase
# several ipdatabase files can be specified, just separate them with commas.
# eg: ip_database=$sitefiledir/ipdatabase,/home/toto/myipdatabase
#================================================================================
ip_database=$sitefiledir/ipdatabase

#================================================================================
# CORBA CLASS:
#  1 = vbjorb (secure + unsecure nodes)
#  2 = jacorb unsecure
#  3 = jacorb secure with SAM credential (uses sa_credential and sa_password)
#  4 = jacorb secure with SLS login and dowload of nm_credential
#       (uses sls_urls, sls_username, sls_password and puts the NM credential in nm_credential)
#  5 = jacorb secure with NM credential (uses file located in nm_credential)
#================================================================================
corba_class=2

#================================================================================
# CORBA ORB init: the type of reference used for initialising the ORB
#  0 = connect with IOR file, with the property "NameRootIORPath" -> default setting
#  1 = connect with IP address and port, with the property "ORBInitRef.NameService"
#================================================================================
corba_orbinit=0

#================================================================================
# Path to jacorb files
# 0 = use the jacorb files in the user's jarxml folder
# 1 = use the jacorb files in the moshell/commonjars folder
#================================================================================
use_default_jacorb=1

#================================================================================
# CORBA SECURITY METHOD, only applicable when corba_class=1
#  1 = uses host credential
#  2 = uses stand-alone credential
#================================================================================
security_method=1

#================================================================================
# PATH TO HOST CREDENTIAL
# This file is required when corba_class=1 and security_method=1
# Can be generated by PKS server or found on node (in /c/java/host.p12)
# or found in Ranos (in /etc/opt/ericsson/nms_cif_security/certificates/host.p12 )
# This file has an unlimited lifetime.
#================================================================================
credential=$commonjardir/host.p12

#================================================================================
# PATH TO STAND-ALONE CREDENTIAL and stand-alone password
# This file is required when corba_class=3 (or corba_class=1 and security_method=2)
# Can be downloaded from SLS server or with EMAS.
# This file has a limited lifetime, set by SLS server.
#================================================================================
sa_credential=$HOME/Ericsson/OMSec/sam.p12
#sa_password="oemas"


#================================================================================
# PATH TO STAND-ALONE CREDENTIAL folder
# Used on COM nodes together with the setting xxx to allow the user to choose from a list of sam.p12 files
#================================================================================
sa_folder=$HOME/Ericsson/OMSec

#================================================================================
# PATH TO NETWORK-MODE CREDENTIAL
# The path nm_folder indicates the folder where the NM credential will be downloaded when corba_class=4
# The path nm_credential indicates the path to the NM credential file that will be used when corba_class=5
#================================================================================
nm_folder=$HOME/Ericsson/OMSec
nm_credential=$HOME/Ericsson/OMSec/ssucredentials.xml

#================================================================================
# URLs and login details for SLS (one or more URLs can be given)
# If the uservariable sls_urls is empty, moshell will try to find it out by http download of the file /configuration/sls_address.cfg
# Only sls_username has a default value, sls_urls and sls_password are not set by default:
#  - when sls_urls is not set, moshell tries to find it out by query to the node (the SLS url is usually set in ManagedElementData)
#  - when sls_password is not set, moshell will prompt for the password. This is more secure than writing the password in a file or on command line
#================================================================================
sls_username=$USER
#sls_password=sls
#sls_urls=https://137.58.194.190:8443/sls/servlet/sls,https://137.58.194.191:8443/sls/servlet/sls

#================================================================================
# The CPP node has Security Level 3 (default: no)
# When sl3=1 (ie the CPP node has security level 3), the ssh/sftp login uses sls_username and sls_password instead of username and ipdatabase password
# Also when sl3=1, the following setting apply: smart_password=0, secure_shell=1, secure_ftp=1.
# If the feature smart_sl3 is activated (see description below), the sl3 setting will automatically change to 1 upon detection of node in security level 3
#================================================================================
sl3=0

#================================================================================
# Smart sl3 (0=no, 1=yes):
# automatically change the sl3 setting to 1 if the node has security level 3. Default=enabled (recommended).
# Note: the sl3 setting will only be changed by smart_sl3 if the node has a connection to OSS.
#================================================================================
smart_sl3=1

#================================================================================
# Dedicated login for CPP Linux nodes (EvoC8300)
#================================================================================
cpplinux_username=root
#cpplinux_password=xxx

#==============================================================================
# Smart Action (0=no, 1=yes).
# To automatically initiate a poll and reload MOs after asynchronous actions on BrM/SwM/CertM/NodeCredential MOs in COM nodes.
# To automatically reload the PmKpi MOs after action "installKpis" in RNC.
#==============================================================================
smart_action=1

#================================================================================
# Anonymize IMSI/IMEI (0=no, 1=yes)
# Only applicable for the following RNC printouts: te log read, ueregprint, uer
# When anon_ue=1, the user specific part of IMSI/IMEI (MSIN/SNR) will be non-reversibly hashed with CRC32 or MD5 algorithm
#================================================================================
anon_ue=0

#==============================================================================
# Prompt setting:
# It is possible to set the prompt directly at moshell startup with the uservariable "prompt", eg moshell -v prompt=xxx <node>
# Useful for automated test suite such as JCAT.
# The prompt can contain a line feed \n, eg: moshell -v prompt='moshell\nNode' <node>
#==============================================================================
#prompt=XXX

#==============================================================================
# Prompt highlighting and coloring (1=bold/color, 0=normal)
# Prompt highlighting and color can be toggled online using the "b" command.
# Note: prompt_color only works when prompt_highlight is turned on
#
# Prompt color codes:
# grey       : 30 or 100
# red        : 31 or 101
# green      : 32 or 102
# yellow     : 33 or 103
# dark blue  : 34 or 104
# purple     : 35 or 105
# light blue : 36 or 106
# white      : 37 or 107
#
# prompt_attribute: the name of the ManagedElement attribute that will be used to produce the prompt.
# eg: userLabel, site, logicalName...
#
# prompt_case: 0 = all uppercase (default)
#              1 = keep original case (can be mix of upper and lower)
#==============================================================================
prompt_highlight=1
prompt_color=1
prompt_rnc=31
prompt_rbs=32
prompt_mgw=35
prompt_attribute=userLabel
prompt_case=0

#==============================================================================
# Banner text
# To have a customized text that will be printed at moshell/AMOS/EMCLI startup
#  - use_banner: 0/1 . 0=don't print a customized banner (default). 1=print a customized banner
#  - banner_color: 0 for no color, 31 for red, 34 for blue, 35 for purple. 
#  - banner_text: the text of the banner. Must be written on a single line, but can use \n to indicate carriage returns.
#==============================================================================
use_banner=0
banner_color=0
#banner_text=\n!!!! This system is private and may only be accessed if authorized. \n!!!! All contents are confidential and proprietary and may not be viewed or used in any way without prior authorization.

#==============================================================================
# Smart Password (0=no, 1=yes).
# If password is not found in ipdatabase or in variable $password, we try some standard passwords. Default=disabled (recommended).
# Note: If sl3=1 then smart_password is ignored
#==============================================================================
smart_password=0
standard_passwords=Password4cpp,x,Ericsson_$nodetype,Ericsson_$nodetype$ip,Ericsson_$nodetype$ip2,$nodetype,$nodetype$ip,$nodetype$ip2,Wcdmarbs600!,Wcdmarnc830!,Ericsson_$nodename,rbs1_$nodename,$nodename

#==============================================================================
# Multiple logins
# Try a list of usernames and passwords for COM nodes or CPPLinux (EvoC8300) nodes respectively
# The passwords can be stored in encoded format from the "encpw" command
#==============================================================================
#com_usernames=username1,username2,username3,etc
#com_passwords=password1,password2,password3,etc
#cpplinux_usernames=username1,username2,username3,etc
#cpplinux_passwords=password1,password2,password3,etc

#==============================================================================
# Login to CSDP server for gpg decryption
# Should be the user's Ericsson Windows login
#==============================================================================
csdp_username=$USER
#csdp_password=xxx

#================================================================================
# Smart corba (0=no, 1=yes):
# automatically change the corba_class setting if mismatch with CorbaSecurity of the node. Default=enabled (recommended).
#================================================================================
smart_corba=1

#================================================================================
# Smart ipv6 (0=no, 1=yes):
# automatically change ipv6 to 1 if attempting to connect to a ipv6 address while ipv6=0. Default=enabled (recommended).
#================================================================================
smart_ipv6=1

#==============================================================================
# Set Window Title at startup (0=no, 1=yes)
#==============================================================================
set_window_title=1

#==============================================================================
# Show colors
# Can be toggled online with the "col" command.
#==============================================================================
show_colors=1

#==============================================================================
# Show userlabel. To show the userlabel in st/pget printouts.
# Can be toggled online with the "ul" command.
#==============================================================================
show_userlabel=0

#==============================================================================
# Show "takes effect". To show the "takes effect" field at the end of successful set command.
# 0=disabled, 1=enabled (default)
#==============================================================================
show_takeseffect=1

#==============================================================================
# Alarm format in al/lga/lgx/lgj
# 0=old format (shows the cause)
# 1=new format (shows the additional text)
# 2=new format (shows the additional text and the cause)
#==============================================================================
alarm_format=1

#==============================================================================
# Show updated alarms in alarm log (lga).
# 0=disabled, 1=enabled (default=0)
#==============================================================================
show_updated_alarms=0

#==============================================================================
# Get format in get <mo> <attr>
# 0=dont show the proxy id
# 1=show the proxy id
#==============================================================================
get_format=0

#==============================================================================
# Moshell alarm
# 0=disabled
# 1=enabled => additional check on CPP feature MOs and TimDevice MOs may print additional alarms in the alarm list.
# These alarms are internally produced by moshell and marked with "Moshell generated alarm"
#==============================================================================
mosalarm=1

#==============================================================================
# Use DBCV
# 0=disabled
# 1=enabled => cvls will show DBC status (OK/NOK/?) and al will raise a "Moshell generated alarm" if some CVs have db inconsistencies
# Refer to "h dbcv" for more info.
#==============================================================================
use_dbcv=0

#==============================================================================
# Sort proxy. To sort the MO proxy list in:
# - 0: proxy order (default)
# - 1: LDN order
# - 2: MO class order
# The "s+/s++/s-" command can be used to switch between the values (s+: 1, s++: 2, s-: 0).
#==============================================================================
sort_proxy=0

#==============================================================================
# Safe syntax. Can also be turned on or off while online with the "safe+/safe-" command.
# Apply strict MO matching rules on MO WRITE commands : bl, deb, del, rdel, fdel, set, eset, rset, fset, acc, facc
# Examples:
# bl utrancell=11 --> will lock cell=11 only (cell=111, or cell=11a , etc. would not be affected)
# bl utrancell=11|utrancell=12|utrancell=13 --> will lock cell=11, cell=12, cell=13
# bl utrancell=11|12|13                     --> same as above
# bl utrancell=11|12|13|iublink=1           --> will lock cell=11/12/13 and iublink=1
#==============================================================================
safe_syntax=0

#===============================================================================
# Telnet/ssh/ftp/sftp username and maximum number of login attempts (0=unlimited)
#===============================================================================
username=moshelluser
max_login_attempts=0

#===============================================================================
# OSE-shell/ftp security (1 to use ssh/sftp, 0 to use telnet/ftp)
# smart_secure=1 means that if secure_shell=0 and there is no contact to telnet port then secure_shell will automatically change to 1
#===============================================================================
secure_shell=0
secure_ftp=1
smart_secure=1

#===============================================================================
# Use https
# smart_http=1 means that if secure_http=0 and there is no contact to http_port and there is contact to s_http_port then secure_http will automatically change to 1
# Note: smart_http is only applicable for CPP nodes
#===============================================================================
secure_http=0
smart_http=1

#===============================================================================
# http version used in http/https get request
# - 0: http/1.0 , but not fully compatible with the standard, may get discarded by certain firewalls
# - 1: http/1.1 , compatible with the standard
#===============================================================================
http_version=1

#===============================================================================
# Keep file properties at file transfer ftget/ftput (file timestamp and permissions)
# - 0: file properties are not preserved
# - 1: file properties are preserved at ftp "get"
# - 2: file properties are preserved at ftp "put"
# - 3: file properties are preserved at ftp "get" and "put"
#===============================================================================
ftp_preserveprops=0

#===============================================================================
# Timeouts for IP connections (http/telnet/ftp/ssh/sftp/corba), in seconds.
#  * ip_connection_timeout : timeout for connection establishment of telnet/ssh/ftp/sftp/http
#  * ip_inactivity_timeout : timeout for data transfer on telnet/ssh
#  * ftp_timeout           : timeout for data transfer on ftp/sftp
#  * http_timeout          : timeout for data transfer on http
# Following timeouts are only applicable for corba_class >= 2. (for corba_class=1, corba timeout is infinite)
#  * corba_timeout         : timeout for corba requests (MO operations: get/set/create/action/delete)
#  * corba_connection_timeout: timeout for connection establishment on corba
#  * fast_timeout          : timeout used for some operations that should be quick, like fetch iorfile, check mom version, check corba security, sls_urls, etc
#  * medium_timeout        : timeout used for checking the MOM version of the CPP node, over http
#===============================================================================
ip_connection_timeout=10
ip_inactivity_timeout=45
ftp_timeout=150
http_timeout=30
corba_timeout=240
corba_connection_timeout=90
fast_timeout=5
medium_timeout=12

#===============================================================================
# Inactivity_timeout (in seconds):
# Moshell exits if no user input arrives within this time.
#===============================================================================
inactivity_timeout=108000

#===============================================================================
# readinput_timeout (in seconds) :
# timeout used for the scripting functions "readinput" and "readinputsilent"
# the function returns the value "TIMEOUT" if no user input is given within this time.
# Default value 0 => same timeout as for moshell prompt (inactivity_timeout)
#===============================================================================
readinput_timeout=0

#==============================================================================
# Keep alive interval (in seconds):
# A message is sent on the corba interface at this interval to keep the corba connection alive
# Default value 0 means no keep alive message is sent
# Some issue were seen in some labs where corba connection hangs after being left idle for 15-30 minutes
# For these cases, use keepalive_interval=1500 (25 minutes)
# Note: if this setting is used then the inactivity_timeout setting is cancelled and there will be no moshell idle session timeout
#==============================================================================
keepalive_interval=0

#==============================================================================
# Http port: 80 for CPP, xx80 for CppEmu where xx is the offset (usually 40)
# Telnet port: 23 for CPP, xx23 for CppEmu where xx is the offset (usually 40)
# Ftp port: 21 for CPP, xx21 for CppEmu where xx is the offset (usually 40)
# Secure port: used for ssh/sftp. a different value can be used in case of RSG port forwardings
# Corba port: 56834. The port for unsecure corba. Only applicable when corba_orbinit=1 and corba_class=2.
# Secure corba port: 56836. The port for secure corba. Only applicable when corba_orbinit=1 and corba_class>=3.
# Port base: adds a fixed value to each port. E.g: portbase=4000 ==> telnet_port=4023, ftp_port=4021, corba_port=4834, s_corba_port=4836, etc.
#==============================================================================
http_port=80
telnet_port=23
ftp_port=21
secure_port=22
corba_port=56834
s_corba_port=56836
#portbase=4000

#==============================================================================
# Node login: 1 (default): enter a password for ssh/telnet/ftp/sftp.
#             0 : no password. Used for for CPP Backup mode, SimCello/CPPemu, AXE, epic root user
#==============================================================================
node_login=1

#==============================================================================
# Ssh Retry: Number of attempts to retry ssh/sftp login on CPP node when all existing connections are occupied by other users
# The duration between attempts is 1 seconds until the first re-attempt, then 2 seconds until second re-attempt, then 3 seconds until third re-attempt, etc
# Default: 1 retry attempt
#==============================================================================
ssh_retry=1

#==============================================================================
# Http Retry: Number of attempts to retry http file transfer
# The duration between attempts is 1 seconds until the first re-attempt, then 2 seconds until second re-attempt, then 3 seconds until third re-attempt, etc
# Default: 1 retry attempt
#==============================================================================
http_retry=1

#==============================================================================
# Editor to use for the "edit" command (to edit a file on the node)
#==============================================================================
editor=$EDITOR

#==============================================================================
# Files not belonging to a UP that shouldnt be cleaned up by the fclean command
# Separate each file by a comma, as shown below (in this example, target monitor)
#==============================================================================
keepLmList="/d/loadmodules/CXC1326054_R1C01,/d/loadmodules/CXC1326054_R1D01,/c/java/host.p12,/c/java/TaskConfigurationFile.txt,/c/java/OLD_SecurityManagement.prp,/d/loadmodules/CXC33077_R5A08,/c/java/SecurityManagement.prp"

#==============================================================================
# Ask for confirmation on MO commands:
#  - bldebset_confirmation ==> confirmation for the commands bl/deb/set/acc  (0 = no confirmation, 1 = confirmation)
#  - lt_confirmation ==> confirmation for the commands lt/lc  (0 = no confirmation, 1 = confirmation)
#  - del_confirmation ==> confirmation for the commands del/rdel (0 = no confirmation, 1 = confirmation)
# Confirmation is never required when running a command file, regardless of these variables
# Confirmation can be toggled online using command conf[bld]
#==============================================================================
bldebset_confirmation=1
lt_confirmation=1
del_confirmation=1

#==============================================================================
# Restart_confirmation ==> confirmation for node restart ("acc 0 manualrestart" or "restartObj me")
#          *  0 = no confirmation needed
#          *  1 = ask for node type on MGW/RNC/RXI
#          * 11 = ask for node type on MGW/RNC/RXI/RBS
#          *  2 = ask for node type and node name on MGW/RNC/RXI
#          * 22 = ask for node type and node name on MGW/RNC/RXI/RBS
#          *  3 = node restart forbidden on MGW/RNC/RXI
#          * 33 = node restart forbidden on MGW/RNC/RXI/RBS
#==============================================================================
restart_confirmation=1

#==============================================================================
# Polu_confirmupgrade ==> the polu command should or should not automatically send the confirmUpgrade action
#          *  0 = polu will not send the confirmUpgrade: this setting ought to be used if the upgrade was initiated from the SMO application in OSSRC
#          *  1 = polu will send the confirmUpgrade action (default value, legacy setting)
# Note: this setting only applies when running moshell interactively from the prompt.
#       when running the polu command from a script or from mobatch, the polu_confirmupgrade setting has no impact and will have value 1 always.
#==============================================================================
polu_confirmupgrade=1

#===============================================================================
# List of xml files to search for in http://<node>/cello/oe/xml
# The files will be searched in the same order as displayed in the list, eg:
# rnc_node_mim.xml, then RbsNode.xml, then CelloMOM.xml
# for using mgw complete mom, add: mmgw_node_mom_complete.xml,mmgwr4_node_mom_hidden.xml
#===============================================================================
xmlmomlist="rnc_node_mim.xml,RbsNodeVersion.txt,RbsNode.xml,mmgw_node_mom_limited.xml,RxiNode.xml,mmgwr4_node_mom_open.xml,mgw_node_mom_ro.xml,CelloMOMRbs.xml,CelloMOM.xml"

#==============================================================================
# Show timestamp (0 = no timestamp, 1 = timestamp)
#==============================================================================
show_timestamp=1

#===============================================================================
# Transaction timeout: timeout in seconds for MO operations that require a transaction (set/create/delete/action).
# Only applicable for corba_class >= 2 (for corba_class=1, it is hardcoded to 3600)
#===============================================================================
transaction_timeout=180

#==============================================================================
# Fast_lh, fast_cab, fast_coli, fast_sql:
# The lh, cab, and coli commands are made faster by running a command file directly on the node with "shell -f".
# The fro command is made faster by running a command file directly on the node with "sql include".
# The command file is then removed from the node after completion.
# The lh/cab/fro/coli commands will only use ftp if :
#     - more than <fast_xxx_threshold> commands have to be sent (in case of lh/coli command)
# (This depends on the number of boards in the board group and the number of commands to be sent to each board.)
#     - more than <fast_cab_threshold> boards exist in the node (in case of "cab" command)
# Example: suppose there are 2 boards in the board group called "tub", and fast_lh_threshold=5
#          if you do "lh tub vii" then it wont use fast_lh since only 2 commands have to be sent.
#          but if you do "lh tub vii ; llog ; vols" then it will use fast_lh since 2x3=6 commands have to be sent.
# In the case of coli commands, the printout sometimes is corrupted by spurious echo characters.
# The workaround in this case is to set fast_coli_threshold to 0 prior to running the command.
# Caution: if fast_coli_threshold is too low then some commands will not work, e.g. cmxbsh, npsh, ncli, ...
#==============================================================================
fast_lh_threshold=5
fast_cab_threshold=5
fast_coli_threshold=30
fast_sql_threshold=5

#==============================================================================
# use_dbdump
# Only applicable for CPP OSE Nodes C18.Q2 or higher
# Specify whether the dbc/dbd/dbcv command will :
#  0: analyse db.dat files (legacy behaviour) or 
#  1: analyse dbdump.zip files (taken with MO action ConfigurationVersion.generateDbDump or command "cvgetd")
# The latter does not require Polyview
#==============================================================================
use_dbdump=0

#==============================================================================
# mibmgr_threshold
# The number of MO instances above which the dcg command will use MibManager for collecting the MO dump
# Only applicable for CPP nodes >= C15.1
# Example mibmgr_threshold=150000 means that the MibManager will be used for collecting MO dump containing 150,000 MO instances or more
# Mostly useful on O&M connection with low bandwidth or high latency, or for nodes with very many MO instances.
# mibmgr_threshold=0 means the MibManager will not be used.
#==============================================================================
mibmgr_threshold=150000

#==============================================================================
# use_lhz : whether to transfer COLI printouts in compressed format or not
# - 0: disabled completely, including the lhz command will behave as lh
# - 1: enabled only for the lhz command
# - 2: also enabled for ced, cedh, lgt, lh <group> te log read
# - 3: also enabled for uer, stda, sti (NOT recommended yet, slower in most cases)
#==============================================================================
use_lhz=2

#==============================================================================
# use_lhv : whether the lhsh command will be sent with the -v option
# - 0: disabled => lhsh command is sent transparently as the user typed it
# - 1: enabled  => lhsh command is sent with -v option in order to find the end of the printout from the return code instead of using echo command. Useful for XMU03 and avoiding spurious echo printout
# Default: 1 (recommended)
#==============================================================================
use_lhv=1

#==============================================================================
# use_bocache : to read board group configuration from cache
# - 0: disabled. Board group configuration is always read from the node
# - 1: enabled. Baord group is read from cache. Do not use in live network, only for lab and internal usage.
# bocachedir: the path to the directory containing the bocache files. This is optional. Default location is $logdir/cache
# bocachename: the basename of the cache files. This is optional. Default basename will be the node ipaddress
# The names of the cache files will be <bocachename>.<extension> , where <bocachename> is by default the ipaddress and the extensions are: .bo/.rnc/.cpp/.drh
# These files are generated automatically when running the "bor" command and stored in bocachedir
#==============================================================================
use_bocache=0
#bocachedir=/path/to/bocachedirectory
#bocachename=hello

#==============================================================================
# print_lmids: 0=no loadmodule name translation in COLI commands
#              1(or more)=append loadmodule name translation in COLI commands and pipe "te log read" to concat_segmented_rlib_traces.pl (RNC)
#==============================================================================
print_lmid=1

#==============================================================================
# Settings for the RNC/RBS/MGW/CPP/LTE complete MOM
# The complete MOM is for internal use only, do NOT distribute to customer.
# If use_complete_mom=1 then moshell will try to find the corresponding complete mom in moshell/jarxml
# If not found there, it will try and fetch it :
#   1) from clearcase (if there is clearcase access and correct labels in config spec: /main/wendy/LATEST , /main/wanja/LATEST, D2-STRUCT_MAIN_RNC_INC2.1_KI)
#   2) from utran01 server (if there is contact to utran01)
# If use_complete_mom=2 then moshell will only try to look in the moshell/jarxml folder and not try to fetch the file from utran01
#==============================================================================
use_complete_mom=0

#==============================================================================
# When use_extended_mom=1, some additional attributes are displayed in the get/kget/hget commands.
# The list of extended attributes can be found in the file moshell/commonjars/extendedMOM.txt
# It is also possible to print these attributes with the command "eget", regardless of the use_extended_mom setting
#==============================================================================
use_extended_mom=0

#==============================================================================
# Append the enum translation in attributes of type sequence of enums in get commands (get/hget/kget/etc)
# Append the binary to decimal or decimbal to binary conversion for struct members sfAllocationFourFrame/sfAllocationOneFrame or subframeAllocationFourFrame/subframeAllocationOneFrame
# Default value is 1 (ON) but for backwards compatibility to older moshell printout format (e.g. scripts), it is possible to use 0 (OFF)
#==============================================================================
translate_sequence_enum=1

#==============================================================================
# Use_crn: 0: disabled, 1: enabled (default)
# When set to 1, the commandfile generated by diff/undo/gmc will use the command "crn" instead of "cr"
# The uv no_crn is to list MO classes for which use_crn will always be 0
#==============================================================================
use_crn=1
no_crn=RbsLocalCell,Carrier

#==============================================================================
# Use_nodelete: 0: disabled (default), 1: enabled 
# When set to 1, the del/rdel command will not delete any MO instances of the types listed in "nodelete_list"
#==============================================================================
use_nodelete=1
nodelete_list=Program,ReliableProgramUniter,RncModule,Aal2Sp,SwAllocation,TimDevice

#==============================================================================
# Use_nolock: 0: disabled (default), 1: enabled 
# When set to 1, the bl/set command will not lock any MO instances of the types listed in "nolock_list"
# Note: if a MO class has the prefix "Com" then it will be applicable to COM nodes only.
#       if a MO class has the prefix "Cpp" then it will be applicable to CPP nodes only.
#       without prefix, the MO class will be applicable to both platforms
#==============================================================================
use_nolock=1
nolock_list=Com.EthernetPort

#==============================================================================
# In this variable you can define a different path for the pm ROP files:
# statistics (.xml.gz), ctr/uetr (.bin), gpeh (.lnk)
# If the variable is not defined, the files are stored under the standard
# logfiles directory: ~/moshell_logfiles/logs_moshell
#==============================================================================
#pm_logdir=/path/to/pm_logdir

#==============================================================================
# Path to UTRAN decoder (decoder.pl) and LTE decoder (ltedecoder), used by the "pme" command (option "d")
#==============================================================================
decoder=/app/decoder/0/bin/decoder.pl
ltedecoder=/app/moshell/bin/ltng-decoder

#==============================================================================
# Path to expect, needed for the goxb command
#==============================================================================
expect=/usr/bin/expect

#==============================================================================
# Path to python, needed for the rinpm command
#==============================================================================
python=/usr/bin/python

#==============================================================================
# The default mute factor, controls the amount of progress dots in l+m/l+mm
#==============================================================================
muteFactor=100

#==============================================================================
# The default wait time (in seconds) when checking PM counters increments (stc and pdiff commands)
#==============================================================================
pm_wait=30

#==============================================================================
# The default ROP period (in minutes) for the wait command (eg: wait 1r)
#==============================================================================
rop_period=15

#==============================================================================
# Include non-pm attributes in statistics scanners
# Only works for MO classes using the pull method (ie. where counters are not reset at the end of the ROP)
# and attribute has to be of type long, long[], boolean, string, moRef
# Default is 0 (disabled). Set to 1 in order to activate this functionality.
#==============================================================================
include_nonpm=0

#==============================================================================
# Moshell Command logging (0=disabled, 1=enabled)
# By default, all moshell commands run on a particular node are logged under:
#    /home/<userid>/moshell_logfiles/logs_moshell/moscomlogs/ipaddress.log
# To keep the command logs in a different folder, set the uservariable moscommanddir in the moshellrc or .moshellrc file
# Eg: moscommanddir=/opt/ericsson  --> the logs will end up under /opt/ericsson/moscomlogs/<userid>/<ipaddress>.log
#==============================================================================
moscommandlog=1
#moscommanddir=/path/to/moscomlogs

#==============================================================================
# Moshell Command log rotation
# When the moshell command log is above a certain size (default: 10 MB) then it is moved to a file called <ipaddress>.old.gz
# The contents of the file <ipaddress>.old.gz however stays available for the lgn command to display.
# To disable moshell command log rotation, set the uv moscommandsize to 0
#==============================================================================
moscommandsize=10

#==============================================================================
# Keep command history between different sessions to the same node
# Specifies the number of lines of command history that get carried across from the moshell command log of previous sessions to a specific node
# This feature requires moscommandlog=1. To disable the feature, set keep_history_lines to 0
#==============================================================================
keep_history_lines=100

#==============================================================================
# Consistency check on the Set command
#          *  0 = no parameter consistency check is done before performing a set operation
#          *  1 = Prints an extra warning on the set command when trying to set an attribute to a value different to the recommended value
#          *  2 = Same as 1, and an exception is given when trying to set an Ericsson Internal parameter to a value different than the recommended value. The list of Ericsson Internal parameters can be printed from the complete MOM with command "momd . . . ericsson"
# The recommended values are stored in the files moshell/commonjars/pm/PARAM* and depend on the node type and SW release
# Additional recommended values can be stored in the file specified in the uservariable custom_param_file
#==============================================================================
set_check=1

#==============================================================================
# Path to reference file containing parameter reference values
# These reference values complement or override the Ericsson recommended parameter values listed in the files moshell/commonjars/pm/PARAM*
# The custom_param_file should only contain reference values that are different to the Ericsson recommended values
# The format of the custom_param_file must be the same as the format used by the PARAM files
# The values in this file are used when :
#    - running a parameter audit with the diff command, e.g. "diff <mo-filter>" or "diff <modump>"
#    - running the set command if set_check=1
# By default, this uservariable is not set.
# Note: it is possible to specify several files, in which case they are read in sequential order and the settings in the latter files
#       will override the ones in the former. Eg: custom_param_file=/path/to/file_one,/path/to/file_two,/path/to/file_three
#==============================================================================
#custom_param_file=/path/to/custom_param_file

#==============================================================================
# Path to alternative upids.txt files to complement or override the UP translations of moshell/commonjars/upids.txt
# (used in SW release translation of cvcu/cvls and upid commands).
# The default upids.txt file is stored in moshell/commonjars/upids.txt and contains the release names for all the RNC/RBS/ERBS/RXI UpgradePackages
# If this file is not up to date, it is possible to override or complement it by manually storing additional entries in a file whose path shall be specified in the uservariable custom_upid_file
# The format for each entry in this file shall be the same format as in moshell/commonjars/upids.txt, ie:
# ReleaseName; CPPversion; UP ProductNumber; Up Revision; Node Type
# for instance: L12A.1.6.0; EP22-1-C12.0; CXP102051/14; R21DD; ERBS
# Note: it is possible to specify several files, in which case they are read in sequential order and the entries in the latter files
#       will override the ones in the former. Eg: custom_upid_file=/path/to/file_one,/path/to/file_two,/path/to/file_three
#==============================================================================
#custom_upid_file=/path/to/custom_upids.txt

#==============================================================================
# MO classes and attributes to exclude from the comparison in "diffm"/"diffd" commands
#==============================================================================
diffm_exclude_moclasses=LoadModule,Program,ReliableProgramUniter,UpgradePackage
diffm_exclude_attributes=administrativeState,user,password,userLabel,remoteSctpPortNbapC,remoteSctpPortNbapD,selectionPriority,egressAtmMcr,ingressAtmMcr,egressAtmPcr,ingressAtmPcr,ipAddress,ipAddress1,ipAddress2,ownIpAddressActive,ownIpAddressPassive,piuGroupNumber,upgradeGroupId,radioBuildingBlock,alarmStatus
diffm_exclude_structs=PlmnIdentity,BoardTypePositions

#==============================================================================
# MO classes and attributes to exclude from the comparison in "diffo" command
#==============================================================================
#diffo_exclude_moclasses=Program,LoadModule
diffo_exclude_attributes=userLabel

#==============================================================================
# MO attributes to exclude from the comparison in "dbd" command
#==============================================================================
#dbd_exclude_moclass=Program,LoadModule,MsProgram
#dbd_exclude_attributes=maoTableIndex,froTableIndex,theclientsuniqueid

#==============================================================================
# In case only certain MO classes shall be checked by the "dbd" command
#==============================================================================
#dbd_only_moclasses=Program,ReliableProgramUniter,LoadModule

#==============================================================================
# Cluster Members: the list of nodes that are part of the same cluster
# Usually this uservariable is node specific and therefore shall be specified in the ipdatabase file or from within the moshell session with uv command
# The list of cluster members is currently used in the moshell command "ir" (rnc in pool iub redundancy)
# The nodes can be specified in any of the following way:
#   - nodename
#   - dnsname
#   - ipaddress
#   - ipaddress:portbase  (in case of EriEmu)
#   - /path/to/modump.zip (in case of offline mode)
#==============================================================================
#cluster_members=<node1>,<node2>,....

#==============================================================================
# ir_nosync: the list of attributes that shall not be synchronised from primary to secondary Iublink (RNC in pool with Iub redundancy)
#==============================================================================
ir_nosync=administrativeState,rncModulePreferredRef,userPlaneIpResourceRef

#===============================================================================
# Enable/disable the use of built-in ip connection utility (0=disabled, 1=enabled)
# Enabled: an internal ping utility is used to check ip contact with the node
# Disabled: an external ping utility is used which makes moshell response time a bit slower
#===============================================================================
use_netcatlib=1

#===============================================================================
# Enable/disable the use of built-in scandir utility (0=disabled, 1=enabled)
# Enabled: an internal utility to list directory contents is used
# Disabled: directories are read via "ls -1", slightly slower
# Default=enabled, except for solaris/sparc
#===============================================================================
use_scandir=1

#===============================================================================
# Enable/disable the use of 64bit binaries for ssh/sftp on linux x86_64
# Default=enabled
#===============================================================================
use_lin64=1

#===============================================================================
# Support for IPv6 (0=disabled, 1=enabled)
# When IPv6 support is enabled it is possible to connect to a CPP node using an IPv6 O&M address
# Limitations: ftp is not yet supported, use_netcatlib disabled (==> commands will have slower response time)
#===============================================================================
ipv6=0

#===============================================================================
# Choice of TCP monitor client for IPv4 CPP nodes ("mon" command)
# use_monitor6054=1 -> use monitor6054
# use_monitor6054=1 -> use nc6
#===============================================================================
use_monitor6054=0

#===============================================================================
# Support for COM nodes
#
# smart_comcli=1   means that the comcli value will be set automatically and does not need to be specified manually
# comcli=0 (default, CPP node)
# comcli=1 (COM node, accessing the Linux shell)
# comcli=2 (COM node, accessing the COM CLI shell)
# linux_shell=1 means that the linux shell is available on this node
#    -> The COMCLI will be accessed by executing the cliss application in the linux shell. The cliss path can be specified in the uservariable cliss.
#    -> If the CLISS command contains a space then use comma instead of the space (eg: instead of "/home/comuser/bin/cliss 2843", write "/home/comuser/bin/cliss,2843")
# linux_shell=2 is the same as linux_shell=1 except that the bash shell of the node is started in a different way, needed in some cases for picoRBS.
# linux_shell=0 means that the linux shell is not available on this node, eg. RBS G2.
#    -> The COMCLI will be accessed via a separate port specified in comcli_port
#    -> The COLI shell will be accessed via the port specified in secure_port
#    -> The SFTP server of the node will be accessed via the port specified in ftp_port. On RBS G2 this is port 2024
# comcli_columns is the maximum number of characters that can be displayed per line
# comcli_timeout is the idle timeout in seconds for the ssh session used for the MO interface to COM. It is also the timeout after which a hanging MO printout will be released. Default value is 2 minutes.
# netconf_timeout is the idle timeout in seconds for the ssh session used when running a netconf script with the moshell command "netconf".
# comcli_cfg is the default path for the com.cfg file
# comcli_model is the default path for the the model_file_list.cfg
# comcli_retry_maxtime is the maximum time that moshell during which moshell will retry connecting to COMCLI. Set to 0 to disable auto-retry.
# comcli_retry_interval is the interval between each retry
# comcli_port is the TCP port to be used for accessing the COMCLI over SSH when linux_shell=0
# s_comcli_port is the TCP port for accessing COMCLI over SSL/TLS
# s_secure_port is the TCP port for accessing RCS-COLI over SSL/TLS
# s_http_port is the TCP port for HTTP over SSL/TLS (HTTPS)
# comcli_mom is the method for mom fetching:
#    -> -1: via coli shell command "cat" if linux_shell=0
#           via linux shell command "cat" if linux_shell>0
#    ->  0: via coli shell command "cat" if linux_shell=0
#           via sftp if linux_shell>0
#    ->  1: with Schema MO and sftp. The uv comcli_mompath specifies where on the node the MOM fragments can be fetched. On real pico it is /oss/models, on netsim pico it is /SysMMimSchemas
#    ->  2: with Schema MO and http or https
#    ->  3: with Schema MO export action. The uv export_method specifies whether to use a local SFTP server or a remote SFTP server, see further down, export related uv's.
# comcli_mompath is the path on the node where the MOM fragments can be fetched via sftp and is only applicable for comcli_mom=1
# comcli_portfile indicates whether the TCP ports should be read from the file cat /local/scratch/$USER/RCS_ROOT/$HOME/releases/R*/port.conf (0=no, 1=yes) -> Use 1 for RCSsim only.
# login_wait: time to wait in ms before sending ssh commands after login. May be needed for pico to avoid hanging. Only applies when linux_shell=2 or node_login=0
#
# Saved Login for COM nodes:
# The login for COM nodes can be saved in the uservariables com_username and com_password.
# If the uservariable com_password is empty then the login will be read from the uservariable username and the variable $password
#
# Connection methods:
#   - use_netconf=0  -> the MO interface is accessed via COMCLI (over SSH or TLS)
#   - use_netconf=1  -> the MO interface is accessed via NETCONF over SSH instead of COMCLI
#   - use_tls=0      -> the COMCLI and RCS-COLI are accessed via SSH with username/password login.
#   - use_tls=1      -> the COMCLI and RCS-COLI are accessed via TLS, using a sam.p12 credential file. The uservariables sa_credential and sa_password must be set.
#   - use_tls=2      -> the COMCLI and RCS-COLI are accessed via TLS, using a client.pem and ca.pem file. The uservariables clientpem and capem must be set.
#   - use_tls=21     -> same as us_tls=2 but with an additional key.pem file and its passphrase. The uservariables keypem and keypass must be set, in addition to the variables clientpem and capem.
#   - use_tls=3      -> the COMCLI and RCS-COLI are accessed via TLS, using a ssucredentials.xml file. The uservariable nm_credential must be set.
#   - tls_menu=1     -> a menu allows the user to select connection method TLS with ssucredential.xml/sam.p12 or SSH with user/password. The credential files will be searched in the folders nm_folder and sa_folder (default: ~/Ericsson/OMSec)
#
# Faster MO write operations (TR HU50440)
#   - comcli_netconf_set (0/1) -> the set/bl/deb commands are performed via NETCONF instead of COMCLI . Currently default ON in DUS Gen2 and OFF in other node types.
#   - comcli_netconf_del (0/1) -> the del/rdel commands are performed via NETCONF instead of COMCLI . Currently default ON in DUS Gen2 and OFF in other node types.
#   - comcli_netconf_cre (0/1) -> the cr/crn commands are performed via NETCONF instead of COMCLI . Currently default ON in DUS Gen2 and OFF in other node types.
#   - comcli_netconf_pcr (0/1) -> the pcr commands are performed via NETCONF instead of COMCLI . Currently default ON in DUS Gen2 and OFF in other node types.
#   - comcli_netconf_acc (0/1) -> the acc commands are performed via NETCONF instead of COMCLI . Currently default ON in DUS Gen2 and OFF in other node types.
#
# Node Credential validation:
#   - nc_validate    -> whether to do Node Credential validation for the TLS ports (0=no , 1=yes)
#   - ca_folder      -> the folder containing root CA files fetched from TDPS server, used for NC validation of the TLS ports
#
# Shell handling
#   - smart_shell=1  -> auto-detect to which shell to send a command: COMCLI, COLI, Linux. Type "h c+" for info
#
# ESCI (Ericsson Support Command Interface)
#   - esci=1         -> a prompt and disclaimer will be printed before executing a command that requires COLI access
#
# Number of BB crash dumps to keep in the ESI 
#   - esi_nr_bbdumpkeep=2  -> by default only the last 2 BB crash dumps of each BB EMCA processor will be included in the ESI (when taken with lgf/dcgm), the other ones will be removed
#-------------------------------------------------------------------------------
#           COMCLI special values.
#
# The following values of the comcli uservariable can be used
# for the following node types and automatically will set a number of other settings in order to work on those node types:
# VALUE        NODE TYPE                     CORRESPONDS TO:
# comcli=10    pico commercial               comcli=2,linux_shell=0,comcli_mom=1,comcli_port=9830,secure_port=9830,ftp_port=22
# comcli=11    pico RnD                      comcli=1,cliss=/opt/com/bin/cliss,9892,comcli_cfg=/opt/com/etc/local/maf.cfg
# comcli=12    NetSim and APG43L 1.x         comcli=2,linux_shell=0,comcli_mom=1,comcli_port=22,secure_port=22,ftp_port=22,comcli_mompath="/SysMMimSchemas"
# comcli=13    pico commercial via netconf   comcli=2,linux_shell=0,comcli_mom=1,comcli_port=9830,secure_port=9830,ftp_port=22,use_netconf=1,netconf_port=830
# comcli=20    g2 via comcli/SSH             comcli=2,coli_shell=1,comcli_mom=2,http_port=8080,secure_port=4192,linux_shell=0,ftp_port=2024,secure_http=1,comcli_port=2023,s_http_port=443
# comcli=21    g2 RnD via comcli/SSH         comcli=2,coli_shell=2,comcli_mom=2,http_port=8080,secure_port=4192,linux_shell=0,ftp_port=2024,secure_http=1,comcli_port=2023,s_http_port=443
# comcli=22    g2 RCSsim via comcli/SSH      comcli=2,comcli_mom=2,comcli_portfile=1
# comcli=23    g2 commercial via netconf/SSH comcli=2,comcli_mom=2,http_port=8080,secure_port=4192,linux_shell=0,ftp_port=2024,use_netconf=1,netconf_port=830
# comcli=24    g2 RnD via netconf/SSH        comcli=2,comcli_mom=2,http_port=8080,secure_port=4192,linux_shell=0,ftp_port=2024,use_netconf=1,netconf_port=830
# comcli=25    g2 via comcli/TLS + sam.p12   comcli=20,use_tls=1
# comcli=26    g2 via comcli/TLS + pemfiles  comcli=20,use_tls=2
# comcli=27    g2 via comcli/TLS + ssucredentials           comcli=20,use_tls=3
# comcli=28    g2 via comcli/TLS+SSH with connection menu   comcli=20,tls_menu=1,use_tls=-1
# comcli=30    NetSim                        comcli=2,comcli_mom=3,linux_shell=0,comcli_port=22,secure_port=22,ftp_port=22,export_method=1
# comcli=31    BSP                           comcli=2,comcli_mom=3,linux_shell=0,comcli_port=2024,secure_port=2024,ftp_port=22,export_method=1
# comcli=32    PGM                           comcli=2,secure_port=830
# comcli=33    Netsim via netconf            comcli=2,comcli_mom=3,linux_shell=0,comcli_port=22,secure_port=22,ftp_port=22,export_method=1,use_netconf=1,netconf_port=830
# comcli=34    APG43L 2.x                    comcli=2,comcli_mom=3,linux_shell=0,comcli_port=22,secure_port=22,ftp_port=22,export_method=1
# comcli=35    EPG/SSR                       comcli=34,epg_ssr=1
# comcli=36    EMe,vSAPC                     comcli=30,ftp_port=22,comcli_port=830,ssh_subsystem=cli,export_method=3
# comcli=37    MRSv,vSAPC,DSC                comcli=36,ftp_port=115
# comcli=38    CBA Ref                       comcli=36,ftp_port=830
# comcli=39    SBGv                          comcli=36,ftp_port=2028,comcli_port=2022
# comcli=40    vEME                          comcli=36,comcli_port=2022
# comcli=5*    5G VNFM                       comcli=2*,s_http_port=3443
#===============================================================================
comcli=0
linux_shell=2
cliss="/opt/com/bin/cliss"
comcli_columns=3000
comcli_timeout=120
comcli_cfg=/opt/com/etc/com.cfg
comcli_model=/opt/com/etc/model/model_file_list.cfg
comcli_retry_maxtime=1200
comcli_retry_interval=5
comcli_port=22
comcli_mom=-1
comcli_mompath=/oss/models
comcli_momversion_cache=1
comcli_portfile=0
comcli_portfilepath=/local/scratch/$USER/RCS_ROOT/home/$USER/releases/*/port.conf
login_wait=500
use_netconf=0
netconf_port=830
smart_comcli=1
s_comcli_port=9830
s_secure_port=9831
s_http_port=443
s_netconf_port=6513
s_ftp_port=9921
use_tls=0
use_ftps=0
clientpem=$HOME/Ericsson/OMSec/client.pem
capem=$HOME/Ericsson/OMSec/ca.pem
keypem=$HOME/Ericsson/OMSec/key.pem
#keypass=secret
tls_menu=0
ca_folder=$HOME/Ericsson/OMSec/CAcert
nc_validate=0
smart_shell=1
esci=0
epg_ssr=0
com_username=$USER
#com_password=xxx
#ssh_subsystem=cli
#ssh_kexalg/sftp_kexalg: to specify the value for the openSSH option KexAlgorithms used in ssh/sftp respectively. 
#Can be used on RCS nodes where the ssh connection is slow or to connect to SFTP export servers using coreFTP instead of openSSH
#ssh_kexalg=ecdh-sha2-nistp256
#sftp_kexalg=diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha256
comcli_netconf_set=0
comcli_netconf_del=0
comcli_netconf_cre=0
comcli_netconf_pcr=0
comcli_netconf_acc=0
netconf_timeout=300
is_netsim=0
esi_nr_bbdumpkeep=2


#===============================================================================
# Export settings. Used on COM nodes for exporting the MOM from Schema MO (comcli_mom=3) and the Logs from Log/LogM MO ("lg" command)
#
#   - export_timeout=60
# The number of seconds until a Log export action will timeout. For the action LogM.exportEsi(), the actual timeout is 20 times the value of export_timeout
#
#   - export_method=0
# Export to custom SFTP server on a random port specified in the uservariables sshd_port and sshd_range.
# The SFTP server will run on the same machine where moshell is executing and only for the duration of the export.
# No username or password need to be specified. The SFTP port is selected randomly in the range specified by the uservariables sshd_port/sshd_range
# This method only works if the firewall does not block the SFTP ports in that range from the node to the workstation.
# The following uservariables are used by export_method=0: sshd_port, sshd_range, sshd_random
#
#  - export_method=1
# Export to the existing SFTP server running on port "export_port" on the moshell workstation 
# With this method, the uservariables export_username and export_password must be set.
# If export_password is not set then it will be prompted at the first export.
# The following uservariables are used by export_method=1: export_username, export_password
#
#  - export_method=2
# Export to a remote SFTP server on port "export_port", the address of the server is specified in the uservariable "export_server"
# Important: the remote SFTP server must be reachable both from the node as well as from the workstation where moshell is running
#            since the logfile will be first transferred from the node to the server, then from the server to the moshell workstation.
# The temporary path where to store the logs on the remote server can be specified with the uv export_dir
# The export_dir setting is optional, but if it has been specified then it must actually exist on the server, moshell will not create it automatically.
# If export_dir has not been specified then the logs will be temporarily stored on the default root path of the SFTP server such as the user's home directory for instance
# After the logs have been successfully transferred back to the moshell workstation, they will be removed from the remote SFTP server.
# With this method, the uservariables export_username and export_password must be set.
# If export_password is not set then it will be prompted at the first export.
# The following uservariables are used by export_method=2: export_username, export_password, export_server
# If export_server points to the same server as where moshell is running then export_method will be automatically changed from value 2 to value 1, unless smart_export=0
# If SFTP to the remote server fails (can happen on some SFTP servers running coreFTP software), it is possible to set the uservariable sftp_kexalg, see example further up in this file.
#
#  - export_method=3
# Export to the node's own SFTP server on port 22, then fetch the files from the node's SFTP server
# This is basically an alias to export_method=2,export_server=<nodeip>,export_username=<nodeusername>,export_password=<nodepassword>
#===============================================================================
export_method=0
sshd_port=10001
sshd_range=999
sshd_random=2
export_timeout=60
export_username=$USER
#export_password=xxx
#export_server=x.y.z.a
export_dir=/tmp
smart_export=1
export_port=22

#===============================================================================
# LTTNG settings. Used by the "mon" command on MSRBSV2, TCU03, and Evo8300
#  - lttng_port/lttng_range : the range of TCP ports that will be tried for the communication between lttng-relayd and the node.
#  - lttng_flush : the value that will be specified in the "-f" parameter for the "ts ip" command. To not use the "-f" flag, set this uservariable to empty
#  - lttng_buff  : the value of lttng subbuffer in MB (default: 4x1 MB in RCS / 4x4 MB in CPP). This will be specified in "ts ip" options "-n" and "-s". To not use these flags, set this uservariable to empty.
#  - lttng_tracefilesize   : the value that will be specified in the "-z" parameter for the "ts ip" command. To not use the "-z" flag, set this uservariable to empty
#  - lttng_tracefilecount  : the value that will be specified in the "-l" parameter for the "ts ip" command. To not use the "-l" flag, set this uservariable to empty.
#  - use_babel2  : 0=use the standard babeltrace/babelwrap (default). 1=use babeltrace2/babelwrap2 , a wrapper that redirects messages from stderr to stdout
#  - lttng_relayd_options: to specify some debug options that will be used when "mon" starts the lttng-relayd
#===============================================================================
lttng_port=5342
lttng_range=999
#lttng_dir=/tmp
lttng_flush_rcs=2000000
lttng_flush_cpp=4000000
lttng_buff_rcs=4x1
lttng_buff_cpp=4x4
lttng_tracefilesize_cpp=4194304
lttng_tracefilesize_rcs=1048576
lttng_tracefilecount_cpp=2
lttng_tracefilecount_rcs=2
use_babel2=0
#lttng_relayd_options=-vvv,>,$logdir/$ipaddress_lttngdebug.log,2>&1

#===============================================================================
# LTTNG keepalive settings. Used by the "mon" command on MSRBSV2, TCU03, and Evo8300
# - lttng_keepalive: 0=disabled. 1=enabled (default) => enable dead-peer detection to avoid hanging open file descriptors due to loss of connection between lttng-relayd and the node
# - lttng_keepalive_time: the interval between the last data packet sent and the first keepalive probe; after the connection is marked to need keepalive, this counter is not used any further 
# - lttng_keepalive_probes: the number of unacknowledged probes to send before considering the connection dead and notifying the application layer 
# - lttng_keepalive_intvl: the interval between subsequential keepalive probes, regardless of what the connection has exchanged in the meantime 
#  LTTNG_NETWORK_SOCKET_TIMEOUT 
# - lttng_nwsocket_timeout: socket connection receive and send timeout in milliseconds. Default: 0 (uses operating system default)
#===============================================================================
lttng_keepalive=1
lttng_keepalive_time=5
lttng_keepalive_probes=10
lttng_keepalive_intvl=1
lttng_nwsocket_timeout=0

#===============================================================================
# MONU settings. Used by the "monu" command 
#  - udp_router  : applicable for CPP nodes.  To specify the ip address of the server where UDP trace router is running. If empty, the address of moshell workstation will be used.
#  - bbte_router : applicable for Gen2 nodes. to specify the ip address of the server where UDP trace router is running. If empty, the address of moshell workstation will be used.
#  - bbte_buffer_rate : if this value is more than 0, then the following parameters will be given to bbte setdest: --buffer emca -bitrate <buffer_rate>
#===============================================================================
#udp_router=
#bbte_router=
bbte_buffer_rate=200000
bbte_port=33079

#==============================================================================
# Handling of COLI in RCS nodes (RBS Gen2 / TCU03)
# coli_shell=0  => COLI commands cannot be run transparently, only by going specifically into RCS-COLI mode, by typing the command "coli"
# coli_shell=1  => RCS-COLI commands can be run transparently and seamlessly
# coli_shell=2  => RCS-COLI is not used, instead the COLI commands will run on linux shell via ssh to port 22 and the login will be done with linux_username and linux_password
#==============================================================================
coli_shell=1
linux_username=root
linux_password=root

#==============================================================================
# Fast read of Ericsson-Only attributes in MSRBSv2
# Requires the feature license "Hidden Parameter Access" (CXC4012188/FAJ1214785) to be installed and activated on the node.
# use_testmomdump=0 => the command "internalmomread" will be used 
# use_testmomdump=1 => the command "testmomdump" will be used (faster)
#==============================================================================
use_testmomdump=1

#==============================================================================
# Fast read of SFP values. Only applicable for MSRBS v2. 
# WARNING: NOT FULLY TESTED YET 
# Uses coli command "sfpvalues" on DUS G2 instead of coli command "sfp" on all RU/XMU
# use_sfpvalues=0 => the command "sfp" on each RU/XMU will be used
# use_sfpvalues=1 => the command "sfpvalues" on DUS will be used (faster but not fully tested yet)
#==============================================================================
use_sfpvalues=0

#===============================================================================
# Support for Linux-based nodes (SIU, TCU, COM, CPP-linux)
# lincli=0 (default, OSE based CPP node)
# lincli=1 (linux based nodes)
# lincli=2 (OSE based SIU nodes)
# lincli=3 (AXE nodes)
#===============================================================================
lincli=0

#===============================================================================
# Fast inv. Only applicable for DUS Gen2
# The number of XP boards above which part of the inv command will be run in a parallel process. Default: 6
#===============================================================================
fast_inv_threshold=6

#===============================================================================
# Enable/disable moshell debug printouts (1=enabled, 0=disabled)
# Can also take the value 99, only to be used when run from an expect script. See TR WRNae06245
# Can also take the value 999, which gives the same behaviour as 99 plus that the answer to prompts from cr/acc/etc are echoed
#===============================================================================
mosdebug=0

#===============================================================================
# Enable/disable jacorb debug printouts (1=enabled, 0=disabled)
# Can also take the value 2 for SSL printouts, only to be used in case corba security issues
#===============================================================================
corba_debug=0

#===============================================================================
# Enable/disable openssl debug printouts 
# tls_debug=0 -> no debug flags
# tls_debug=1 -> -msg -state -showcerts
# tls_debug=2 -> -msg -state -showcerts -debug
#===============================================================================
tls_debug=0

#===============================================================================
# Version of the polyhedra sql database reader, used in sql mode and dbc command
#  - 0: version 6.0, supported on solaris and linux, allows read and write to the db.dat, might not work on the newest CPP releases (CPP9 and above)
#  - 1: latest version (9.0), supported on solaris, linux, and cygwin, read-only (cannot write to db.dat). Supports all CPP releases.
#  - 83, 84, 86, 87, 88, 89, 90 : to explicitely specify a version (8.3, 8.4, 8.6, 8.7, 8.8, 8.9, 9.0)
#===============================================================================
polyversion=1

#==============================================================================
# Sql port: the starting point for the range of ports used in sql mode and dbc command
# The SQL client uses this port to communicate with the SQL server on the workstation.
# This communication is only internal on the workstation, not with the node.
# The default range of ports consists of 1000 ports, where the starting point is the port given in "sql_port", e.g. 8001-9000
# The scanning of ports can be :
#   * non-random (sql_random=0)
#   * random (sql_random=1 -> shuffle up to 10 times)
#   * extra random (sql_random=2 -> shuffle up to 100 times)
#   * extra-extra random (sql_random=3 -> shuffle up to 1000 times)
# The sql_random is needed when running dbc from mobatch in order to ensure that there will not be any collision of sql ports between sessions running at the same time
#==============================================================================
sql_port=8001
sql_range=999
sql_random=0

#===============================================================================
# Allow/Forbid corba connection (0=allow, 1=forbid)
# Value 1 means that moshell will not attempt to connect to the node via corba, only telnet/ftp/ssh/sftp
# Can also be activated by starting moshell/mobatch with option "-l" (light mode)
#===============================================================================
nocorba=0

#===============================================================================
# Allow/Forbid MO loading in SQL mode (0=allow, 1=forbid)
# Value 1 means that moshell will not read the MO data tables when loading a db.dat with option "-d"
# The startup time will be much faster but only SQL commands will then be available, not MO commands
#===============================================================================
nomo=0

#===============================================================================
# Handling of deprecated attributes and counters
#  0=Keep the deprecated attributes, actions, and counters
#  1=Exclude the deprecated attributes and notInMOM counters at create MO (cr command) and create scanner (pcr command)
#  2=Deprecated attributes and counters are completely taken out of the MOM and not visible in any MO command (cr/pcr/get/pget/mom/pmom/etc)
#  3=Same as option 2 , and exclude the deprecated MO actions
#  4=Same as option 3 , and exclude the deprecated struct members from undo commandfile
#===============================================================================
exclude_deprecated=4

#===============================================================================
# Handling of preliminary attributes and counters
#  0=Keep the preliminary attributes and counters
#  1=Preliminary attributes and counters are completely taken out of the MOM and not visible in any MO command (cr/pcr/get/pget/mom/pmom/etc)
#===============================================================================
exclude_preliminary=1

#===============================================================================
# Set timeout in SSU for communication with SLS server (in seconds)
# If no valid SLS server can be found before this timeout expires, secure connection to node will fail.
# Value should be set to 10 * (number of SLS servers) to make sure all available server are attempted before connection fails.
#===============================================================================
sls_timeout=30

#===============================================================================
# The maximum time the corba polling will go on for. After this time, the corba connection is disconnected and reconnected.
# Default 20 minutes (1200 seconds). Use 0 for infinite value.
# Note: on RBS/ERBS/RXI, the max_poll_time is 5 minutes.
#===============================================================================
max_poll_time=1200

#===============================================================================
# Command restriction
#  * 0: no restriction
#  * 1: block commands specified in the file(s) listed in the uservariable "blocked_commands"
# It is possible to specify several files in this uv, eg: blocked_commands=/path/to/file1,/path/to/file2
# These files shall contain one blocked command per line
# The blocked commands can be moshell commands or coli commands
# It is possible to use regular expression characters in the command name, but if it is a moshell command, then the command name must be preceded by a tilde sign (~).
# If no regular expression characters are used in the command name then moshell will be able to distinguish automatically if the command is a moshell command or coli command.
# See example files in the folder moshell/examples/command_restriction
#===============================================================================
command_restriction=0
#blocked_commands=$moshelldir/examples/command_restriction/coli_commands.txt,$moshelldir/examples/command_restriction/write_commands.txt,$moshelldir/examples/command_restriction/other_commands.txt

#===============================================================================
# Search listme: to search for the node's ip address in the OSSRC utility "listme" when not found in ipdatabase.
# Only applicable when running moshell on a OSSRC.
#  * 0: dont search listme
#  * 1: search listme
#===============================================================================
search_listme=1

#===============================================================================
# Disable multimode
#  * 0: multimode allowed (default)
#  * 1: multimode not allowed
#===============================================================================
nomulti=0

#===============================================================================
# gpg retry: the number of times that the gpg command will retry to decrypt the logfile in case of loss of connection with CSDP server
#===============================================================================
gpg_retry=3

#######################################################

#===============================================================================
# Enable/disable printing of "logstart"/"logclose" information in l+/l- (1=enabled, 0=disabled)
#===============================================================================
loginfo_print=1

#==============================================================================
# The list of attributes that are not displayed on screen by the CS notification client (runClient.sh -c)
#==============================================================================
csnotiflist=availabilitystatus

#==============================================================================
# Activate/deactivate workaround for handling of blank space in the MO id.
# All blank spaces in MO identities are displayed as the @ sign
# When creating MOs with the "cr" command, the @ sign is replaced by a blank space
# 1=enabled, 0=disabled. By default this feature is turned on (recommended).
#==============================================================================
mospace_convert=1

#==============================================================================
# Default xml-MOM file (in case not stored on node, e.g. prior to the first SW upgrade)
# MGW R2 MOM can be downloaded from http://internal.ericsson.com/page/hub_corenetwork/unit/pdu_ipconnectivity_control/node_mgw/mgw_supply_and_support/plm.html
# Click on "release binders". The latest MOM is included in the latest release binder.
# MGW R3 MOM can be downloaded from http://mgw.lmf.ericsson.se/projects/r3/system/MGwR3_MOM/
# MGW R4 MOM can be downloaded from http://mgw.lmf.ericsson.se/projects/r4/sm/MOM/index_4.1.html
# MGW R5 MOM can be downloaded from http://vobs.lmf.ericsson.se/wcs/mmgw/r5/mgwr5_oam_appl_mom/xml_storage/
# MGW R6/R6.1 MOM can be downloaded from https://webse1.rnd.ki.sw.ericsson.se/vobs/mmgw/sw/oam_appl_mom/build/xml_storage/
# NOTE: this setting is superceeded by the setting in ~/.moshellrc file.
# Please set this variable in ~/.moshellrc instead .
# Alternatively, transfer the MOM to the node, into the directory /c/public_html/cello/oe/xml and rename it to CelloMOM.xml
# This way, the correct MOM will be used for each node, rather than the default MOM.
#==============================================================================
default_mom="$moshelldir/commonjars/CPP_MOM-CPP-LSV144-gen1_gen1.xml.gz"

#==============================================================================
# Finding out the OS
#==============================================================================
unamea=$(uname -a)

#==============================================================================
# AMOS parameters used for licensing of the amos/moshell feature.
#
# amos_debug can have following values :
#   - 0 (or false) - no debug
#   - 1 (or true)  - some debug printouts
#   - 2            - more debug printouts
#
# AMOS log interval (amos_log_interval) : 
# to specify the interval (in minutes) after which the AMOS command history will be written to LogViewer/SMLog. 
# Default=0 (=> command history will be written at the end of the AMOS session)
#
# AMOS Account Lookup (amos_enm_accountlookup) : 
# Note: only applicable for ENM, not OSSRC
#   - 1 (default): AMOS will query ENM to create a temporary ldap account to login to the node
#   - 0: the AMOS Account Lookup feature will not be used. Can be useful to disable this feature in case the account lookup is causing long delays
#==============================================================================
if [[ $moshelldir = /opt/ericsson/amos/moshell* ]] ; then
amos_debug="false"
amos_process_logging="true"
amos_java="$JAVA_HOME/bin/java"
amos_log_interval=0
amos_enm_accountlookup=1
if [[ $unamea = SunOS* ]] ; then
source /etc/opt/ericsson/system.env
fi
export NSA_CLASSPATH PAS_CLASSPATH PORTAL_CLASSPATH SECURITY_CLASSPATH SENTINEL_CLASSPATH TSS_CLASSPATH BORLAND_HOME JAVA_HOME JAVAFLAGS NameServiceHost NameServicePortGB HOSTNAME
fi


#######################################################
#  OTHER SETTINGS (!! DO NOT EDIT !!)
#######################################################
emcli=0
vobsinstallation=0  #Will be automatically set to 1 when installing moshell with "bash moshell_install -vk": this is done when the same moshell shall be run both from solaris and linux. Installation must be done from the solaris/sparc machine
unr=0
mosro=0
thisdate=$(date +%Y%m%d)
thistime=$(date +%H%M%S)
serialNumber="${thisdate}-${thistime}_$$"
gawkext=""
gawklib=""
if [[ $unamea = [Ll][iI][nN][uU][xX]*x86_64* ]] ; then gawklib="lin64"   ; if [[ $vobsinstallation = 1 ]] ; then gawkext=".lin64"   ; fi
elif [[ $unamea = [Ll][iI][nN][uU][xX]* ]]      ; then gawklib="linux"   ; if [[ $vobsinstallation = 1 ]] ; then gawkext=".linux"   ; fi
elif [[ $unamea = SunOS*sparc* ]]               ; then gawklib="solaris" ; if [[ $vobsinstallation = 1 ]] ; then gawkext=".solaris" ; fi
elif [[ $unamea = SunOS* ]]                     ; then gawklib="sol86"   ; if [[ $vobsinstallation = 1 ]] ; then gawkext=".sol86"   ; fi
else gawklib="cygwin" ; gawkext=".exe"
fi
gawkprog="gawk${gawkext}"
gawk="LANG=C LC_ALL=C $moshelldir/$gawkprog"

#special case where moshell has been installed on a linux 32 bit machine but should be run on linux 64 sharing the same file system
if [[ $unamea = [Ll][iI][nN][uU][xX]*x86_64* && $vobsinstallation != 1 && `file "$moshelldir/gawk"` = *32-bit* ]] ; then gawklib="linux" ; fi

filefunc="$moshelldir/commonjars/lib/${gawklib}/filefuncs"
#LD_LIBRARY_PATH should not start or end with a colon sign. The expression below indicates to only put "$LD_LIBRARY_PATH:" if it is set and non-null
export LD_LIBRARY_PATH=$moshelldir/commonjars/lib/${gawklib}${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
programfile="$moshelldir/prog.awk"
iorfiledir="$moshelldir/iorfiles"
funcs="$moshelldir/funcs.awk"
defLogDir=$commonjardir/defLogDir.sh
moshellrc=$($defLogDir)
globmoshellrc=$jarxmldir/moshellrc
if [[ ! -r $globmoshellrc ]] ; then cp $globmoshellrc.template $globmoshellrc ; fi
#read the value of set_window_title from jarxml/moshellrc and ~/.moshellrc since it is used in the trap cleanup function
tmp_window_title=`$moshelldir/$gawkprog '$1~/^set_window_title/{print gensub(/^.*= *| *#.*$/,"","g",$0)}' $globmoshellrc`
if [[ $tmp_window_title = 0 || $tmp_window_title = 1 ]] ; then set_window_title=$tmp_window_title ; fi
tmp_window_title=`$moshelldir/$gawkprog '$1~/^set_window_title/{print gensub(/^.*= *| *#.*$/,"","g",$0)}' $moshellrc`
if [[ $tmp_window_title = 0 || $tmp_window_title = 1 ]] ; then set_window_title=$tmp_window_title ; fi

#Finding out the logdirectory
temp_logdir="unknown"
logdir="$moshelldir/logfiles/logs_moshell"
while getopts "lv:uc:nmdo:a:eft:gx:y:w:" options
do
case $options in
o) temp_logdir="$OPTARG"
   if [[ -f $temp_logdir ]] ; then temp_logdir="unknown"
   else mkdir -p $temp_logdir ; fi
   if [[ $temp_logdir != /* ]] ; then temp_logdir=`pwd`/$temp_logdir ; fi
   if [[ -w $temp_logdir && -d $temp_logdir ]] ; then : ; else temp_logdir="unknown" ; fi
   ;;
esac
done
unset OPTIND
umask=$(umask)
if [[ $temp_logdir = "unknown" ]] ; then
temp_logdir=$($defLogDir moshell)
umask 000
fi
if [[ -w $temp_logdir && -d $temp_logdir ]] ; then logdir=$temp_logdir ; fi
if mkdir -p $logdir/tempfiles ; then tempdir=$logdir/tempfiles ; else tempdir=/tmp ; fi
if [[ $moshelldir = /opt/ericsson/amos/moshell* && $unamea = [Ll][iI][nN][uU][xX]* ]] ; then tempdir=/var/tmp ; fi
tempdir=$tempdir/$serialNumber
mkdir -p $tempdir
if [[ -d $logdir/undo && -d $logdir/moscomlogs && -d $logdir/fclean && -d $logdir/diff && -d $logdir/lg ]] ; then :
else
mkdir -p $logdir/undo
mkdir -p $logdir/resub
mkdir -p $logdir/hc/logs
mkdir -p $logdir/hc/reports
mkdir -p $logdir/lg
mkdir -p $logdir/remod
mkdir -p $logdir/rset
mkdir -p $logdir/sessionlog
mkdir -p $logdir/logs_monode
mkdir -p $logdir/moscomlogs
mkdir -p $logdir/other
mkdir -p $logdir/diff
mkdir -p $logdir/fclean
mkdir -p $logdir/gnuplot
fi
umask $umask
if [[ $moshelldir = /opt/ericsson/amos/moshell ]] ; then
   chmod 1777 $logdir/tempfiles $tempdir $logdir/undo $logdir/resub $logdir/hc $logdir/lg $logdir/remod $logdir/rset $logdir/sessionlog $logdir/logs_monode $logdir/moscomlogs $logdir/other $logdir/diff $logdir/fclean $logdir/hc/logs $logdir/hc/reports
   echo "BEGIN{}" > "$tempdir/amosvarfile"
fi
#the lgcsv folder is not applicable anymore so we move it to "old" (disabled for the moment, causes error messages in some cases)
#if [[ -d $logdir/lgcsv ]] ; then mv $logdir/lgcsv $logdir/old_lgcsv ; fi

tempior="$tempdir/ior$$"
argumentfile="$tempdir/argumentfile$$"
tempother="$tempdir/other$$"
unzip="unzip"
bash="/bin/bash"
if [[ $unamea = SunOS*sparc* ]] ; then
    if [[ $vobsinstallation = 1 ]] ; then unzip=$commonjardir/unzip.solaris ; bash=$commonjardir/bash.solaris
    else unzip=$commonjardir/unzip ; bash=$commonjardir/bash
    fi
    export PATH=${PATH}:/usr/ucb   #workaround for whoami sometimes not found on solaris/sparc
elif [[ $unamea = SunOS* ]] ; then
    if [[ $vobsinstallation = 1 ]] ; then bash=$commonjardir/bash.sol86 ; else bash=$commonjardir/bash ; fi
elif [[ $unamea = Linux*x86_64* ]] ; then
    if [[ $vobsinstallation = 1 ]] ; then bash=$commonjardir/bash.lin64 ; else bash=$commonjardir/bash ; fi
elif [[ $unamea = Linux* ]] ; then
    if [[ $vobsinstallation = 1 ]] ; then bash=$commonjardir/bash.linux ; else bash=$commonjardir/bash ; fi
elif [[ $unamea = CYGWIN* ]] ; then
    export CYGWIN=nodosfilewarning
fi
if [[ $unamea = SunOS* ]] ; then
    if [[ -z "$TZ" ]] ; then TZ=`$moshelldir/$gawkprog '$1~/^TZ=.+/{print gensub(/^TZ=|\"/,"","g",$1)}' /etc/TIMEZONE` ; fi
elif [[ $unamea = Linux* ]] ; then
    if [[ -z "$TZ" ]] ; then
        if [[ -f /etc/sysconfig/clock ]] ; then TZ=`$moshelldir/$gawkprog '$1~/^TIMEZONE=.+/{print gensub(/^TIMEZONE=|\"/,"","g",$1)}' /etc/sysconfig/clock`
        elif [[ -f /etc/timezone ]] ; then TZ=`$moshelldir/$gawkprog '$1!=""{print $1}' /etc/timezone`
        else
        	$moshelldir/$gawkprog -v tzfile="$tempdir/tz$$" -f $moshelldir/commonjars/find_tz.awk
        	TZ=`cat $tempdir/tz$$`
        fi
    fi
fi
if [[ "$TZ" ]] ; then export TZ ; fi
##########################################################################
#  END OF DEFINITIONS
##########################################################################

##########################################################################
#     FUNCTIONS
##########################################################################


function get_ip_address(){
LANG=C LC_ALL=C $moshelldir/$gawkprog -v iorfile=$iorfile 'BEGIN{
	FS=""
	getline < iorfile
	close(iorfile)
	iorline=tolower($0)
	match(iorline,/(3[0-9])+2e(3[0-9])+2e(3[0-9])+2e(3[0-9])+00/)
	$0=substr(iorline,RSTART,RLENGTH-2)
	temp=""
	for (i=2;i<=NF;i=i+2) temp=temp $i
	ip_address = gensub("e",".","g",temp)
	if (ip_address !~ /^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/)
	{
		#ipv6
		l[1]="a";l[2]="b";l[3]="c";l[4]="d";l[5]="e";l[6]="f"
		#match(iorline,/(3[0-9]|[46][1-6])+3a(3[0-9]|[46][1-6])+3a(3[0-9]|[46][1-6])+3a(3[0-9]|[46][1-6])+3a(3[0-9]|[46][1-6])+3a(3[0-9]|[46][1-6])+3a(3[0-9]|[46][1-6])+3a(3[0-9]|[46][1-6])+00/)
		match(iorline,/(3[0-9]|[46][1-6])+3a(3[0-9]|[46][1-6])+3a(3[0-9]|[46][1-6])*3a(3a|3[0-9]|[46][1-6])+00/)
		$0=substr(iorline,RSTART,RLENGTH-2)
		temp=""
		#print "debug: "$0 > "/dev/stderr"
		for (i=1;i<NF;i+=2)
		{
			if ($i==3)
			{
				#temp=temp $(i+1)
				if( $(i+1) == "a" ) temp=temp":"
				else temp=temp $(i+1)
			}
			else if ($i==4 || $i==6) temp=temp l[$(i+1)]
		}
		#ip_address=gensub("a",":","g",temp)
		ip_address=temp
	}
	#print "debug: "ip_address >"/dev/stderr"
	print ip_address
	}'
}

function cleanup()
{
if [[ $moshelldir = /opt/ericsson/amos/moshell ]] ; then
        LANG=C LC_ALL=C $moshelldir/$gawkprog -v moshell_pid=$$  -v moshelldir="$moshelldir" -v amos_process_logging=true -v amos_ps_logfile=/var/opt/ericsson/amos/sessions_`hostname`.log -f "$funcs" --source 'BEGIN{amos_process_log(moshell_pid,"1")}'
        if test -s "$tempdir/amosvarfile" ; then
		LANG=C LC_ALL=C $moshelldir/$gawkprog -f "$tempdir/amosvarfile" -f "$funcs" -l "$filefunc" --source 'BEGIN{parse_common_variables();log_amos()}'
        fi
fi
if test -s "$tempdir/lgnlastcmd" && test -s "$tempdir/lgnvarfile" ; then
	#echo "LGN:" ; cat "$tempdir/lgnlastcmd"
	LANG=C LC_ALL=C $moshelldir/$gawkprog -f "$tempdir/lgnvarfile"  --source 'BEGIN{ if (system("test -s "moscomlog)!=0 && system("test -s "moscomlog".gz")==0) system("gzip -d "moscomlog".gz") ;while (getline < templastmoshellcmd) { print $0 >> moscomlog } ; close(moscomlog) }'
fi
sshdpid=`cat $tempdir/sshdpid.log 2>/dev/null`
#echo "sshdpid=${sshdpid}x"
if [[ "$sshdpid" = [0-9]* ]] ; then
	#echo "kill $sshdpid"
	kill $sshdpid
	#kill -9 $sshdpid
fi
rm -rf $tempdir/*
rmdir $tempdir 2>/dev/null
if test $set_window_title -eq 1  ; then echo -e "\x1B]0; \a" ; fi
exit
}

function moshell_noargs()
{
cat <<EOF
Usage:
 1) Online mode : moshell [-v uservariables] [-efg] [-a <rcfiles>] [-n] [-t <ip>[:port]] <site-name>|<ip-address>|<host-name>|<ior-file> [<command(s)>|<commandfile>] [<logfile>]
 2) Offline mode: moshell [-v uservariables] [-efg] [-a <rcfiles>] [<MO-dump>|<dcglogs-zipfile>]  [<command(s)>|<commandfile>] [<logfile>]
 3) Multi mode  : moshell [-v uservariables] [-efg] [-a <rcfiles>] -m <sitelist>|<sitefile> [<command(s)>|<commandfile>] [<logfile>]
 4) SQL mode    : moshell [-v uservariables] [-efg] [-a <rcfiles>] -d [-v nomo=1] <db.dat>|<cv.zip>|<dbdump.zip>

Online means that moshell is connected to a node.
Offline is used for browsing logs with moshell, e.g. an MO-dump, a set of ROP files, or a set of CPP logfiles.
Multimode means that moshell is connected to several nodes at the same time.
SQL mode means that moshell is connected to a db.dat, cv.zip (fetched with cvget), or dbdump.zip (fetched with cvgetd).
Refer to the chapter "Offline mode and Multi mode" in the User Guide for more information.

The "-v" option is for setting uservariables from the command line. See README file chapter 0.2 for more info.
The "-v" option can also be used for setting scripting variables from the command line. In this case, the "$" sign in front of the variable name should be omitted. See README chapter
The "-n" option is for disabling the check of IP contact at startup.
The "-e" option is to skip sourcing of the global moshellrc file (moshell/jarxml/moshellrc)
The "-f" option is to skip sourcing of the user's moshellrc file (~/.moshellrc)
The "-g" option is for gzipping the logfile after completion (only applicable when a logfile has been specified)
The "-a" option is to source some additional moshellrc files, eg: -a file1,file2. These files will be sourced after the global moshellrc and before the user's .moshellrc.
The "-t" option is to use a time server when connecting to an emulated node. If the optional port argument is not specified, the default port of 8123 will be used.

The argument can be:
 * <site-name> : refers to the node's name as defined in the ipdatabase file (whose path is defined in moshell file).
 * <host-name> : refers to the node's name as defined in DNS.
 * <ip-address>: raw ip address
 * <ior-file>  : an iorfile that has been stored on the workstation.
 * <sitelist>  : the list of sites to connect to, eg: site1,site2,site3. Applicable with option "-m" only.
 * <sitefile>  : the file containing the list of sites, one site per line. Applicable with option "-m" only.
 * <MO-dump>   : the MO dump is a file obtained with the command "dcgk" or "lt all;kget". It can be in text format, .gz format, or .zip format.
 * <dcglogs-zipfile> : a zipfile containing all the logs produced by the dcgm command (modump.zip, logfiles.zip, ropfiles.zip)

Logfiles and temporary files are automatically stored under ~/moshell_logfiles/logs_moshell. This path can be changed either by setting the uservariable "logdir" in the file ~/.moshellrc or from command line with the option "-o <logdirectory>".

Examples, online mode:
 * moshell 10.121.7.33
 * moshell -v security_method=2,sa_credential=~/sam.pbe,sa_password=oemas 10.1.128.17
 * moshell -v telnet_port=2323,http_port=8080 rnc3
 * moshell rbs28 ~/tools/moshell/cmdfiles/runSwTest.cmd
 * moshell bsc5 'vii ; cabslxrd ; lh mp te log read | grep ERROR ; lt plug ; st all dis ; get all all '
 * moshell 10.121.2.37 'vii ; lh mp te log read | grep ERROR ' ~/moshell_logfiles/nodeTest.log
Examples, offline mode:
 * moshell ~/moshell_logfiles/logs_moshell/sessionlog/RNC37_modump.zip  #interactive mode
 * moshell ~/modumps/mgw1_kget.log.gz 'pr ; get ; st ; inv'             #script mode
Examples, multimode:
 * moshell -m rnc11,10.1.128.17,rbs33.ericsson.se
 * moshell -m rbslist.txt 'lt all; kget'
Examples, sql mode:
 * moshell -d ~/moshell_logfiles/logs_moshell/dcg/RNC11/RNC11_cvfinal.zip
 * moshell -d ~/moshell_logfiles/logs_moshell/cv/RNC11/db.dat

EOF
}

function check_pathes()
{
if [ ! -d $moshelldir ] ; then  echo "" ; echo "=====================================================================" ; echo "!!!! Moshell directory not found !!!! ---> moshelldir=$moshelldir ???" ;  echo "=====================================================================" ;fi
if [ ! -x $bash ]       ; then  echo "" ; echo "=====================================================================" ; echo "!!!! Bash not found !!!! ---------------> bash=$bash ???"               ;  echo "=====================================================================" ;fi
}


##########################################################################
# END OF FUNCTIONS
##########################################################################

##########################################################################
#    START OF SHELL SCRIPT
##########################################################################

echo ""
trap 'cleanup' 0 1 2 3 15

check_pathes

gz=0
nocs=0
checkIpContact=1
multi=0
dbdat=0
userVariables=""
additionalRcFile=""
noglobrc=0
nouserrc=0
amosopt=0
timeServer=""
timePort=""
# $LIB is an internal token used in ld.so. It will expand to lib for 32-bit binaries
# and lib64 for 64-bit binaries. This will allow us to use the correct timelib for each
# binary in a mixed 32/64 bit environment.
timeLib="$moshelldir/commonjars/lib/timelib/\$LIB/timelib.so"

while getopts "lv:uc:nmdo:a:eft:gx:y:w:" options
do
case $options in
w) mobatch_dirdate="$OPTARG"
   ;;
x) amosopt=1
   amosfile="$OPTARG"
   ;;
y) amosopt=2
   amosfile="$OPTARG"
   ;;
g) gz=1
   ;;
l) nocs=1
   ;;
v) userVariables="$OPTARG"
   ;;
c) securityOptions="$OPTARG"
   ;;
u) if [[ $unr = 1 ]] ; then unr=0 ; fi
   ;;
n) checkIpContact=0 ;;
m) if [[ $nomulti = 1 ]] ; then echo "Multimode is not allowed on this server." ; exit 1 ; fi
   multi=1 ;;
d) dbdat=1 ;;
a) additionalRcFile="$OPTARG" ;;
e) noglobrc=1 ;;
f) nouserrc=1 ;;
t) if [[ $OPTARG = *:* ]]; then
	#read timeServer timePort <<<$(IFS=':'; echo $OPTARG)  #not compatible with old bash versions
	timeServer=${OPTARG%:*}
	timePort=${OPTARG#*:}
   else
	timeServer="$OPTARG"
	timePort="8123"
   fi
  ;;
esac
done
shift $(($OPTIND - 1))


logfile=0
command=0
commandfile=0
case $# in
1|2|3)
    if [[ $# -gt 1 ]] ; then
    	if test -s "$2" ; then commandfile="$2" ; else command="$2" ; fi
    	if [[ $# -gt 2 ]] ; then
    		logfile="$3"
    		if [[ $logfile = nolog ]] ; then :
    		elif [[ $unr = 3 ]] ; then :   #touch not working when running unr=3
    		elif touch $logfile && test -w $logfile && test -f $logfile ; then :
    		else echo "Unable to write to logfile: $logfile" ; exit 1
    		fi
    	#else
    	#no logfile is made by default anymore
	#	date=$(date +%y%m%d-%H%M)
	#	logfile=${logdir}/logs_monode/${date}_`basename $1`.log
	fi
    fi
    iorfile=$1 ; node_address=""
    if test -s "$iorfile" && test -f "$iorfile" ; then
        #it's a file
	node_address=`get_ip_address`
	node=`basename $iorfile`
	if [[  x$node_address = x ]] ; then
		#it's not an iorfile
		if [[ "$iorfile" = *.gz || "$iorfile" = *.zip || "$iorfile" = *.ZIP || "$iorfile" = *.GZ || "`grep -c stopfile= "$iorfile"`" > 0 || $dbdat = 1 ]] ; then
			#it's an modump or a db.dat/cv.zip
			checkIpContact=0
			node_address="OFFLINE_"`basename $iorfile`
			node=$node_address
		else
			#it's not an modump, it's probably a file that has the same name as a node
		        node_address=$1
			iorfile=$tempior
			node=$node_address
		fi
	fi
    elif [[ $dbdat = 1 ]] ; then
        #we used option -d but gave wrong path to the file
	checkIpContact=0
	node_address="OFFLINE_"`basename $iorfile`
	node=$node_address
    else
    	#it's an ipaddress or dns name
        node_address=$1
	iorfile=$tempior
	node=$node_address
    fi
    ;;
0)
    checkIpContact=0
    node="OFFLINE"
    node_address="OFFLINE"
    moshell_noargs
    ;;
*)
    moshell_noargs
    exit 0
    ;;
esac

if [[ $timeServer != "" && ($multi == 1 || $dbdat == 1 || $node == "OFFLINE") ]]; then
    echo "Time server usage is not supported in multi mode, SQL mode or offline mode"
    exit 0
fi

if [[ $unr > 0 || $mosro > 0 ]] ; then
     otherfunctions="$moshelldir/other1.awk"
     if   [[ $unr = 1 ]] ; then moshell_version="$moshell_version RESTRICTED+"
     elif [[ $unr = 2 ]] ; then moshell_version="$moshell_version RESTRICTED"
     elif [[ $unr = 3 ]] ; then moshell_version="$moshell_version LIMITED"
     elif [[ $mosro = 1 ]] ; then moshell_version="$moshell_version READONLY"
     fi
elif [[ -r "$moshelldir/other.awk" ]] ; then otherfunctions="$moshelldir/other.awk"
elif [[ -r "$moshelldir/other.zip" ]] ; then
	tty -s && stty -echo
	read -e -p "Please enter password: "
	tty -s && stty echo
	if $unzip -qc -P $REPLY "$moshelldir/other.zip" > $tempother ; then
		otherfunctions=$tempother
		echo ""
	else echo -e "\nIncorrect password. Exiting..." ; exit 1
	fi
fi

cat <<EOF > $argumentfile
BEGIN{
moshell_parent_pid=$PPID
moshell_pid=$$
moshelldir="$moshelldir"
moshellrc="$moshellrc"
globmoshellrc="$globmoshellrc"
monode_command="$command"
monode_commandfile="$commandfile"
monode_logfile="$logfile"
mobatch_dirdate="$mobatch_dirdate"
gawk="$gawk"
bash="$bash"
iorfile="$iorfile"
node="$node"
node_address="$node_address"
logdir="$logdir"
moshell_version="$moshell_version"
unr=$unr
checkIpContact="$checkIpContact"
tempother="$tempother"
nocs=$nocs
securityOptions="$securityOptions"
userVariables="$userVariables"
tempdir="$tempdir"
vobsinstallation="$vobsinstallation"
multi=$multi
dbdat=$dbdat
filefunc="$filefunc"
additionalRcFile="$additionalRcFile"
noglobrc="$noglobrc"
nouserrc="$nouserrc"
perllib="$PERLLIB"
amosopt="$amosopt"
amosfile="$amosfile"
}
EOF

if [[ $LD_PRELOAD = */opt/Citrix/VDA/lib64/libctxXrandrhook.so* ]] ; then
	export LD_PRELOAD=""
fi
if [[  $timeServer != "" ]]; then
	export TIME_SERVER=$timeServer
	export TIME_PORT=$timePort
	export LD_PRELOAD=$timeLib
fi
if [[ $unamea = SunOS* && $LD_PRELOAD_32 = *libatriagetcwd_interposer.so* ]] ; then
	unset LD_PRELOAD_32
fi
#PERLLIB is set by CPP DTE source scripts , can cause conflicts in pmr/pmx/steg
unset PERLLIB
#To avoid openssl error message "WARNING: can't open config file: /usr/local/ssl/openssl.cnf"
if [[ -z "$OPENSSL_CONF" ]] ; then touch $tempdir/openssl.cnf && export OPENSSL_CONF="$tempdir/openssl.cnf" ; fi
if [[ $logfile != 0 && $logfile != nolog ]] ;then
	echo "Logging to file $logfile"
	echo "Logging to file $logfile" > $logfile
	#LANG=C LC_ALL=C $moshelldir/$gawkprog -f "$argumentfile" -f "$programfile" -f "$otherfunctions" -f "$funcs" -l "$filefunc" --source 'BEGIN { moshell_start() } ; END { moshell_end() }' 2>&1 | LANG=C LC_ALL=C $moshelldir/$gawkprog -v logfile=$logfile '{print ; print >> logfile ; if ($1=="$mobrowser_pid" || $1=="$pmtester_pid" || $1=="$amosrb_pid") close(logfile) ; else if ($1 == "Bye..." && NF==1) exit ; else if (pid_found != 1 && $NF ~ /^stopfile=.tmp.[0-9]+$/) { close(logfile) ; pid_found=1 }}'
	#LANG=C LC_ALL=C $moshelldir/$gawkprog -f "$argumentfile" -f "$programfile" -f "$otherfunctions" -f "$funcs" -l "$filefunc" --source 'BEGIN { moshell_start() } ; END { moshell_end() }' 2>&1 | LANG=C LC_ALL=C $moshelldir/$gawkprog -v logfile=$logfile '{print ; print >> logfile ; if ($1=="$mobrowser_pid" || $1=="$pmtester_pid" || $1=="$amosrb_pid") close(logfile) ;                                          else if (pid_found != 1 && $NF ~ /^stopfile=.tmp.[0-9]+$/) { close(logfile) ; pid_found=1 }}'
	#TR HL94683, must use tee instead of gawk otherwise exits when calling an moshell from within moshell. if not using the exit in gawk then hanging when starting a background monitor6054 from moshell. tee has both advantages, does not hang when starting background monitor6054 process and logs to file continuously without buffering
	LANG=C LC_ALL=C $moshelldir/$gawkprog -O -f "$argumentfile" -f "$programfile" -f "$otherfunctions" -f "$funcs" -l "$filefunc" --source 'BEGIN { moshell_start() } ; END { moshell_end() }' 2>&1 | tee -a $logfile
	echo "Output has been logged to file $logfile"
	echo "Output has been logged to file $logfile" >> $logfile
	if [[ $gz = 1 ]] ; then
		echo "Gzipping logfile to "$logfile".gz"
		gzip -f $logfile
	fi
else
	LANG=C LC_ALL=C $moshelldir/$gawkprog -O -f "$argumentfile" -f "$programfile" -f "$otherfunctions" -f "$funcs" -l "$filefunc" --source 'BEGIN { moshell_start() } ; END { moshell_end() }' 2>&1
fi

