Sthope b94fbc891a
All checks were successful
continuous-integration/drone/push Build is passing
first commit
2022-05-15 15:57:21 +02:00

29 lines
948 B
Plaintext
Executable File

#!/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 /config/temp2mqtt ]] && touch /config/temp2mqtt;
cat <<EOF >> /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 /config/temp2mqtt;
chmod +x /config/temp2mqtt;