156 lines
5.4 KiB
Ruby
156 lines
5.4 KiB
Ruby
# -*- mode: ruby -*-
|
|
# vi: set ft=ruby :
|
|
|
|
Vagrant.configure("2") do |config|
|
|
|
|
config.vm.box = "generic/ubuntu1604"
|
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
|
|
|
config.vm.define "simulation" do |simulation|
|
|
simulation.vm.hostname = "simulation"
|
|
simulation.vm.network "private_network", ip: "192.168.95.10"
|
|
|
|
# Dependencies
|
|
simulation.vm.provision "shell", inline: <<-SHELL
|
|
apt-get update
|
|
apt-get install -y libjsoncpp-dev liblapacke-dev python-pymodbus build-essential git apache2 php libapache2-mod-php
|
|
SHELL
|
|
|
|
# Installation
|
|
simulation.vm.provision "shell", privileged: false, inline: <<-SHELL
|
|
git clone https://github.com/Fortiphyd/GRFICSv2
|
|
cd ~/GRFICSv2/simulation_vm/simulation && sudo make
|
|
sudo rm /var/www/html/index.html
|
|
sudo ln -s /home/vagrant/GRFICSv2/simulation_vm/web_visualization/* /var/www/html
|
|
SHELL
|
|
|
|
# Networking
|
|
(0..5).each do |i|
|
|
case i
|
|
when 0
|
|
simulation.vm.provision "shell", inline: <<-SHELL
|
|
ifdown eth1
|
|
sed -i 's/allow-hotplug/auto/' /etc/network/interfaces
|
|
sed -i "s/auto eth1/auto eth1:#{i}/" /etc/network/interfaces
|
|
sed -i "s/iface eth1 inet static/iface eth1:#{i} inet static/" /etc/network/interfaces
|
|
SHELL
|
|
when 1..5
|
|
simulation.vm.provision "shell", inline: <<-SHELL
|
|
echo >> /etc/network/interfaces
|
|
echo auto eth1:#{i} >> /etc/network/interfaces
|
|
echo iface eth1:#{i} inet static >> /etc/network/interfaces
|
|
echo address 192.168.95.1#{i} >> /etc/network/interfaces
|
|
echo netmask 255.255.255.0 >> /etc/network/interfaces
|
|
SHELL
|
|
end
|
|
end
|
|
simulation.vm.provision "shell", inline: <<-SHELL
|
|
systemctl restart networking
|
|
SHELL
|
|
|
|
# Run
|
|
simulation.vm.provision "shell", privileged: false, run: "always", inline: <<-SHELL
|
|
cd ~/GRFICSv2/simulation_vm/simulation
|
|
screen -d -m ./simulation
|
|
cd ~/GRFICSv2/simulation_vm/simulation/remote_io/modbus
|
|
sed -i 's/user/vagrant/' run_all.sh
|
|
screen -d -m sudo bash run_all.sh
|
|
SHELL
|
|
|
|
end
|
|
|
|
config.vm.define "hmi" do |hmi|
|
|
hmi.vm.hostname = "hmi"
|
|
hmi.vm.network "private_network", ip: "192.168.90.5"
|
|
|
|
# Dependencies, Networking
|
|
hmi.vm.provision "shell", inline: <<-SHELL
|
|
apt-get update
|
|
apt-get install -y git
|
|
sed -i 's/allow-hotplug/auto/' /etc/network/interfaces
|
|
sed -i 's/#VAGRANT.*//' /etc/network/interfaces
|
|
sed -i 's/# The contents below.*//' /etc/network/interfaces
|
|
echo up route add -net 192.168.95.0 netmask 255.255.255.0 gw 192.168.90.100 dev eth1 >> /etc/network/interfaces
|
|
systemctl restart networking
|
|
SHELL
|
|
|
|
# Installation
|
|
hmi.vm.provision "shell", privileged: false, inline: <<-SHELL
|
|
git clone https://github.com/ScadaBR/ScadaBR_Installer
|
|
cd ScadaBR_Installer && chmod +x install_scadabr.sh remove_scadabr.sh scadabr.sh
|
|
sudo ./install_scadabr.sh silent
|
|
SHELL
|
|
|
|
# Run
|
|
hmi.vm.provision "shell", privileged: false, run: "always", inline: <<-SHELL
|
|
sudo bash /opt/ScadaBR/scadabr.sh start
|
|
SHELL
|
|
|
|
end
|
|
|
|
config.vm.define "router" do |router|
|
|
router.vm.box = "debian/bookworm64"
|
|
router.vm.hostname = "router"
|
|
router.vm.network "private_network", ip: "192.168.90.100"
|
|
router.vm.network "private_network", ip: "192.168.95.100"
|
|
|
|
router.vm.provision "shell", run: "always", inline: <<-SHELL
|
|
sysctl -w net.ipv4.conf.all.forwarding=1
|
|
SHELL
|
|
|
|
end
|
|
|
|
config.vm.define "plc" do |plc|
|
|
plc.vm.hostname = "plc"
|
|
plc.vm.network "private_network", ip: "192.168.95.2"
|
|
|
|
# Dependencies
|
|
plc.vm.provision "shell", inline: <<-SHELL
|
|
apt-get update
|
|
apt-get install -y build-essential pkg-config bison flex autoconf automake libtool make nodejs git
|
|
SHELL
|
|
|
|
# Installation
|
|
plc.vm.provision "shell", privileged: false, inline: <<-SHELL
|
|
git clone https://github.com/Fortiphyd/GRFICSv2
|
|
cd ~/GRFICSv2/plc_vm/OpenPLC_v2-master
|
|
find -name '*.sh' -exec chmod +x {} \\;
|
|
yes 2 | ./build.sh
|
|
SHELL
|
|
|
|
# Run
|
|
plc.vm.provision "shell", privileged: false, run: "always", inline: <<-SHELL
|
|
cd ~/GRFICSv2/plc_vm/OpenPLC_v2-master
|
|
screen -d -m sudo nodejs server.js
|
|
sleep 2
|
|
curl http://localhost:8080/api/changeModbusCfg -F mbConfig=@mbconfig.cfg
|
|
SHELL
|
|
|
|
end
|
|
|
|
config.vm.define "workstation" do |workstation|
|
|
workstation.vm.hostname = "workstation"
|
|
workstation.vm.network "private_network", ip: "192.168.95.5"
|
|
|
|
# Dependencies, Networking
|
|
workstation.vm.provision "shell", inline: <<-SHELL
|
|
apt-get update
|
|
apt-get install -y python-zeroconf python-lxml python-matplotlib python-pip
|
|
pip2 install six numpy==1.14.6
|
|
sed -i 's/allow-hotplug/auto/' /etc/network/interfaces
|
|
sed -i 's/#VAGRANT.*//' /etc/network/interfaces
|
|
sed -i 's/# The contents below.*//' /etc/network/interfaces
|
|
echo up route add -net 192.168.90.0 netmask 255.255.255.0 gw 192.168.95.100 dev eth1 >> /etc/network/interfaces
|
|
systemctl restart networking
|
|
SHELL
|
|
|
|
# Installation
|
|
workstation.vm.provision "shell", privileged: false, inline: <<-SHELL
|
|
mkdir -p ~/.local/share/applications
|
|
wget https://autonomylogic.com/wp-content/uploads/files/OpenPLC%20Editor%20for%20Linux.zip
|
|
unzip "OpenPLC Editor for Linux.zip"
|
|
cd "OpenPLC_Editor" && sudo ./install.sh
|
|
SHELL
|
|
end
|
|
|
|
end
|