cpp-d1064d
authorMichael Wagner <michael@wagnertech.de>
Fri, 18 Jun 2021 21:05:59 +0000 (23:05 +0200)
committerMichael Wagner <michael@wagnertech.de>
Fri, 18 Jun 2021 21:05:59 +0000 (23:05 +0200)
debian/eibd.cp
debian/eibd.postinst [new file with mode: 0755]
eibd/eibd.env [new file with mode: 0644]
eibd/eibd.service
eibd/start-eibd [new file with mode: 0755]

index 786b51e..c6798a5 100755 (executable)
@@ -13,3 +13,13 @@ rsync -a ../build/debian/tmp/ debian/tmp/
 cp ../build/bcusdk-0.0.5/debian/changelog debian/
 cp ../build/bcusdk-0.0.5/debian/copyright debian/
 
+mkdir -p $1/etc
+cp eibd/eibd.env $1/etc/eibd
+echo "/etc/eibd" > $1/DEBIAN/conffiles
+
+mkdir -p $1/lib/systemd/system
+cp eibd/eibd.service $1/lib/systemd/system/
+
+mkdir -p $1/usr/sbin
+cp eibd/start-eibd $1/usr/sbin/
+
diff --git a/debian/eibd.postinst b/debian/eibd.postinst
new file mode 100755 (executable)
index 0000000..6f5684d
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+set -e
+
+# On Raspberry if a tpuart works on /dev/ttyAMA0, some services have to be deactivated
+# see: https://busware.de/tiki-index.php?page=ROT_Installation
+if [ -e /dev/ttyAMA0 ]
+then
+       if grep ttyAMA0 /etc/inittab
+       then
+               grep -v ttyAMA0 /etc/inittab >/etc/inittab.tmp
+               mv /etc/inittab.tmp /etc/inittab
+       fi
+       if grep ttyAMA0 /etc/inittab
+       then
+               grep -v ttyAMA0 /boot/cmdline.txt >/boot/cmdline.txt.tmp
+               mv /boot/cmdline.txt.tmp /boot/cmdline.txt
+               echo "--------------------- reboot system! ---------------------------"
+       fi
+       systemctl stop serial-getty@ttyAMA0.service
+       systemctl disable serial-getty@ttyAMA0.service
+fi
+
+systemctl enable eibd || true
+systemctl start eibd || true
+
diff --git a/eibd/eibd.env b/eibd/eibd.env
new file mode 100644 (file)
index 0000000..4d9bf2d
--- /dev/null
@@ -0,0 +1,6 @@
+# individual address of eibd tunnelling instance
+IND_ADDR="1.1.251"
+
+# additional eibd params
+ADD_PARAM=
+
index 4aee24c..21b86ec 100644 (file)
@@ -4,14 +4,10 @@ After=network.target syslog.service
 
 [Service]
 EnvironmentFile=/etc/eibd
-#ExecStart=/usr/bin/eibd -iDTS -e $IND_ADDR tpuarts:$EIB_DEV
-ExecStart=/home/debian10/tmp/start
+ExecStart=/usr/sbin/start-eibd
 KillMode=process
-#Restart=on-failure
-RestartPreventExitStatus=255
-Type=simple
+Type=forking
 
-#[Install]
-#WantedBy=multi-user.target
-#Alias=sshd.service
+[Install]
+WantedBy=multiuser.target
 
diff --git a/eibd/start-eibd b/eibd/start-eibd
new file mode 100755 (executable)
index 0000000..fc30bf0
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+set -e
+
+if [ -e /dev/ttyAMA0 ]
+then
+       EIB_URL="tpuarts:/dev/ttyAMA0"
+       # ttyAMA0 interferes with others. Check if everything is deactivated
+       if [ -f /etc/inittab ]
+       then
+               if grep ttyAMA0 /etc/inittab
+               then
+                       echo "ttyAMA0 not deactivated. Run dpkg eibd --reconfigure."
+                       exit 10
+               fi
+       fi
+elif [ -e /dev/ttyACM0 ]
+then
+       EIB_URL="tpuarts:/dev/ttyACM0"
+else
+       EIB_URL="ipt:127.0.0.1"
+fi
+
+echo "running under $IND_ADDR"
+echo "connect with $EIB_URL"
+/usr/bin/eibd -i -DTS -e $IND_ADDR $ADD_PARAM $EIB_URL &
+