ungleich-tools/openwrt-add-temper.sh

45 lines
1.2 KiB
Bash
Raw Normal View History

2020-10-12 20:02:32 +00:00
#!/bin/sh
2020-12-03 19:03:23 +00:00
if [ $# -ne 1 ]; then
echo "$0 ip-address"
echo " ip-address: where to find the OpenWRT device"
exit 1
fi
my_ip=$1; shift
temper_version=0.0.2
temper_url=https://files.pythonhosted.org/packages/7e/1b/0579fef8482660fe194099d988a8ae82b5e5843a60070520039789b26a84/temper-py-0.0.2.tar.gz
2020-12-03 19:03:23 +00:00
cat <<EOF | ssh -t "root@${my_ip}"
set -x
opkg update
opkg install libustream-openssl ca-bundle ca-certificates
opkg install kmod-usb-hid python3-pyserial
2020-10-12 21:06:24 +00:00
wget -O - ${temper_url} | tar xz temper-py-${temper_version}/temper.py
2020-10-12 20:02:32 +00:00
mv temper-py-${temper_version}/temper.py /usr/bin
rmdir temper-py-${temper_version}
2020-12-03 19:03:23 +00:00
chmod a+rx /usr/bin/temper.py
2020-12-03 19:11:33 +00:00
if ! grep -q temper /etc/crontabs/root; then
2020-12-03 19:12:50 +00:00
echo "*/5 * * * * /usr/bin/temper.py | awk '{ print $7 " " $8 }' > /www/temperature.txt" >> /etc/crontabs/root
2020-12-03 19:25:20 +00:00
/etc/init.d/cron restart
2020-12-03 19:11:33 +00:00
fi
2020-12-03 19:25:20 +00:00
2020-12-03 19:03:23 +00:00
EOF
2020-10-12 20:02:32 +00:00
exit 0
[ 2089.624343] hid-generic 0003:413D:2107.0001: input,hidraw0: USB HID v1.11 Keyboard [HID 413d:2107] on usb-101c0000.ehci-1.2/input0
[ 2089.826684] hid-generic 0003:413D:2107.0002: hiddev96,hidraw1: USB HID v1.10 Device [HID 413d:2107] on usb-101c0000.ehci-1.2/input1
2020-10-12 21:06:24 +00:00
root@viirb1:~/temper-py-0.0.1# python3 temper.py
Bus 002 Dev 023 413d:2107 TEMPerGold_V3.1 28.5C 83.3F - - - -