diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..3733d91d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM ubuntu:18.04 + +RUN apt-get update && apt-get install -y build-essential pkg-config bison flex autoconf automake libtool make git python2.7 python-pip sqlite3 cmake git +RUN pip install flask flask-login pyserial +COPY . /workdir +RUN cd /workdir && ./install.sh docker +WORKDIR /workdir +ENTRYPOINT ["./start_openplc.sh"] diff --git a/install.sh b/install.sh index f820e2c8..cf67bcd3 100755 --- a/install.sh +++ b/install.sh @@ -220,6 +220,88 @@ WantedBy=multi-user.target" >> openplc.service cp ./start_openplc.sh ../../ +elif [ "$1" == "docker" ]; then + echo "Installing OpenPLC on Linux inside Docker" + + echo "" + echo "[MATIEC COMPILER]" + cd utils/matiec_src + autoreconf -i + ./configure + make + cp ./iec2c ../../webserver/ + if [ $? -ne 0 ]; then + echo "Error compiling MatIEC" + echo "OpenPLC was NOT installed!" + exit 1 + fi + cd ../.. + + echo "" + echo "[ST OPTIMIZER]" + cd utils/st_optimizer_src + g++ st_optimizer.cpp -o st_optimizer + cp ./st_optimizer ../../webserver/ + if [ $? -ne 0 ]; then + echo "Error compiling ST Optimizer" + echo "OpenPLC was NOT installed!" + exit 1 + fi + cd ../.. + + echo "" + echo "[GLUE GENERATOR]" + cd utils/glue_generator_src + g++ glue_generator.cpp -o glue_generator + cp ./glue_generator ../../webserver/core + if [ $? -ne 0 ]; then + echo "Error compiling Glue Generator" + echo "OpenPLC was NOT installed!" + exit 1 + fi + cd ../.. + + echo "" + echo "[OPEN DNP3]" + cd utils/dnp3_src + echo "creating swapfile..." + dd if=/dev/zero of=swapfile bs=1M count=1000 + mkswap swapfile + swapon swapfile + cmake ../dnp3_src + make + make install + if [ $? -ne 0 ]; then + echo "Error installing OpenDNP3" + echo "OpenPLC was NOT installed!" + exit 1 + fi + ldconfig + echo "removing swapfile..." + swapoff swapfile + rm -f ./swapfile + cd ../.. + + echo "" + echo "[LIBMODBUS]" + cd utils/libmodbus_src + ./autogen.sh + ./configure + make install + if [ $? -ne 0 ]; then + echo "Error installing Libmodbus" + echo "OpenPLC was NOT installed!" + exit 1 + fi + ldconfig + cd ../.. + + echo "" + echo "[FINALIZING]" + cd webserver/scripts + ./change_hardware_layer.sh blank_linux + ./compile_program.sh blank_program.st + cp ./start_openplc.sh ../../ elif [ "$1" == "rpi" ]; then echo "Installing OpenPLC on Raspberry Pi"