Compare commits
5 Commits
66b4d3a067
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
56cd464a9a
|
|||
|
8fe9435206
|
|||
|
c1dea85bed
|
|||
|
60ed643580
|
|||
|
7c966b063b
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.bak
|
||||||
@@ -25,15 +25,13 @@ if [[ ! "$ans" =~ ^[yY][eE]?[sS]?$ ]]; then
|
|||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
touch /tmp/savesync
|
|
||||||
printf "s|RCLONE_PREFIX|%s|\n" "$prefix" >/tmp/savesync
|
|
||||||
sed -i -e "/tmp/savesync" "savesync[rungame,endgame](sync).ash"
|
|
||||||
sed -i -e "/tmp/savesync" "locksync.ash"
|
|
||||||
rm "/tmp/savesync"
|
|
||||||
printf "Installing scripts...n"
|
printf "Installing scripts...n"
|
||||||
|
sed -i "s|RCLONE_PREFIX|$prefix|" "savesync[rungame,endgame](sync).ash"
|
||||||
|
sed -i "s|RCLONE_PREFIX|$prefix|" "locksync.ash"
|
||||||
cp "savesync[rungame,endgame](sync).ash" /recalbox/share/userscripts/
|
cp "savesync[rungame,endgame](sync).ash" /recalbox/share/userscripts/
|
||||||
mkdir -p /recalbox/share/userscripts/manual
|
mkdir -p /recalbox/share/userscripts/manual
|
||||||
cp "locksync.ash" /recalbox/share/userscripts/manual/
|
cp "locksync.ash" /recalbox/share/userscripts/manual/
|
||||||
|
|
||||||
printf "done\n"
|
printf "done\n"
|
||||||
printf "Cleaning up..."
|
printf "Cleaning up..."
|
||||||
cd .. || {
|
cd .. || {
|
||||||
|
|||||||
28
locksync.ash
28
locksync.ash
@@ -5,23 +5,23 @@ export REMOTE_BASE="RCLONE_PREFIX"
|
|||||||
export LOG_FILE="/recalbox/share/system/logs/locksync.log"
|
export LOG_FILE="/recalbox/share/system/logs/locksync.log"
|
||||||
|
|
||||||
log() {
|
log() {
|
||||||
# $1 = level
|
# Ensure log directory exists
|
||||||
# $2 = message
|
mkdir -p "$(dirname "$LOG_FILE")"
|
||||||
printf "[%s] [%s] %s\n" "$(date '+%Y-%m-%d %H:%M:%S')" "$1" "$2" >>"$LOG_FILE"
|
printf "[%s] [%s] %s\n" "$(date '+%Y-%m-%d %H:%M:%S')" "$1" "$2" >>"$LOG_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
locks=$(find /recalbox/share/saves -name "*.lock")
|
# Use find to pipe directly into the loop to handle spaces in filenames correctly
|
||||||
if [ -z "$locks" ]; then
|
find /recalbox/share/saves -name "*.lock" | while read -r lockfile; do
|
||||||
log "INFO" "No game locks found"
|
# 1. Get the game path by removing .lock
|
||||||
else
|
lgame="${lockfile%.lock}"
|
||||||
while read -r lockfile; do
|
|
||||||
lgame="$(echo "$lockfile" | sed 's/\.lock//')"
|
# 2. Extract the relative path for the remote
|
||||||
rgame="$(echo "$lockfile" | sed 's|/recalbox/share/roms/||' | sed 's/\.lock//')"
|
# This removes '/recalbox/share/saves/' from the start of the path
|
||||||
|
rgame="${lgame#/recalbox/share/saves/}"
|
||||||
|
|
||||||
if [ -f "$lgame" ]; then
|
if [ -f "$lgame" ]; then
|
||||||
log "INFO" "Game found: $lgame"
|
log "INFO" "Game found: $lgame"
|
||||||
else
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if rclone copyto "$lgame" "${REMOTE_BASE}/${rgame}"; then
|
if rclone copyto "$lgame" "${REMOTE_BASE}/${rgame}"; then
|
||||||
log "INFO" "Game synced: $rgame"
|
log "INFO" "Game synced: $rgame"
|
||||||
rm "$lockfile"
|
rm "$lockfile"
|
||||||
@@ -29,5 +29,7 @@ else
|
|||||||
log "WARN" "Could not sync game $rgame"
|
log "WARN" "Could not sync game $rgame"
|
||||||
log "INFO" "Lockfile $lockfile not removed"
|
log "INFO" "Lockfile $lockfile not removed"
|
||||||
fi
|
fi
|
||||||
done <"$locks"
|
else
|
||||||
|
log "DEBUG" "Lock found for non-existent file: $lgame"
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user