#!/bin/sh

# Updates our crontab file so that it has all the stuff we need
InfluxToken="InfluxDB Token Goes Here"
flairID="Flair Client ID Goes Here"
flairCS="Flair Client Secret Goes Here"

cat << EOF | crontab
@reboot ${HOME}/NWC2026-AstropotaPOD/start_gearman.sh
@reboot ${HOME}/NWC2026-AstropotaPOD/AstropotaPOD.sh --init --start --mqtt

# Get AstropotaPOD Stats and set up the MQTT HA integration information
0 * * * * ${HOME}/NWC2026-AstropotaPOD/AstropotaPOD.sh --mqtt
* * * * * ${HOME}/NWC2026-AstropotaPOD/AstropotaPOD.sh --stats

# Pull stats and throw into InfluxDB
* * * * * INFLUX_TOKEN=${InfluxToken} ${HOME}/NWC2026-AstropotaPOD/telegraf.sh --local
*/2 * * * * INFLUX_TOKEN=${InfluxToken} ${HOME}/NWC2026-AstropotaPOD/telegraf.sh --ppba
*/3 * * * * INFLUX_TOKEN=${InfluxToken} ${HOME}/NWC2026-AstropotaPOD/telegraf.sh --iss
*/15 * * * * INFLUX_TOKEN=${InfluxToken} ${HOME}/NWC2026-AstropotaPOD/telegraf.sh --weather

# Grab Puck temp stats and throw into MQTT (which will then be pulled into Nagios via a check_mqtt plugin)
*/5 * * * * FLAIR_CLIENT_ID="${flairID}" FLAIR_CLIENT_SECRET="${flairCS}" ${HOME}/NWC2026-AstropotaPOD/flair2MQTT.sh bridge
EOF
