-
Notifications
You must be signed in to change notification settings - Fork 0
/
retropie_sync.sh
80 lines (71 loc) · 2.13 KB
/
retropie_sync.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Sync ROMs from network directory.
# Version 1.0.0, c/o Wyrrrd
# 09.06.2021
echo "# retropie_sync"
echo "# Sync ROMs from other directory."
echo "# Version 1.0.0, c/o Wyrrrd"
echo "# 09.06.2021"
romspath="/home/pi/RetroPie/roms"
metapath="/home/pi/.emulationstation"
systems=("gb" "gbc" "gba" "nes" "snes")
restart=false
retries=10
retryinterval=10
. $(dirname $0)/retropie_sync.conf
if [[ -z $sourcepath ]]
then
for (( i=0; $i<=$retries; i++ ))
do
if [[ -z $sourcepath && "$(ls -A $sourcepath)" ]]
then
echo "Source path is not empty. Starting sync."
len=${#systems[@]}
for (( j=0; $j<$len; j++ ))
do
system=${systems[j]}
if [[ "$ls -A $sourcepath/$system)" ]]
then
echo "Syncing system $system ($((j+1))/$len)"
if [[ -z $romspath ]]
then
echo " - Syncing ROMs"
mkdir -p $romspath/$system
[[ $(rsync -aiz --delete $sourcepath/$system/* $romspath/$system) ]] && changes=true
fi
if [[ -z $metapath ]]
then
echo " - Syncing gamelist"
mkdir -p $metapath/gamelists/$system
[[ $(rsync -aiz --delete $sourcepath/.emulationstation/gamelists/$system/* $metapath/gamelists/$system) ]] && changes=true
echo " - Syncing boxarts"
mkdir -p $metapath/downloaded_images/$system
[[ $(rsync -aiz --delete $sourcepath/.emulationstation/downloaded_images/$system/* $metapath/downloaded_images/$system) ]] && changes=true
fi
fi
done
echo "Sync completed."
if [[ $changes ]]
then
echo "There are changes. Playing change laser."
aplay $(dirname $0)/done.wav > /dev/null
fi
if [[ $retries -gt 0 ]]
then
echo "$i of $retries retries needed."
fi
break
else
echo "Source path is empty. Not syncing to avoid data loss."
if [[ $retries -gt 0 ]]
then
echo " - Retrying in $retryinterval seconds."
sleep 10
else
break
fi
fi
done
else
echo "Source path not set, aborting."
fi