Error while running container

Hi, I am try to containerize one soft through Dockerfile, build is successful but while running container its giving exception, dockerfile consists of installation script and installation script file consists of multiple option as per below.

1.) ./install.sh–>press enter–>select option 1–>quit–select yes–>select yes–>select no–>select no–>logout from session–>login

2.) manually running script file is ok but while container it’s giving exception as per below.

[centos@ip-172-31-22-99 ~]$ docker run -it -p 8090:8080 hmp
./install.sh: line 84: bc: command not found
./install.sh: line 84: [: -eq: unary operator expected
./install.sh: line 126: perl: command not found
dmesg: read kernel buffer failed: Operation not permitted

Installing Dialogic(R) HMP Software Release 4.1LIN
Redistributable Runtime
Please wait, installation is in progress...

Error: ./install.sh: The command tput is not in the path.

An error occurred while installing the Redistributable Runtime
Software.  Aborting installation of the Software Development
Kit.

3.) Dockerfile as below.

FROM centos
RUN mkdir /hmp
WORKDIR /hmp
COPY lnxHMP_4.1_293.tgz /hmp
RUN yum -y update
RUN yum -y install libstdc++*
RUN yum -y install libstdc++.i686
RUN tar -zxvf lnxHMP_4.1_293.tgz
COPY install.sh /hmp
RUN chmod +x ./install.sh
CMD ./install.sh 

4.) Docker build o/p

[centos@ip-172-31-22-99 ~]$ docker build -t hmp .
Sending build context to Docker daemon  1.058GB
Step 1/11 : FROM centos
 ---> 5d0da3dc9764
Step 2/11 : RUN mkdir /hmp
 ---> Using cache
 ---> 6798e36f7823
Step 3/11 : WORKDIR /hmp
 ---> Using cache
 ---> b1acd4af6774
Step 4/11 : COPY lnxHMP_4.1_293.tgz /hmp
 ---> Using cache
 ---> 3d52b457aaf9
Step 5/11 : RUN yum -y update
 ---> Using cache
 ---> 3b1db01bb01a
Step 6/11 : RUN yum -y install libstdc++*
 ---> Using cache
 ---> 3d79e35597c6
Step 7/11 : RUN yum -y install libstdc++.i686
 ---> Using cache
 ---> 76061dad2ae4
Step 8/11 : RUN tar -zxvf lnxHMP_4.1_293.tgz
 ---> Using cache
 ---> e699407a7d38
Step 9/11 : COPY install.sh /hmp
 ---> Using cache
 ---> 9ea2af7fc9aa
Step 10/11 : RUN chmod +x ./install.sh
 ---> Using cache
 ---> 4e9d3416e3db
Step 11/11 : CMD ./install.sh
 ---> Using cache
 ---> 5e3d6dfc4688
Successfully built 5e3d6dfc4688
Successfully tagged hmp:latest

Kindly help…

I’d start with fixing this. Unlike on your local machine, the image you’re using does not know this command. You’re already using RUN yum -y install libstdc++* and some more, so you’d need something like RUN yum -y install bc as well.

Aside, when all works you’ll want to read about build caching: Overview of best practices for writing Dockerfiles | Docker Docs Also, I’d say that the output you’re showing for docker build -t hmp . is missing its last lines.

Thanks Arjan,

I did try with yum -i install bc but getting exception, below are details.

[centos@ip-172-31-22-99 ~]$ docker build -t hmp .
Sending build context to Docker daemon  1.058GB
Step 1/12 : FROM centos
 ---> 5d0da3dc9764
Step 2/12 : RUN mkdir /hmp
 ---> Using cache
 ---> 6798e36f7823
Step 3/12 : WORKDIR /hmp
 ---> Using cache
 ---> b1acd4af6774
Step 4/12 : COPY lnxHMP_4.1_293.tgz /hmp
 ---> Using cache
 ---> 3d52b457aaf9
Step 5/12 : RUN yum -y update
 ---> Using cache
 ---> 3b1db01bb01a
Step 6/12 : RUN yum -y install libstdc++*
 ---> Using cache
 ---> 3d79e35597c6
Step 7/12 : RUN yum -y install libstdc++.i686
 ---> Using cache
 ---> 76061dad2ae4
Step 8/12 : RUN tar -zxvf lnxHMP_4.1_293.tgz
 ---> Using cache
 ---> e699407a7d38
Step 9/12 : RUN yum -y install bc
 ---> Running in 0f822e8cba72
CentOS Linux 8 - AppStream                       14 kB/s | 4.3 kB     00:00
CentOS Linux 8 - BaseOS                          26 kB/s | 3.9 kB     00:00
CentOS Linux 8 - Extras                         6.5 kB/s | 1.5 kB     00:00
Dependencies resolved.
================================================================================
 Package      Architecture     Version                   Repository        Size
================================================================================
Installing:
 bc           x86_64           1.07.1-5.el8              baseos           129 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 129 k
Installed size: 236 k
Downloading Packages:
bc-1.07.1-5.el8.x86_64.rpm                      4.9 MB/s | 129 kB     00:00
--------------------------------------------------------------------------------
Total                                           1.2 MB/s | 129 kB     00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : bc-1.07.1-5.el8.x86_64                                 1/1
  Running scriptlet: bc-1.07.1-5.el8.x86_64                                 1/1
  Verifying        : bc-1.07.1-5.el8.x86_64                                 1/1

Installed:
  bc-1.07.1-5.el8.x86_64

Complete!
Removing intermediate container 0f822e8cba72
 ---> 3835a4747e5f
Step 10/12 : COPY install.sh /hmp
 ---> a47bc0d1e0a3
