0

Basically I am going to have a whole bunch of ubuntu containers that are going to have ossec agent installed that will communicate with a main server. I want to automate the installation so using the docker RUN variable in the dockerfile I wrote a script that downloads the ossec tar file, unpacks it, cds into directory and runs the install script while passing arguments to each question of the installation phase:

Dockerfile:

From ubuntu

RUN apt-get update && apt-get install -y \
    build-essential \
    libmysqlclient-dev \
    postgresql-common \
    wget \
    tar \

RUN wget -U ossec https://bintray.com/artifact/download/ossec/ossec-hids/ossec-hids-2.8.3.tar.gz
RUN tar -xvf ossec-hids-2.8.3.gz && \
    rm -f ossec-hids-2.8.3.tar.gz && \
    cd ossec-hids-2.8.3 && \
    echo "en agent \n 192.168.1.50 y y y" | ./install.sh

When it echos in the arguments into the script, the install.sh script falls and loops over the second question infinitely. Note I have tried printf, expect script, yes command and tried the script inside the container. All with the same outcome.

TecGuy94
  • 49
  • 1
  • 8
  • You haven't included the most important part of your problem. How is `install.sh` processing its std-in input? Also, verbal descriptions of problems are almost always too vague for readers. Include the exact text of error messages or other output of your script in the body of your Q above. You might figure out the source of your problem by adding `set -x` near the top of your `install.sh`. It will display each line that is processed with the actual values of any variables that are mentioned in the code. Good luck. – shellter Sep 30 '19 at 15:35
  • AND we don't need to see your whole install script. Try to reduce the problem to 3-5 testable lines of code that produce the same result. (comment out almost everything inside any loops, and restore line by line until you get your error. Maybe you can figure it out then, else **then** post the smallest code possible to reproduce the problem). Good luck! – shellter Sep 30 '19 at 15:42
  • The install.sh is a script provided by a third party https://www.ossec.net/ The install.sh has 1250 lines of code. Thanks ill add that and try and debug the problem – TecGuy94 Oct 01 '19 at 08:50
  • Try your `echo "en agent \n 192.168.1.50 y y y"` by itself on the command line. Does the `\n` work as you expect? (Not sure it will). You may need `echo -e` And I would expect you need `\n`'s for all the inputs. But it sounds like you may have tried that too. On the matter of debugging, I'm wondering if `tar ... && .. &&...&& echo ... | bash -x ./install.sh` would work for your testing. Good luck. – shellter Oct 01 '19 at 13:27

0 Answers0