From 6e2c115dd239b757158a15f126d876a2bb4c232a Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Sat, 8 Jun 2024 21:22:27 +0200 Subject: [PATCH] Migrate to docker. --- Dockerfile | 12 ++++++++++++ find_ttyUSB.sh | 10 ++++++++++ install.sh | 25 ------------------------- 3 files changed, 22 insertions(+), 25 deletions(-) create mode 100644 Dockerfile create mode 100644 find_ttyUSB.sh delete mode 100755 install.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..907684c --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM debian:bookworm +MAINTAINER yohan <783b8c87@scimetis.net> +ENV DEBIAN_FRONTEND noninteractive +ENV TZ Europe/Paris +RUN apt-get update && apt-get -y install gunicorn sqlite3 python3-pip python3-requests python3-yaml python3-flask python3-serial udev +WORKDIR /root +COPY find_ttyUSB.sh /root/ +COPY read_one-wire_sensor.py /root/ +COPY read_teleinfo.py /root/ +COPY read_yocto_sensor.py /root/ +COPY sensors-polling.py /root/ +ENTRYPOINT ["/root/sensors-polling.py"] diff --git a/find_ttyUSB.sh b/find_ttyUSB.sh new file mode 100644 index 0000000..a224fe3 --- /dev/null +++ b/find_ttyUSB.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do + syspath="${sysdevpath%/dev}" + devname="$(udevadm info -q name -p $syspath)" + [[ "$devname" == "ttyUSB"* ]] || continue + eval "$(udevadm info -q property --export -p $syspath)" + [[ -z "$ID_SERIAL" ]] && exit + echo "/dev/$devname - $ID_SERIAL" +done diff --git a/install.sh b/install.sh deleted file mode 100755 index 46e4ff6..0000000 --- a/install.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -#Absolute path to this script -SCRIPT=$(readlink -f $0) -#Absolute path this script is in -SCRIPTPATH=$(dirname $SCRIPT) -SERVICE="sensors-polling" - -cat << EOF > /etc/systemd/system/${SERVICE}.service -[Unit] -Description=Starting ${SERVICE} -After=network-online.target -Wants=network-online.target - -[Service] -Type=simple -User=root -ExecStart=$SCRIPTPATH/${SERVICE}.py -WorkingDirectory=$SCRIPTPATH - -[Install] -WantedBy=multi-user.target -EOF -systemctl daemon-reload -systemctl enable ${SERVICE}.service -