Added locksync.ash, updated install script
This commit is contained in:
33
locksync.ash
Normal file
33
locksync.ash
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/ash
|
||||
#shellcheck shell=dash
|
||||
|
||||
export REMOTE_BASE="<RCLONE_PREFIX>"
|
||||
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
|
||||
Reference in New Issue
Block a user