Step 11/12 : RUN chmod +x ./install.sh
 ---> Running in 7462b8ae9db9
Removing intermediate container 7462b8ae9db9
 ---> 53799d67565a
Step 12/12 : CMD ./install.sh
 ---> Running in e40e150e64ab
Removing intermediate container e40e150e64ab
 ---> 90169de30550
Successfully built 90169de30550
Successfully tagged hmp:latest

run container o/p

[centos@ip-172-31-22-99 ~]$ docker run -it -p 8090:8080 hmp
./install.sh: line 126: perl: command not found
dmesg: read kernel buffer failed: Operation not permitted

Installing Dialogic(R) HMP Software Release 4.1LIN
Redistributable Runtime
Please wait, installation is in progress...

Error: ./install.sh: The command tput is not in the path.

An error occurred while installing the Redistributable Runtime
Software.  Aborting installation of the Software Development
Kit.

Dockerfile

[centos@ip-172-31-22-99 ~]$ cat Dockerfile
#base image
FROM centos
RUN mkdir /hmp
WORKDIR /hmp
COPY lnxHMP_4.1_293.tgz /hmp
RUN yum -y update
RUN yum -y install libstdc++*
RUN yum -y install libstdc++.i686
#redhat-lsb gcc* telnet
#RUN cd hmp
RUN tar -zxvf lnxHMP_4.1_293.tgz
RUN yum -y install bc
COPY install.sh /hmp
RUN chmod +x ./install.sh
#ENTRYPOINT ["/install.sh"]
#CMD ["true"]
CMD ./install.sh

Well, try the same for the next error?

Aside, please use the formatting toolbar, or Markdown fenced code blocks, for formatting:

```text
your code
here
```

Thanks Arjan, now previous exception is cleared but while running container it’s asking for choice for installing package as below () in short once install.sh is executed then we need to “Press ENTER to display the menu of packages” -->Enter the packages you want to install, separated by a space, or [A,a,Q,q]: 1 -->Press ENTER to continue:–>Enter the packages you want to install, separated by a space, or [A,a,Q,q]: q -->Do you wish to install the Software Development Kit [y/n] ? y -->Do you wish to install the Software Demo Kit [y/n] ? y -->Do you wish to configure the SNMP Agent Listening Port (default is 161) [y/n] ? n -->Do you wish to configure the CLI Agent Telnet Port (default is 23) [y/n] ? n.
MEANS ENTER VARIOUS OPTION TO INSTALL PACKAGE for which i am not getting clue how to do that will additional steps needs to be mentioned in Dockerfile and build it? or else some different approach while running container.

[centos@ip-172-31-90-196 ~]$ docker run -it -p 8080:8090 hmp

Installing Dialogic(R) HMP Software Release 4.1LIN
Redistributable Runtime
Please wait, installation is in progress…

Initializing install, please wait …

================================================================================
Dialogic(R) HMP Software Release 4.1LIN
Redistributable Runtime
INSTALLATION

You will now have the opportunity to install software packages.
After the menu is displayed, enter the package number(s) of the desired
packages, separated by a space. Enter A for all packages, Q to quit.

Package dependencies will be automatically resolved during installation. For
example, selecting a single package will automatically install all packages
required for that selection.

Press ENTER to display the menu of packages:

Item Package Description


1 Dialogic(r) Host Media Processing Software (365 MB)
2 Dialogic(r) DNI Boards & HMP Software (438 MB)

A Install All (438 MB)
Q Quit Installation

Enter the packages you want to install, separated by a space, or [A,a,Q,q]: 1

Press ENTER to continue:

Item Package Description


1 Dialogic(r) Host Media Processing Software (365 MB)
2 Dialogic(r) DNI Boards & HMP Software (438 MB)

A Install All (438 MB)
Q Quit Installation

Enter the packages you want to install, separated by a space, or [A,a,Q,q]: q

Installation of Dialogic(R) HMP Software Release 4.1LIN Redistributable Runtime was successful.

Installing media server prompt package
Verifying… ################################# [100%]
Preparing… ################################# [100%]
Updating / installing…
1:lsb-dialogic-hmp41-msp-4.1.0.0-5 ################################# [100%]

Do you wish to install the Software Development Kit [y/n] ? y

Installing Dialogic(R) HMP Software Release 4.1LIN Software Development Kit

Verifying… ################################# [100%]
Preparing… ################################# [100%]
Updating / installing…
1:lsb-dialogic-hmp41-sdk-4.1.0.0-30################################# [100%]
Installation successful.

Installation of Dialogic(R) HMP Software Release 4.1LIN Software Development Kit was successful.

Do you wish to install the Software Demo Kit [y/n] ? y

Installing Dialogic(R) HMP Software Release 4.1LIN Software Demo Kit

Verifying… ################################# [100%]
Preparing… ################################# [100%]
Updating / installing…
1:lsb-dialogic-hmp41-demos-4.1.0.0-################################# [100%]
Installation successful.

Installation of Dialogic(R) HMP Software Release 4.1LIN Software Demo Kit was successful.

Do you wish to configure the SNMP Agent Listening Port (default is 161) [y/n] ? n
Do you wish to configure the CLI Agent Telnet Port (default is 23) [y/n] ? n

Installation of Dialogic(R) HMP Software Release 4.1LIN successfully completed.

WARNING:
WARNING: RTC IRQ test failed, The HPET may be enabled.
WARNING: It is recommended to disable the HPET when running HMP
WARNING: Please see HMP Software Installation Guide for more information



– NOTE: –


