From 03b229a64f1e756fbabeaf583737133ecaf80736 Mon Sep 17 00:00:00 2001 From: wytch Date: Sat, 28 Feb 2026 17:13:35 -0600 Subject: [PATCH] Added locksync.ash, updated install script --- install.sh | 27 +++++++++++++++++++---- locksync.ash | 33 +++++++++++++++++++++++++++++ savesync[rungame,endgame](sync).ash | 2 +- 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 locksync.ash diff --git a/install.sh b/install.sh index 205ae33..328b862 100644 --- a/install.sh +++ b/install.sh @@ -2,14 +2,33 @@ ENDPOINT="https://git.sassysalamander.net/wytch/recalbox-savesync/archive/main.tar.gz" cd /recalbox/share/system +printf "Curling tarball..." curl -L -o savesync.tar.gz "$ENDPOINT" 2>/dev/null +printf "done\n" +printf "extracting tarball..." tar -xvf savesync.tar.gz >/dev/null +printf "done\n" rm savesync.tar.gz cd recalbox-savesync -cp *.ash /recalbox/share/userscripts/ -mkdir -p /recalbox/share/system/configs/savesync -#cp *.conf /recalbox/share/system/configs/savesync/ + +ans="" +while [ ! "$ans" =~ ^[yY][eE]?[sS]?$ ]; do + read -p "\nWhat's your rclone prefix? : " prefix + read -rp "Is $prefix okay? [y/N]: " ans +done + +printf "s//%s/g" "$prefix" > "/tmp/savesync.sed" +sed -ie "/tmp/savesync.sed" "*.ash" +rm "/tmp/savesync.sed" +printf "Installing scripts...n" +cp "savesync[rungame,endgame](sync).ash" /recalbox/share/userscripts/ +mkdir -p /recalbox/share/userscripts/manual +cp "locksync.ash" /recalbox/share/userscripts/manual/ +printf "done\n" +printf "Cleaning up..." cd .. rm -rf recalbox-savesync -echo Done +printf "done\n" + +printf "Installation complete!\n" diff --git a/locksync.ash b/locksync.ash new file mode 100644 index 0000000..b743c73 --- /dev/null +++ b/locksync.ash @@ -0,0 +1,33 @@ +#!/bin/ash +#shellcheck shell=dash + +export REMOTE_BASE="" +export LOG_FILE="/recalbox/share/system/logs/locksync.log" + +log() { + # $1 = level + # $2 = message + printf "[%s] [%s] %s\n" "$(date '+%Y-%m-%d %H:%M:%S')" "$1" "$2" >>"$LOG_FILE" +} + +locks=$(find /recalbox/share/saves -name "*.lock") +if [ -z "$locks" ]; then + log "INFO" "No game locks found" +else + while read -r lockfile; do + lgame="$(echo "$lockfile" | sed 's/\.lock//')" + rgame="$(echo "$lockfile" | sed 's|/recalbox/share/roms/||' | sed 's/\.lock//')" + if [ -f "$lgame" ]; then + log "INFO" "Game found: $lgame" + else + continue + fi + if rclone copyto "$lgame" "${REMOTE_BASE}/${rgame}"; then + log "INFO" "Game synced: $rgame" + rm "$lockfile" + else + log "WARN" "Could not sync game $rgame" + log "INFO" "Lockfile $lockfile not removed" + fi + done <"$locks" +fi diff --git a/savesync[rungame,endgame](sync).ash b/savesync[rungame,endgame](sync).ash index ec3297a..03d150b 100644 --- a/savesync[rungame,endgame](sync).ash +++ b/savesync[rungame,endgame](sync).ash @@ -4,7 +4,7 @@ event_data=$(cat /tmp/es_state.inf | tr -d '\r') export LOG_FILE="/recalbox/share/system/logs/savesync.log" -REMOTE_BASE="saves:gamepi-tv" +REMOTE_BASE="" #DEBUG=1 log() {