view install.sh @ 26:3090d8bf4242

Fix temperature decoding.
author Daniel O'Connor <darius@dons.net.au>
date Tue, 21 Dec 2021 15:05:32 +1030
parents 41eba85c0c84
children
line wrap: on
line source

#!/bin/sh

root=$(cd $(dirname $0); pwd)

# Set VE_SERVICE for our serial cable to inform serial-starter about it
mkdir -p /etc/udev/rules.d >/dev/null 2>&1
cat >/etc/udev/rules.d/eprodbus.rules <<EOF
ACTION=="add", ENV{ID_BUS}=="usb", ENV{ID_MODEL}=="FT232_epro", ENV{VE_SERVICE}="eprodbus"
EOF

# Tell serial starter to run our service
mkdir -p /data/conf/serial-starter.d >/dev/null 2>&1
cat >/data/conf/serial-starter.d/eprodbus.conf <<EOF
service	eprodbus	eprodbus
EOF

# Create service template for running and logging
# Serial starter copies this to /service and pattern-replaces TTY
mkdir -p /opt/victronenergy/eprodbus/service/log >/dev/null 2>&1
cat >/opt/victronenergy/eprodbus/service/run <<EOF
#!/bin/sh
exec 2>&1
exec /usr/bin/python $root/eprodbus.py TTY
EOF
cat <<EOF >/opt/victronenergy/eprodbus/service/log/run
#!/bin/sh
exec 2>&1
exec multilog t s25000 n4 /var/log/eprodbus.TTY
EOF
chmod 755 /opt/victronenergy/eprodbus/service/run /opt/victronenergy/eprodbus/service/log/run

# Create rc.local hooks for reinstallation
mkdir /data/rc.local.d /data/rcS.local.d >/dev/null 2>&1
cat >/data/rc.local.d/eprodbus <<EOF
#!/bin/sh
sh $root/install.sh
EOF

cat >/data/rc.local <<EOF
#!/bin/sh
for s in /data/rc.local.d/*; do
  \$s
done
EOF

cat >/data/rcS.local <<EOF
#!/bin/sh
for s in /data/rcS.local.d/*; do
  \$s
done
EOF

chmod 755 /data/rc.local.d/eprodbus /data/rc.local /data/rcS.local