apt update
apt upgrade
#download thingsboard-gateway
wget https://github.com/thingsboard/thingsboard-gateway/releases/latest/download/python3-thingsboard-gateway.deb
apt install ./python3-thingsboard-gateway.deb -y
systemctl status thingsboard-gateway
#stop thingsboard-gateway
systemctl stop thingsboard-gateway

#download ethernetip extension
curl -H 'Authorization: token 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' \
  -H 'Accept: application/vnd.github.v3.raw' \
  -O \
  -L https://github.com/Henry-Pump/ThingsBoard/raw/main/Thingsboard%20Gateway/ethernetip_converter.py

curl -H 'Authorization: token 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' \
  -H 'Accept: application/vnd.github.v3.raw' \
  -O \
  -L https://github.com/Henry-Pump/ThingsBoard/raw/main/Thingsboard%20Gateway/ethernetip_connector.py

curl -H 'Authorization: token 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' \
  -H 'Accept: application/vnd.github.v3.raw' \
  -O \
  -L https://github.com/Henry-Pump/ThingsBoard/raw/main/Thingsboard%20Gateway/ethernetip.json

curl -H 'Authorization: token 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' \
  -H 'Accept: application/vnd.github.v3.raw' \
  -O \
  -L https://github.com/Henry-Pump/ThingsBoard/raw/main/Thingsboard%20Gateway/tb_gateway.yaml?token=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

wget https://hp-thingsboard.s3.amazonaws.com/ethernetip_connector.py
wget https://hp-thingsboard.s3.amazonaws.com/ethernetip_converter.py
wget https://hp-thingsboard.s3.amazonaws.com/ethernetip.json
wget https://hp-thingsboard.s3.amazonaws.com/tb_gateway.yaml


#move to proper location
mkdir /var/lib/thingsboard_gateway/extensions/ethernetip
mv ethernetip_converter.py /var/lib/thingsboard_gateway/extensions/ethernetip
mv ethernetip_connector.py /var/lib/thingsboard_gateway/extensions/ethernetip

mv tb_gateway.yaml /etc/thingsboard-gateway/config
mv ethernetip.json /etc/thingsboard-gateway/config

#install pycomm3 for thingsboard
sudo pip3  install --target=/usr/lib/python3/dist-packages pycomm3


systemctl start thingsboard-gateway
rm installtbg.sh python3-thingsboard-gateway.deb