first commit
This commit is contained in:
parent
51dc52e5f2
commit
b5e324d9d9
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
FROM alpine:latest
|
||||||
|
#
|
||||||
|
ARG PUID=1000
|
||||||
|
ARG PGID=1000
|
||||||
|
#
|
||||||
|
RUN set -xe \
|
||||||
|
&& addgroup -g ${PGID} -S mosquitto \
|
||||||
|
&& adduser -u ${PUID} -G mosquitto -h /mosquitto/ -D mosquitto \
|
||||||
|
&& apk add --no-cache --purge -uU mosquitto mosquitto-libs mosquitto-clients
|
||||||
|
|
||||||
|
WORKDIR /workspace
|
||||||
|
COPY root/defaults/temp2mqtt /workspace
|
||||||
|
|
||||||
|
CMD [ "sh", "./temp2mqtt" ]
|
0
data/config/.gitkeep
Normal file
0
data/config/.gitkeep
Normal file
0
data/data/.gitkeep
Normal file
0
data/data/.gitkeep
Normal file
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
version: "3.8"
|
||||||
|
services:
|
||||||
|
temp2mqtt:
|
||||||
|
image: sthopeless/temp2mqtt:latest
|
||||||
|
container_name: temp2mqtt
|
||||||
|
network_mode: bridge
|
||||||
|
environment:
|
||||||
|
- PGID=1000
|
||||||
|
- PUID=1000
|
||||||
|
- PROXMOX_NAME=Icecrown
|
||||||
|
- MQTT_BROKER=mqtt_ip
|
||||||
|
- USERNAME=mqtt_username
|
||||||
|
- PASSWORD=mqtt_password
|
||||||
|
volumes:
|
||||||
|
- /sys/class/thermal/thermal_zone2/temp:/temp:ro
|
||||||
|
restart: unless-stopped
|
||||||
|
labels:
|
||||||
|
- com.centurylinklabs.watchtower.enable=true
|
19
root/defaults/temp2mqtt
Normal file
19
root/defaults/temp2mqtt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# ___ _ _ _ __
|
||||||
|
# / __|| |_ | |_ ___ | '_ \ ___
|
||||||
|
# \__ \| _|| \ / _ \| .__// -_)
|
||||||
|
# |___/ \__||_||_|\___/|_| \___|
|
||||||
|
|
||||||
|
MQTT_BROKER="${MQTT_BROKER:-192.168.100}";
|
||||||
|
USERNAME="${USERNAME:-mosquitto}";
|
||||||
|
PASSWORD="${PASSWORD:-insecurebydefault}";
|
||||||
|
PROXMOX_NAME="${PROXMOX_NAME:-pve}";
|
||||||
|
|
||||||
|
tempvar=$(cat /temp);
|
||||||
|
TEMP=$(expr $tempvar / 1000)
|
||||||
|
|
||||||
|
while :
|
||||||
|
do
|
||||||
|
mosquitto_pub -h "${MQTT_BROKER}" -u "${USERNAME}" -P "${PASSWORD}" -t proxmox/"${PROXMOX_NAME}"/cpu_temp -m "${TEMP}"
|
||||||
|
sleep 1m
|
||||||
|
done
|
29
root/etc/cont-init.d/10-setup
Executable file
29
root/etc/cont-init.d/10-setup
Executable file
@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/with-contenv bash
|
||||||
|
|
||||||
|
MQTT_BROKER="${MQTT_BROKER:-192.168.100}";
|
||||||
|
USERNAME="${USERNAME:-mosquitto}";
|
||||||
|
PASSWORD="${PASSWORD:-insecurebydefault}";
|
||||||
|
PROXMOX_NAME="${PROXMOX_NAME:-pve}";
|
||||||
|
|
||||||
|
TEMP=$(clear;sensors | sed -n 9p | sed 's/^[^=:]*[=:]//' | sed -r 's/\s+//g');
|
||||||
|
|
||||||
|
[[ ! -f /mosquitto/config/temp2mqtt ]] && touch /mosquitto/config/temp2mqtt;
|
||||||
|
cat <<EOF >> /mosquitto/config/temp2mqtt
|
||||||
|
#!/bin/bash
|
||||||
|
# ___ _ _ _ __
|
||||||
|
# / __|| |_ | |_ ___ | '_ \ ___
|
||||||
|
# \__ \| _|| \ / _ \| .__// -_)
|
||||||
|
# |___/ \__||_||_|\___/|_| \___|
|
||||||
|
|
||||||
|
MQTT_BROKER="${MQTT_BROKER:-192.168.100}";
|
||||||
|
USERNAME="${USERNAME:-mosquitto}";
|
||||||
|
PASSWORD="${PASSWORD:-insecurebydefault}";
|
||||||
|
PROXMOX_NAME="${PROXMOX_NAME:-pve}";
|
||||||
|
|
||||||
|
TEMP=$(clear;sensors | sed -n 9p | sed 's/^[^=:]*[=:]//' | sed -r 's/\s+//g');
|
||||||
|
|
||||||
|
mosquitto_pub -h "${MQTT_BROKER}" -u "${USERNAME}" -P "${PASSWORD}" -t proxmox/"${PROXMOX_NAME}"/cpu_temp -m "${TEMP}"
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chown -R mosquitto:mosquitto /mosquitto/;
|
||||||
|
chmod +x /mosquitto/config/temp2mqtt;
|
5
root/etc/services.d/mosquitto/run
Normal file
5
root/etc/services.d/mosquitto/run
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/with-contenv bash
|
||||||
|
|
||||||
|
cd /mosquitto/config || exit 1;
|
||||||
|
|
||||||
|
while /mosquitto/config/temp2mqtt; do sleep 10; done
|
Loading…
x
Reference in New Issue
Block a user