.
Thanks a lot Oliver.
Following your guide line, done using single service file connect@.service
.
STEP-1
abcd@debian:~$ sudo nano /lib/systemd/system/connect@.service
.
Copy-pasted following code
#data pipe service for systemd
[Unit]
Description=%i
Wants=network.target
After=network.target
[Service]
RuntimeDirectory=%i
RuntimeDirectoryMode=0755
ExecStart=/usr/share/connect/tunnel.sh %i
SyslogIdentifier=%i
Type=simple
Restart=on-failure
RestartSec=30
RestartPreventExitStatus=64
Nice=-5
[Install]
WantedBy=default.target
.
STEP-2
sudo mkdir /usr/share/connect
sudo nano /usr/share/connect/tunnel.sh
.
Copy-pasted following code
#!/bin/bash
if [[ $1 == "pi1-adsb" ]]; then /usr/bin/socat -u TCP:192.168.0.21:30005 TCP:localhost:30004
elif [[ $1 == "pi1-mlat" ]]; then /usr/bin/socat -u TCP:192.168.0.21:30105 TCP:localhost:30004
elif [[ $1 == "pi2-adsb" ]]; then /usr/bin/socat -u TCP:192.168.0.22:30005 TCP:localhost:30004
elif [[ $1 == "pi2-mlat" ]]; then /usr/bin/socat -u TCP:192.168.0.22:30105 TCP:localhost:30004
elif [[ $1 == "pi3-adsb" ]]; then /usr/bin/socat -u TCP:192.168.0.23:30005 TCP:localhost:30004
elif [[ $1 == "pi3-mlat" ]]; then /usr/bin/socat -u TCP:192.168.0.23:30105 TCP:localhost:30004
else echo "this pipe is not listed"
fi
.
STEP3
abcd@debian:~$ sudo systemctl enable connect@pi1-adsb.service
abcd@debian:~$ sudo systemctl start connect@pi1-adsb.service
abcd@debian:~$ sudo systemctl enable connect@pi1-mlat.service
abcd@debian:~$ sudo systemctl start connect@pi1-mlat.service
abcd@debian:~$ sudo systemctl enable connect@pi2-adsb.service
abcd@debian:~$ sudo systemctl start connect@pi2-adsb.service
abcd@debian:~$ sudo systemctl enable connect@pi2-mlat.service
abcd@debian:~$ sudo systemctl start connect@pi2-mlat.service
abcd@debian:~$ sudo systemctl enable connect@pi3-adsb.service
abcd@debian:~$ sudo systemctl start connect@pi3-adsb.service
abcd@debian:~$ sudo systemctl enable connect@pi3-mlat.service
abcd@debian:~$ sudo systemctl start connect@pi3-mlat.service
.
STEP-4
abcd@debian:~$ sudo systemctl status connect@pi1-adsb.service
● connect@pi1-adsb.service - pi1-adsb
Loaded: loaded (/lib/systemd/system/connect@.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-09-08 17:05:35 EDT; 19min ago
Main PID: 1395 (tunnel.sh)
Tasks: 2 (limit: 2348)
Memory: 992.0K
CGroup: /system.slice/system-connect.slice/connect@pi1-adsb.service
├─1395 /bin/bash /usr/share/connect/tunnel.sh pi1-adsb
└─1396 /usr/bin/socat -u TCP:192.168.0.21:30005 TCP:localhost:30004
Sep 08 17:05:35 debian systemd[1]: Started pi1-adsb.
Sep 08 17:05:35 debian pi1-adsb[1395]: pi1-adsb
.
abcd@debian:~$ sudo systemctl status connect@pi1-mlat.service
● connect@pi1-mlat.service - pi1-mlat
Loaded: loaded (/lib/systemd/system/connect@.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-09-08 17:05:59 EDT; 19min ago
Main PID: 1410 (tunnel.sh)
Tasks: 2 (limit: 2348)
Memory: 1008.0K
CGroup: /system.slice/system-connect.slice/connect@pi1-mlat.service
├─1410 /bin/bash /usr/share/connect/tunnel.sh pi1-mlat
└─1411 /usr/bin/socat -u TCP:192.168.0.21:30105 TCP:localhost:30004
Sep 08 17:05:59 debian systemd[1]: Started pi1-mlat.
Sep 08 17:05:59 debian pi1-mlat[1410]: pi1-mlat
.
abcd@debian:~$ sudo systemctl status connect@pi2-adsb.service
● connect@pi3-adsb.service - pi2-adsb
Loaded: loaded (/lib/systemd/system/connect@.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-09-08 17:05:48 EDT; 21min ago
Main PID: 1405 (tunnel.sh)
Tasks: 2 (limit: 2348)
Memory: 1000.0K
CGroup: /system.slice/system-connect.slice/connect@pi2-adsb.service
├─1405 /bin/bash /usr/share/connect/tunnel.sh pi2-adsb
└─1406 /usr/bin/socat -u TCP:192.168.0.22:30005 TCP:localhost:30004
Sep 08 17:05:48 debian systemd[1]: Started pi2-adsb.
Sep 08 17:05:48 debian pi2-adsb[1405]: pi2-adsb
.
abcd@debian:~$ sudo systemctl status connect@pi2-mlat.service
● connect@pi3-mlat.service - pi2-mlat
Loaded: loaded (/lib/systemd/system/connect@.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2019-09-08 17:06:10 EDT; 23min ago
Main PID: 1420 (tunnel.sh)
Tasks: 2 (limit: 2348)
Memory: 1004.0K
CGroup: /system.slice/system-connect.slice/connect@pi2-mlat.service
├─1420 /bin/bash /usr/share/connect/tunnel.sh pi2-mlat
└─1421 /usr/bin/socat -u TCP:192.168.0.22:30105 TCP:localhost:30004
Sep 08 17:06:10 debian systemd[1]: Started pi2-mlat.
Sep 08 17:06:10 debian pi2-mlat[1420]: pi2-mlat
.
.