– (1) The default Verification License has been automatically installed. –
– (2) The Dialogic(R) system services will automatically start every –
– time the system is rebooted. To start and stop system services –
– manually, use the dlstop and dlstart scripts found in –
– /usr/dialogic/bin. –
– (3) For administration via SNMP, use any SNMP browser, library or tools–
– (4) For administration via CLI, use the telnet command –
– (5) For details, refer to documentation –


– NEXT STEPS: –
– (1) Before using the software, you MUST do one of the following: –
– a) Reboot the system. – OR – –
– b) Do the following: –
– (i) Ensure that the environment variables are set by performing –
– the following action: –
– - Logout and login –
– (ii) Start the Dialogic(R) system services manually using the –
– dlstart script found in /usr/dialogic/bin. –
– (2) Configure an appropriate license (higher density) via SNMP or CLI –
– (3) If you are using PSTN, refer documentation on how to configure –
– PSTN via SNMP or CLI –



Let me quote Arjan’s request

If you don’t use the quote or the code block features it will be hard to say which part of your message your thought and which one is an output so we will be lost in your question. Right now I don’t have time to figure it out and fix it.

These steps often create configuration files that you can copy into the image and install softwares in a noninteractive way. In case of a debian based system there is ARG DEBIAN_FRONTEND=noninteractive to add to the top of the Dockerfile. I don’t know yum so much so I can’t tell what the alternative is for yum.

Thanks Rimelek, as I am new to this can you please help me in doing so i.e. how to use quote or code block feature, below is Dockerfile.

#base image
FROM centos
RUN mkdir /hmp
WORKDIR /hmp
COPY lnxHMP_4.1_293.tgz /hmp
RUN yum -y update
RUN yum -y install redhat-lsb
RUN yum -y install libstdc++*
RUN yum -y install libstdc++.i686
RUN yum -y install gcc*
#RUN yum -y install yum gcc-c++-4.8.5-16.el7.x86_64
RUN tar -zxvf lnxHMP_4.1_293.tgz
RUN yum -y install bc
RUN yum -y install perl
#RUN yum -y redhat-lsb
#COPY install.sh /hmp
#RUN yum -y install bc
RUN chmod +x ./install.sh
CMD ./install.sh

Just use the buttons above the text area. You can play with the buttons before sending the message, but @avbentem wrote an example for you before. I could not quote that properly so please, scroll back to see it.

I am sure you will recognize the quote button which is next to the code block: </>. Select the text and use a button.

I also edited your last comment. You can try to edit it again and see the difference

Getting exception as below.
[centos@ip-172-31-90-196 ~]$ docker build -t hmp .
Sending build context to Docker daemon 244.3MB
Error response from daemon: dockerfile parse error line 1: unknown instruction: ```


Dockerfile (added backtick ``` start and end of Docker file)

#base image
FROM centos
RUN mkdir /hmp
WORKDIR /hmp
COPY lnxHMP_4.1_293.tgz /hmp
RUN yum -y update
RUN yum -y install redhat-lsb
RUN yum -y install libstdc++*
RUN yum -y install libstdc++.i686
RUN yum -y install gcc*
#RUN yum -y install yum gcc-c++-4.8.5-16.el7.x86_64
RUN tar -zxvf lnxHMP_4.1_293.tgz
RUN yum -y install bc
RUN yum -y install perl
#RUN yum -y redhat-lsb
#COPY install.sh /hmp
#RUN yum -y install bc
RUN chmod +x ./install.sh
CMD ./install.sh

Why did you add it to the actual Dockerfile? It is just for formatting/highlighting the code on the forum.

ohh!! reverted back in actual Dockerfile.
but remain one question mark what is alternative for “ARG DEBIAN_FRONTEND=noninteractive” in yum as software installation is asking for inputs in terms of press ENTER and yes/no.

I finally have time to give more attention to you question. The first problem I did not notice before is that you use the installer script as a container command. You also pass -it to docker run which means you will get an interactive terminal. Since you have an interactive terminal it is not surprising that you are asked to decide what you want. Is there any serious reason why you run the installer when the container starts instead of installing everything during the image build process? Did you do this because it didn’t work otherwise?

yes, basically main reason for using it(interactive) was to check regarding exception wile running container.

I guess Dialogic HMP does not meant to be installed in a Docker container. Searching for “Dialogic hmp Docker” I found a document about installing Dialogix XMS (not HMP) in a Docker konténer but that document refers to a docker image which is 6 years old.

I don’t know what the install.sh does so I can’t tell you how to do it right. After a very quick research It seems to me the HMP installer uses an RPM package. Am I right? So you need to find out how to install a package like that non-interactively. I would help you more if I had more time but I am a little busy until the weekend.

Even if you can figure it out, I am not sure this software will work inside the container.

  1. I think HMP can be containerized as installation and implementation is not complex.
  2. install.sh will install hmp which is basically used for media processing.
  3. Yes, HMP installer uses an RPM package. Till some extent we are able to containerize HMP now only need focus on non-interactive part means how to proceed for providing inputs once install.sh is initiated for more clarity I am re-iterating below.
    – install.sh -->press enter for packages → enter input 1 → enter input q/quit → enter input y/yes → enter input y/yes → enter input n/no → enter input n/no
    with above process we are done.

I don’t know what is in the install.sh so but I searched for “yum install rpm” and realised you need rpm to install and rpm package. and rpm doesn’t support installing non-interactively. Since you already know what the questiones are, you can try to send thet to the standard input of the rpm command. You can find examples on Google’s first page after searching for “rpm non-interactive”. One of those is:

yes | rpm ...

Where yes is a command repeatadly sending “y” to the standard output. If you need to send “n” or “q” you can try something like:

echo -e "n\ny\nq" | rpm ...

I am not sure it will work but you can try if haven’t solved it yet

I suspect the “interactive” part is not comming from the rpms’s but rather from the install.sh itself.

