Recreating the script

This commit is contained in:
2026-02-27 14:21:33 -06:00
commit 276b84b9aa
3 changed files with 105 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
#!/bin/ash
# shellcheck shell=ash
#
#
eventfile="/tmp/es_state.inf"
# 1. Check if the file exists and is not empty
if [ ! -s "$eventfile" ]; then
echo "Error: $eventfile is missing or empty."
exit 1
fi
# 2. Read the payload safely
PAYLOAD=$(cat "$eventfile")
# 3. Publish (using double quotes to handle spaces/newlines in the file)
mosquitto_pub -h 127.0.0.1 -p 1883 -t /Recalbox/EmulationStation/Event -m "$PAYLOAD"
# 4. Optional: check if the publish succeeded
if [ $? -eq 0 ]; then
echo "Successfully published event."
else
echo "Failed to connect to mosquitto broker."
fi
sleep 4