#!/bin/ash # shellcheck shell=dash export LOG_FILE="/recalbox/share/system/logs/savesync.log" export PIPE="/tmp/savesync_pipe" # Setup the pipe if it doesn't exist [ -p "$PIPE" ] || mkfifo "$PIPE" chmod 666 "$PIPE" write_log() { printf "[%s] %s\n" "$(date '+%Y-%m-%d %H:%M:%S')" "$1" >>"$LOG_FILE" } write_log "--- Logger Started ---" while true; do # Read one line from the pipe if read -r line <"$PIPE"; then case "$line" in LOG:*) write_log "${line#LOG:}" ;; esac fi done