I wouldn’t be surprrised if the releveant commands could be taken straight from the install.sh script and diretly executed in a RUN statement instead. It doesn’t make sense to me to have interactive parts in an automated approach.

I tried those command in Docker build file but it’s not working…
do i need to mention these command during container run process?
yes | rpm …
echo -e “n\ny\nq” | rpm …

If you can’t share what is inside the install.sh I don’t have more ideas. We could try to guess more but we have no way to know if it is the right way without seeing the current commands.

For example @meyay could be right

Check if it is the case.

I agree. This is why I asked it earlier:

Here with I m sharing script file (install.sh) content as uploading .sh file is giving me exception that new user can’t do that.

#!/bin/bash
#:set ts=3
#
######################################################################
#
# Top-Level script to install Dialogic(R) Redistributable
# Runtime and Software Development Kit for Linux
#
# Copyright (C) 2002-2014 Dialogic Corporation.  All Rights Reserved.
#
# All names, products, and services mentioned herein are the
# trademarks or registered trademarks of their respective
# organizations and are the sole property of their respective
# owners.
#
######################################################################

#Using the buildinfo file determine what type of platform
#i.e hmp or tvl2
tplatform=`awk  '/Major Number/ {print $6}' buildinfo`
trel=`awk  '/Release Minor Number/ {print $6}' buildinfo`
tsubrel=`awk  '/Release SubMinor Number/ {print $6}'  buildinfo`

# Release-specific definitions

BUS=""
FAMILY="Dialogic(R)"
MAINTREL=""
RELNUM=$trel
SUBRELNUM=$tsubrel
RELNAME=""
UPDATE=""
PLATFORM="`echo ${tplatform} | tr '[a-z]' '[A-Z]'`"

SNMPORT=""
CLIPORT=""
TOPSILENT=0
RUNTIME_SUCCESSFUL=0

#Specific to TVL
amcBusIfName=""
amcBusMac=""
amcIpAddr=""
amcNetMask=""
HpetEnabled=0

#########################################################################
#Determine the platform either by
#looking at the Major Number in the top buildinfo file.
#########################################################################
setplatformType()
{
        if [ "$tplatform" = "tvl2" ] || [ "$tplatform" = "ovl" ]
        then
                RELNAME="Multimedia Software Release ${RELNUM} for AdvancedTCA";
        elif [ "$tplatform" = "zvl" ]
        then
                RELNAME="Multimedia Kit Software Release ${RELNUM} for PCIe";
        elif [ "$tplatform" = "hmp" ] && [ "$tsubrel" = "-1" ]
        then
                RELNAME="HMP Software Release ${RELNUM}LIN";
        else
                RELNAME="${RELNUM}.${SUBRELNUM}LIN";
        fi
}

