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 -