-
-
Notifications
You must be signed in to change notification settings - Fork 218
/
import.sh
218 lines (179 loc) · 6.56 KB
/
import.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/bin/bash
clear
if [ ! -f "$HOME/.config/EmuDeck/backend/functions/all.sh" ]; then
text="$(printf "<b>EmuDeck installation not found</b>\nPlease Install EmuDeck before using this tool")"
zenity --error \
--title="EmuDeck Import tool" \
--width=250 \
--ok-label="Bye" \
--text="${text}" 2>/dev/null
exit
fi
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
function customLocation(){
zenity --file-selection --directory --title="Select the root of the drive where you want to create your backup" 2>/dev/null
}
function checkSpace(){
local origin=$1
local destination=$2
local neededSpace=$(du -s "$origin" | awk '{print $1}')
local neededSpaceInHuman=$(du -sh "$origin" | awk '{print $1}')
#File Size on destination
local freeSpace=$(df -k "$destination" --output=avail | tail -1)
local freeSpaceInHuman=$(df -kh "$destination" --output=avail | tail -1)
local difference=$(($freeSpace - $neededSpace))
if [[ $difference -lt 0 ]]; then
text="$(printf "Make sure you have enought space in $destination. You need to have at least $neededSpaceInHuman available")"
zenity --question \
--title="EmuDeck Import tool" \
--width=450 \
--cancel-label="Exit" \
--ok-label="Continue" \
--text="${text}" 2>/dev/null
ans=$?
if [ $ans -eq 0 ]; then
echo "Continue..."
else
exit
fi
else
echo "Continue..."
fi
}
text="$(printf "Welcome to EmuDeck's <b>import</b> save tool.\nThis script will help you migrate your EmuDeck saved games from another Steam Deck")"
zenity --question \
--title="EmuDeck Import tool" \
--width=450 \
--cancel-label="Exit" \
--ok-label="Import my saved games" \
--text="${text}" 2>/dev/null
ans=$?
if [ $ans -eq 0 ]; then
echo "Waiting for the user to pick a destination...."
else
exit
fi
text="$(printf "Please select the drive where you have your <b>exported saves</b>")"
zenity --info \
--title="EmuDeck Import tool" \
--width="${width}" \
--text="${text}" 2>/dev/null
origin=$(customLocation)
if [ -d "$origin/EmuDeck/saves/" ]; then
echo "Continue..."
else
text="$(printf "<b>No saved games detected</b>\nPlease select the root of the drive, don't select any of its folders.")"
zenity --error \
--title="EmuDeck Import tool" \
--width=250 \
--ok-label="Try again" \
--text="${text}"
if [ -d "$origin/EmuDeck/saves/" ]; then
echo "Continue..."
else
text="$(printf "<b>No EmuDeck save folder found</b>\nMake sure you have an Emulation/saves folder in your drive")"
zenity --error \
--title="EmuDeck Import tool" \
--width=250 \
--ok-label="Bye" \
--text="${text}"
exit
fi
fi
checkSpace "$origin/EmuDeck/saves/" "$emulationPath"
for entry in "$origin/EmuDeck/saves/"*
do
rsync -rav --ignore-existing --progress "$entry" "$emulationPath/saves/" | awk -f $HOME/.config/EmuDeck/backend/rsync.awk | zenity --progress --text="Importing $entry to $emulationPath/saves/" --title="Importing $entry..." --width=400 --percentage=0 --auto-close
done
size=0;
size=$((size + $(du -sb "$origin/EmuDeck/saves/" | cut -f1)))
if [ "$size" -gt 4096 ]; then
if [ -d "$origin/EmuDeck/storage" ]; then
text="$(printf "<b>Storage folder found in your drive!</b>\nLet's import that one too")"
zenity --question \
--title="EmuDeck Import tool" \
--width=450 \
--cancel-label="Exit" \
--ok-label="Import my storage" \
--text="${text}" 2>/dev/null
ans=$?
if [ $ans -eq 0 ]; then
checkSpace "$origin/EmuDeck/storage/" "$emulationPath"
for entry in "$origin/EmuDeck/storage/"*
do
rsync -ravL --ignore-existing --progress "$entry" "$emulationPath/storage/" | awk -f $HOME/.config/EmuDeck/backend/rsync.awk | zenity --progress --text="Importing $entry to $emulationPath/storage/" --title="Importing $entry..." --width=400 --percentage=0 --auto-close
done
else
echo "User selected no import: Storage"
fi
fi
if [ -d "$origin/EmuDeck/bios" ]; then
text="$(printf "<b>Bios folder found in your drive!</b>\nLet's import that one too")"
zenity --question \
--title="EmuDeck Import tool" \
--width=450 \
--cancel-label="No" \
--ok-label="Import my Bios" \
--text="${text}" 2>/dev/null
ans=$?
if [ $ans -eq 0 ]; then
checkSpace "$origin/EmuDeck/bios/" "$emulationPath"
for entry in "$origin/EmuDeck/bios/"*
do
rsync -ravL --ignore-existing --progress "$entry" "$emulationPath/bios/" | awk -f $HOME/.config/EmuDeck/backend/rsync.awk | zenity --progress --text="Importing $entry to $emulationPath/bios/" --title="Importing $entry..." --width=400 --percentage=0 --auto-close
done
else
echo "User selected no import: bios"
fi
fi
if [ -d "$origin/EmuDeck/tools/downloaded_media" ]; then
text="$(printf "<b>ESDE Media folder found in your drive!</b>\nLet's import that one too")"
zenity --question \
--title="EmuDeck Import tool" \
--width=450 \
--cancel-label="No" \
--ok-label="Import my ESDE media" \
--text="${text}" 2>/dev/null
ans=$?
if [ $ans -eq 0 ]; then
checkSpace "$origin/EmuDeck/tools/downloaded_media/" "$toolsPath"
for entry in "$origin/EmuDeck/tools/downloaded_media/"*
do
rsync -ravL --ignore-existing --progress "$entry" "$emulationPath/bios/" | awk -f $HOME/.config/EmuDeck/backend/rsync.awk | zenity --progress --text="Importing $entry to $emulationPath/tools/downloaded_media/" --title="Importing $entry..." --width=400 --percentage=0 --auto-close
done
else
echo "User selected no import: ESDE media"
fi
fi
if [ -d "$origin/EmuDeck/roms" ]; then
text="$(printf "<b>Roms folder found in your drive!</b>\nLet's import that one too")"
zenity --question \
--title="EmuDeck Import tool" \
--width=450 \
--cancel-label="No" \
--ok-label="Import my Roms" \
--text="${text}" 2>/dev/null
ans=$?
if [ $ans -eq 0 ]; then
checkSpace "$origin/EmuDeck/roms/" "$emulationPath"
for entry in "$origin/EmuDeck/roms/"*
do
rsync -ravL --ignore-existing --progress "$entry" "$emulationPath/roms/" | awk -f $HOME/.config/EmuDeck/backend/rsync.awk | zenity --progress --text="Importing $entry to $emulationPath/roms/" --title="Importing $entry..." --width=400 --percentage=0 --auto-close
done
else
echo "User selected no import: Roms"
fi
fi
text="$(printf "<b>Success!</b>\nRemember that you need to Open EmuDeck and run Steam Rom Manager in this new device to add EmulationStation or any of your games to Steam")"
zenity --info \
--title="EmuDeck Import tool" \
--width=350 \
--text="${text}"
else
text="$(printf "<b>The operation failed</b>\nYour saved games might not have been exported.")"
zenity --error \
--title="EmuDeck Import tool" \
--width=250 \
--ok-label="Bye" \
--text="${text}"
fi