29 lines
982 B
Plaintext
Executable File
29 lines
982 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 /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; |