#########################################################################
#    Process command line. Check for silent install. If requested,
#########################################################################
process_cmd_line()
{
        if [ $# -gt 0 ]
        then
                if [ "$1" == "--silent" ]
                then
                        TOPSILENT=1
                fi
        fi
}

checkSharedMemory()
{
    SHARED_MAX_BYTE=`more /proc/sys/kernel/shmmax`
    if [ $(echo " ${SHARED_MAX_BYTE} < 65536000" | bc) -eq 1 ]
    then
        SHARED_MAX_MEG=`echo $SHARED_MAX_BYTE 1024000 | awk '{print $1/$2}'`
        echo
        echo "Warning: The shared memory limit on this system is currently set to $SHARED_MAX_MEG MB."
        echo "In order to be able to run more than 120 instances of a single resource"
        echo "type, you will need to increase the shared memory maximum (kernel.shmmax)"
        echo "in /etc/sysctl.conf to 64 MB or more."
        echo
        echo -e "Press ENTER to continue\c"

        read _ANS
    fi
}

islibstdcplplInstalled()
{
    # rpm --queryformat='%{NAME}-%{VERSION}-%{RELEASE}.%{arch}\n' -qa | grep ^libstdc | grep "i686\|i586\|i386\|32-\{0,1\}bit"
    # check if 32bit compatible libstdc++ library is in 32bit library directory
    if ! ls /usr/lib/libstdc++* &> /dev/null
    then
        echo "The 32-bit libstdc++ library, required by HMP, was not found."
        echo "Please correct the issue before attempting HMP installation again."
        exit 1
    fi
}

#########################################################################
# Parse the output of dmesg utility.
# looks for "Using *** HPET"
# example of mesg output: demsg | grep -i hpet
# ACPI: HPET (v001 INTEL  S5000PAL 0x00000001 INTL 0x01000013) @ 0x7fb2e000
# ACPI: HPET id: 0x8086a201 base: 0xfed00000
# hpet0: at MMIO 0xfed00000 (virtual 0xf8800000), IRQs 2, 8, 0
# hpet0: 3 64-bit timers, 14318180 Hz
# Using HPET for base-timer
# hpet_resources: 0xfed00000 is busy
# Time: hpet clocksource has been installed.
#########################################################################
isHpetEnabled()
{
        # warning on HPET enabled
        hpetFound=`dmesg |grep -i hpet 2>&1| perl -e 'my $line; while (<>) { $line = $_; if ($line =~ m/Using(\p{isSpace}*[^\p{isSpace}]*\p{isSpace}*)*hpet/i){print "Found HPET"; last;}}'`
        if [ ! "${hpetFound}" = "" ]
        then
            HpetEnabled=1
            echo "WARNING: Detected that HPET is used as time source"
            echo "WARNING: HPET may be enabled. It is recommended to disable the HPET when running HMP"
            echo "WARNING:"
        fi
}

#########################################################################
#    Get AMC Informatino from hwconf and ifconfig.
#########################################################################
getAMCInformation()
{

AMCPCIBUSID=`awk  ' /ParamValue/ ' /usr/dialogic/cfg/mitconfig/ipms_pcibus_map_cfg.xml \
           | sed -ne 's/<ParamValue>\([0-9]*\)<\/ParamValue>/\1/p' | \
           awk 'BEGIN{ln=0; BMI_EXTIF_TBL_BUSID=8; IPMS_EXT_IF_TYPE_FABRIC_RTM=4 };
                      { ln++; if ( ln == BMI_EXTIF_TBL_BUSID  && $1 == IPMS_EXT_IF_TYPE_FABRIC_RTM ) {print busId}; busId=$1  }' `


#amcBusIdLine=`awk  ' /class:\s*/  { if( $2 == "NETWORK") { devcls=$2 } }
#       /device:\s*/ { if( devcls=="NETWORK") { devname=$2 }  }
#       /network.hwaddr:\s*/ { if (devcls=="NETWORK") {devMac=$2} }
#       /pcibus:\s*/ {if (devcls=="NETWORK")
#       { devBus=$2;
#         printf ("devBusId=%d:devName=%s:mac=%s\n",devBus,devname, devMac);
#         devcls="";} } ' /etc/sysconfig/hwconf | awk '/devBusId='$AMCPCIBUSID'/ {print $1}' `


amcBusIfName=`awk  ' /class:\s*/  { if( $2 == "NETWORK") { devcls=$2 } }
        /device:\s*/ { if( devcls=="NETWORK") { devname=$2 }  }
        /network.hwaddr:\s*/ { if (devcls=="NETWORK") {devMac=$2} }
        /pcibus:\s*/ {if (devcls=="NETWORK") {devBus=$2} }
        /pcifn:\s*/ { pcifn =$2; if ( (devcls=="NETWORK") && (pcifn==0) )
        { printf ("devBusId=%d:devName=%s:mac=%s\n",devBus,devname, devMac);
          devcls="";} } ' /etc/sysconfig/hwconf | awk '/devBusId='$AMCPCIBUSID'/ {print $1}' | sed -ne 's/.*devName\=\([a-zA-Z0-9]*\).*$/\1/p' `


if [ -z "$amcBusIfName" ]
then
        return 1
fi


amcBusMac=`awk  ' /class:\s*/  { if( $2 == "NETWORK") { devcls=$2 } }
        /device:\s*/ { if( devcls=="NETWORK") { devname=$2 }  }
        /network.hwaddr:\s*/ { if (devcls=="NETWORK") {devMac=$2} }
        /pcibus:\s*/ {if (devcls=="NETWORK") {devBus=$2} }
        /pcifn:\s*/ { pcifn =$2; if ( (devcls=="NETWORK") && (pcifn==0) )
        { printf ("devBusId=%d:devName=%s:mac=%s\n",devBus,devname, devMac);
          devcls="";} } ' \
 /etc/sysconfig/hwconf | awk '/devBusId='$AMCPCIBUSID'/ {print $1}' | sed -ne 's/.*mac\=\(\([a-zA-Z0-9]\{2\}:\)\{5\}[a-zA-Z0-9]\{2\}\).*$/\1/p' `



ifd=`/sbin/ifconfig $amcBusIfName`

if [ -z "$ifd" ]
then
        return 2
else
        amcIpAddr=`/sbin/ifconfig $amcBusIfName | sed -ne 's/.*inet addr:\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*$/\1/p' `
        amcNetMask=`/sbin/ifconfig $amcBusIfName | sed -ne 's/.*Mask:\(\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}\).*$/\1/p' `
fi

        return 0
}

#########################################################################
#    Execute additional install steps.
#########################################################################
ExecuteAdditionalInstallation()
{

if [ "$PLATFORM" = "HMP" ] && [ "$RELNUM" = "3.1" ] ||
        [ "$RELNUM" = "4.1" ] && [ "$PLATFORM" = "HMP"  ] ||
        [ "$PLATFORM" = "OVL" ] ||
        [ "$PLATFORM" = "TVL2" ] ||
        [ "$PLATFORM" = "ZVL" ] &&
        [ $TOPSILENT -eq 0 ] &&
        [ ${RUNTIME_SUCCESSFUL} -eq 0 ]
then
        changeAgentPorts

        echo
        echo "Installation of $FULLNAME successfully completed."
        echo
fi

}

##################################################################################
#    Execute additional install steps 1) Tvl2StartUp script for ZVL/OVL/TVL
##################################################################################
ExecuteTvl2StartUpScript()
{

if              [ "$PLATFORM" = "OVL" ] || [ "$PLATFORM" = "TVL2" ] || [ "$PLATFORM" = "ZVL" ] &&
        [ $TOPSILENT -eq 0 ] &&
        [ ${RUNTIME_SUCCESSFUL} -eq 0 ]
then
        TVL2_START="/etc/init.d/tvl2_startup start"
        $TVL2_START
        RC=$?

        echo "Execution of startup script tvl2_startup completed."
        echo
fi

}

##################################################################################
#    Execute additional install steps 2)
#    validate the operation of the /dev/rtc driver on the system.
#    If the test fails, HPET may be enabled. print out warning
##################################################################################
ExecuteRtcDriverTest()
{
        if      [ "$PLATFORM" = "HMP"  ] && [ ${RUNTIME_SUCCESSFUL} -eq 0 ]
        then
            if [ -x /usr/dialogic/bin/rtc_irq_test ]
        then
                    /usr/dialogic/bin/rtc_irq_test &>/dev/null
                RC=$?
                if [ ${RC} -ne 0 ]
            then
                            echo "WARNING: "
                            echo "WARNING: RTC IRQ test failed, The HPET may be enabled."
                            echo "WARNING: It is recommended to disable the HPET when running HMP"
                                echo "WARNING: Please see HMP Software Installation Guide for more information"
                            echo
                        fi
                fi
        fi

}

#########################################################################
#    Get SNMP Agent Listening Port from ct_intel.
#########################################################################
findSnmpAgentPort()
{
        if [ -f /etc/init.d/ct_intel ]
        then
                #SNMPORT=`sed -ne 's/.*-sp\s*\([0-9]*\).*/\1/p ' /etc/init.d/ct_intel`
                SNMPORT=`sed -ne 's/\s*SNMP_LISTENER\s*=\s*\([0-9]*\)/\1/p' /etc/init.d/ct_intel`
        else
                SNMPORT="161"
        fi
}

#########################################################################
#    Get CLI Agent Listening Port from ct_intel.
#########################################################################
findCliAgentPort()
{
        if [ -f /etc/init.d/ct_intel ]
        then
                #CLIPORT=`sed -ne 's/.*-ct\s*\([0-9]*\).*/\1/p ' /etc/init.d/ct_intel`
                CLIPORT=`sed -ne 's/\s*CLI_LISTENER\s*=\s*\([0-9]*\)/\1/p' /etc/init.d/ct_intel`
        else
                CLIPORT="23"
        fi
}



#########################################################################
#    Change Agent Listening Port in ct_intel.
#########################################################################
changeAgentPorts()
{
        validPort=""
        findSnmpAgentPort
        echo -ne "Do you wish to configure the SNMP Agent Listening Port (default is $SNMPORT) [y/n] ? \c"
        read line
        resp=`echo ${line} | tr '[A-Z]' '[a-z]' | cut -c1`
        #if [ -z "${resp}" ] || [ "${resp}" = "y" ]
        if [ -z "${resp}" ]
        then
                echo "SNMP port $SNMPORT accepted."
        elif [ "${resp}" = "y" ]
        then
                wexit=0
                while [ $wexit = 0 ]
                do
                        echo -ne "Please Enter SNMP Agent Listening Port? \c"
                        read port
                        validPort=`echo $port | sed -ne 's/^\([0-9]*\)$/\1/p' `
                        if [ -n "$validPort" ]
                        then
                                #if [ -n "$validPort" ] && [ "$port" -lt 32767 ]
                                if [ "$port" -lt 32767 ]
                                then
                                        #sed 's/-sp *[0-9]*/-sp '$port'/' /etc/init.d/ct_intel > footmp
                                        sed 's/SNMP_LISTENER\s*=\s*[0-9]*/SNMP_LISTENER='$port'/' /etc/init.d/ct_intel > /tmp/footmp
                                        mv /tmp/footmp /etc/init.d/ct_intel
                                        chmod 500 /etc/init.d/ct_intel > /dev/null
                                        SNMPORT=$port
                                        echo "SNMP port $port accepted."
                                        wexit=1
                                else
                                        echo "Invalid Port: port exceeds range."
                                fi
                        else
                                echo "Invalid Port: must be numeric."
                        fi
                done
        fi

        findCliAgentPort
        echo -ne "Do you wish to configure the CLI Agent Telnet Port (default is $CLIPORT) [y/n] ? \c"
        read line
        resp=`echo ${line} | tr '[A-Z]' '[a-z]' | cut -c1`
        #if [ -z "${resp}" ] || [ "${resp}" = "y" ]
        if [ -z "${resp}" ]
        then
                echo "CLI port $CLIPORT accepted."
        elif [ "${resp}" = "y" ]
        then
                wexit=0;
                while [ $wexit = 0 ]
                do
                        echo -ne "Please Enter CLI Agent Telnet Port? \c"
                        read port

                        validPort=`echo $port | sed -ne 's/^\([0-9]*\)$/\1/p' `
                        if [ -n "$validPort" ]
                        then
                                if [ "$port" -eq "$SNMPORT" ]
                                then
                                        echo "Invalid Port: Same as SNMP Agent Port...choose a different port."
                                #elif [ "$validPort" ] && [ "$port" -lt 32767 ]
                                elif  [ "$port" -lt 32767 ]
                                then
                                        sed 's/CLI_LISTENER\s*=\s*[0-9]*/CLI_LISTENER='$port'/' /etc/init.d/ct_intel > /tmp/footmp
                                        mv /tmp/footmp /etc/init.d/ct_intel
                                        chmod 500 /etc/init.d/ct_intel > /dev/null
                                        echo "CLI port $port accepted."
                                        wexit=1
                                else
                                        echo "Invalid Port: exceeds port range"
                                fi
                        else
                                echo "Invalid Port: must be numeric"
                        fi
                done
        fi
}

#########################################################################
#    Install Runtime Packages.
#########################################################################
installRuntime()
{
cd redistributable-runtime

echo
echo "Installing ${FULLNAME}"
echo "Redistributable Runtime"
echo "Please wait, installation is in progress..."
echo

RET=0
if [ -x ./install.sh ]
then
        if [ "$PLATFORM" == "TVL2" ] || [ "$PLATFORM" == "OVL" ]
        then
                ./install.sh --silent ALL
                RET=$?
        else
                #./install.sh
                #Added by J. Cruz for silent install to work
                ./install.sh $*
                RET=$?
        fi

else
        echo
        echo "ERROR: install.sh not found in the redistributable-runtime directory".
        echo
        RET=1
fi

RUNTIME_SUCCESSFUL=${RET}

if [ ${RET} -eq 0 ]
then
        if [ "$PLATFORM" != "TVL2" ] || [ "$PLATFORM" != "OVL" ]
        then
                echo
                echo "Installation of ${FULLNAME} Redistributable Runtime was successful."
                echo
        fi
elif    [ ${RET} -eq 1 ]
then
        echo
        echo "An error occurred while installing the Redistributable Runtime"
        echo "Software.  Aborting installation of the Software Development"
        echo "Kit."
        echo
        exit 1
elif    [ ${RET} -eq 2 ]
then
        echo "Based on your selection no runtime packages were installed."
elif    [ ${RET} -eq 3 ]
then
        echo
        echo "Installation of the Redistributable Runtime Software"
        echo "failed due to lack of required disk space. Please"
        echo "free up some disk space and re-run $0 again."
        echo "Aborting installation of the Software Development Kit."
        echo
        exit 3
fi


cd ..
}


#########################################################################
#    Install SDK Package.
#########################################################################
installSdk()
{
# Prompt the user about installing the SDK
if [ "$PLATFORM" == "TVL2" ] || [ "$PLATFORM" == "OVL" ]
then
        RET=0
        if [ -x ./install.sh ]
        then
                cd sdk
                #./install.sh
                #Added by J. Cruz for silent install to work
                #It looks like the sdk silent install does not obey
                #./install.sh --silent
                ./install.sh --silent
                RET=$?
        else
                echo
                echo "ERROR: SDK install.sh not found in the sdk directory".
                echo
                RET=1
        fi

        if [ ${RET} -eq 0 ]
        then
                echo
        else
                echo
                echo "An error occurred while installing the Software Development Kit."
                echo
                exit 1
        fi
        cd ..
else
        echo
        echo -ne "Do you wish to install the Software Development Kit [y/n] ? \c"
        read line
        resp=`echo ${line} | tr '[A-Z]' '[a-z]' | cut -c1`
        if [ -z "${resp}" ] || [ "${resp}" = "y" ]
        then
                # must install sdk after redistributable-runtime to avoid file
                # conflicts with any previously existing RPM's.

                cd sdk

                echo
                echo "Installing ${FULLNAME} Software Development Kit"
                echo

                RET=0
                if [ -x ./install.sh ]
                then
                        #./install.sh
                        #Added by J. Cruz for silent install to work
                        #It looks like the sdk silent install does not obey
                        ./install.sh $*
                        RET=$?
                else
                        echo
                        echo "ERROR: install.sh not found in the sdk directory".
                        echo

                        RET=1
                fi

                if [ ${RET} -eq 0 ]
                then
                        echo
                        echo "Installation of ${FULLNAME} Software Development Kit was successful."
                        echo
                else
                        echo
                        echo "An error occurred while installing the Software Development Kit."
                        echo
                        exit 1
                fi
                cd ..
        elif [ -z "${resp}" ] || [ "${resp}" = "n" ]
        then
                echo
                echo "Installation of the Software Development Kit was skipped."
                echo
        fi
fi
}

#########################################################################
#    Install Demo Package.
#########################################################################
installDemo()
{
# Optional demo package
        echo
        echo -ne "Do you wish to install the Software Demo Kit [y/n] ? \c"
        read line
        resp=`echo ${line} | tr '[A-Z]' '[a-z]' | cut -c1`
        if [ -z "${resp}" ] || [ "${resp}" = "y" ]
        then
                cd demo

                echo
                echo "Installing ${FULLNAME} Software Demo Kit"
                echo

                RET=0
                if [ -x ./install.sh ]
                then
                        ./install.sh $*
                        RET=$?
                else
                        echo
                        echo "ERROR: install.sh not found in the demos directory".
                        echo
                        RET=1
                fi

                if [ ${RET} -eq 0 ]
                then
                        echo
                        echo "Installation of ${FULLNAME} Software Demo Kit was successful."
                        echo
                else
                        echo
                        echo "An error occurred while installing the Software Demo Kit."
                        echo
                        exit 1
                fi
                cd ..
        elif [ -z "${resp}" ] || [ "${resp}" = "n" ]
        then
                echo
                echo "Installation of the Software Demo Kit was skipped."
                echo
        fi
}

#########################################################################
#    Install Media Server Language Prompts Package.
#########################################################################
installMediaServerPrompts()
{
    # only install on HMP4.1 Redhat
    if [ "$PLATFORM" = "HMP" ] && [ "${RELNUM}" = "4.1" ]
    then
        # only for Redhat
        OS=`uname -s`

        if [ "${OS}" = "Linux" ] && [ -f /etc/redhat-release ]
        then
            #  DIST='RedHat'
            # check if media_server_prompts directory and media prompt files exist
            if [ -d media_server_prompts ] && [ -f media_server_prompts/*.rpm ]
            then
                cd media_server_prompts
                echo
                echo "Installing media server prompt package"
                rpm -ivh *.rpm
                cd ..
                echo
            fi
        fi
    fi
}

######################################################################
# Display User Notice
#
######################################################################
displayNotice()
{
if [ ${RUNTIME_SUCCESSFUL} = 0 ]
then
        if [ "$PLATFORM" = "HMP" ] && [ "${RELNUM}" = "3.1" ]
        then
                echo "----------------------------------------------------------------------------"
                echo "--                                                                        --"
                echo "-- NOTE:                                                                  --"
                echo "-- (1) The default Verification License has been automatically installed. --"
                echo "-- (2) The Dialogic(R) system services will automatically start           --"
                echo "--     every time the system is rebooted. To start and stop system        --"
                echo "--     services manually, use the dlstop and dlstart scripts found in     --"
                echo "--     /usr/dialogic/bin.                                                 --"
                echo "-- (3) For administration via SNMP, use any SNMP browser, library or tools--"
                echo "-- (4) For administration via CLI, use the telnet command                 --"
                echo "-- (5) For details, refer to documentation                                --"
                echo "--                                                                        --"
                echo "-- NEXT STEPS:                                                            --"
                echo "-- You need to do the following before using the product:                 --"
                echo "-- (1) Before using the software, you must also ensure that the           --"
                echo "--     environment variables are set by performing the following action:  --"
                echo "--     - Logout and login                                                 --"
                echo "-- (2) The Dialogic(R) system services must be started. To start system   --"
                echo "--     services manually, use the dlstart script found in                 --"
                echo "--     /usr/dialogic/bin.                                                 --"
                echo "-- (3) Configure an appropriate license (higher density) via SNMP or CLI  --"
                echo "--                                                                        --"
                echo "----------------------------------------------------------------------------"
        elif [ "$PLATFORM" = "TVL2" ] || [ "$PLATFORM" == "OVL" ] || [ "$PLATFORM" = "ZVL" ]
        then
                # Notice that config.sh is not executed...
                echo "----------------------------------------------------------------------------"
                echo "--                                                                        --"
                echo "-- NOTE:                                                                  --"
                echo "--                                                                        --"
                echo "-- (1) The default Verification License has been automatically installed. --"
                echo "-- (2) The Dialogic(R) system services will automatically start every     --"
                echo "--     time the system is rebooted. To start and stop system services     --"
                echo "--     manually, use the dlstop and dlstart scripts found in              --"
                echo "--     /usr/dialogic/bin.                                                 --"
                echo "-- (3) For administration via SNMP, use any SNMP browser, library or tools--"
                echo "-- (4) For administration via CLI, use the telnet command                 --"
                echo "-- (5) For details, refer to documentation                                --"
                echo "--                                                                        --"
                echo "-- NEXT STEPS:                                                            --"
                echo "-- (1) Before using the software, you MUST do one of the following:       --"
                echo "--     a) Reboot the system.      -- OR --                                --"
                echo "--     b) Do the following:                                               --"
                echo "--        (i) Ensure that the environment variables are set by performing --"
                echo "--            the following action:                                       --"
                echo "--            - Logout and login                                          --"
                #echo "--        (ii) Manually run the required startup script                  --"
                #echo "--            - /etc/init.d/tvl2_startup start                           --"
                echo "--        (ii) Start the Dialogic(R) system services manually using the   --"
                echo "--             dlstart script found in /usr/dialogic/bin.                 --"
                echo "-- (2) Configure your network                                             --"
                echo "-- (3) Configure an appropriate license (higher density) via SNMP or CLI  --"
                echo "-- (4) Configure the Media Ethernet Interfaces via SNMP or CLI            --"
                echo "-- (5) Ensure that the MMA board interface IP address and DSP IP          --"
                echo "--     addresses are on same sub-net via SNMP or CLI                      --"
                echo "-- (6) If you are using PSTN, refer documentation on how to configure     --"
                echo "--     PSTN via SNMP or CLI                                               --"
                echo "--                                                                        --"
                echo "----------------------------------------------------------------------------"
        elif [ "$PLATFORM" = "HMP" ] && [ "${RELNUM}" = "4.1" ]
        then
                # Notice that config.sh is not executed...
                echo "----------------------------------------------------------------------------"
                echo "--                                                                        --"
                echo "-- NOTE:                                                                  --"
                echo "--                                                                        --"
                echo "-- (1) The default Verification License has been automatically installed. --"
                echo "-- (2) The Dialogic(R) system services will automatically start every     --"
                echo "--     time the system is rebooted. To start and stop system services     --"
                echo "--     manually, use the dlstop and dlstart scripts found in              --"
                echo "--     /usr/dialogic/bin.                                                 --"
                echo "-- (3) For administration via SNMP, use any SNMP browser, library or tools--"
                echo "-- (4) For administration via CLI, use the telnet command                 --"
                echo "-- (5) For details, refer to documentation                                --"
                echo "--                                                                        --"
                echo "-- NEXT STEPS:                                                            --"
                echo "-- (1) Before using the software, you MUST do one of the following:       --"
                echo "--     a) Reboot the system.      -- OR --                                --"
                echo "--     b) Do the following:                                               --"
                echo "--        (i) Ensure that the environment variables are set by performing --"
                echo "--            the following action:                                       --"
                echo "--            - Logout and login                                          --"
                echo "--        (ii) Start the Dialogic(R) system services manually using the   --"
                echo "--             dlstart script found in /usr/dialogic/bin.                 --"
                echo "-- (2) Configure an appropriate license (higher density) via SNMP or CLI  --"
                echo "-- (3) If you are using PSTN, refer documentation on how to configure     --"
                echo "--     PSTN via SNMP or CLI                                               --"
                echo "--                                                                        --"
                echo "----------------------------------------------------------------------------"
        fi
fi
}





##########################################
# START OF SCRIPT
# MAIN
##########################################
setplatformType
process_cmd_line $*

if [ -z "${UPDATE}" ]
then
        FULLNAME="${FAMILY} ${RELNAME}"
else
        FULLNAME="${FAMILY} ${RELNAME} ${UPDATE}"
fi

checkSharedMemory
islibstdcplplInstalled
isHpetEnabled
installRuntime
if [ ${RUNTIME_SUCCESSFUL} -eq 0 ]
then
    installMediaServerPrompts
    installSdk
    installDemo
    ExecuteAdditionalInstallation
    ExecuteTvl2StartUpScript
    if [ ${HpetEnabled} -eq 0 ]
    then
            ExecuteRtcDriverTest
    fi
    displayNotice
fi
exit 0

#END oF MAIN SCRIPT