-
Notifications
You must be signed in to change notification settings - Fork 17
/
update.sh
executable file
·215 lines (174 loc) · 5.86 KB
/
update.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
#!/bin/bash
_now=$(date +"%m_%d_%Y_%H_%M_%S")
BACKUPDIR="/storage/backup/"$_now"/"
DATFILESBACKUPDIR="dat_files/"
DATFILESMASTERDIR="dat_files/"
DATFILESDIR="/storage/.kodi/userdata/addon_data/plugin.program.iarl/dat_files/"
BIOSBACKUPDIR="bios/"
BIOSMASTERDIR="roms/bios/"
BIOSDIR="/storage/roms/bios/"
CONFMASTERDIR="conf/"
echo "
___ _ _ _ _
| _ \___| |_ _ _ ___| | (_) |__ _ _ ___
| / -_) _| '_/ _ \ |__| | '_ \ '_/ -_)
|_|_\___|\__|_| \___/____|_|_.__/_| \___|
";
echo "!!!WARNING!!!
You're about to install our up-to-date Git Package (https://github.com/Piehr/RetroLibre) on this computer, updating its content on your system."
while true; do
read -p "ARE YOU OK TO PROCEED?[y/n]" yn
case $yn in
[Yy]* )
if [ -d "$BACKUPDIR" ]; then
echo -n "Cleaning $BACKUPDIR location... "
rm -rf $BACKUPDIR &&
wait
echo "done";
fi
mkdir $BACKUPDIR && wait
check_arch=$(uname -m);
case $check_arch in
"x86_64" )
dat_files_conf=${PWD}/$CONFMASTERDIR"x86_update_config.conf";;
* )
dat_files_conf=${PWD}/$CONFMASTERDIR"pi_update_config.conf";;
esac
echo "Architecture: $check_arch - $dat_files_conf will be used.";
while true; do
read -p "Do you want to replace your dat_files by the Master ones?[y/n]" yn
case $yn in
[Yy]* )
#backing-up dat files
echo -n "Backing up your dat_files... "
if [ ! -d "$DATFILESDIR" ]; then
echo "ERROR: $DATFILESDIR NOT FOUND";
exit;
fi
mkdir $BACKUPDIR$DATFILESBACKUPDIR && cp -rf $DATFILESDIR* $BACKUPDIR$DATFILESBACKUPDIR &&
wait
cp -rf $DATFILESDIR* $BACKUPDIR$DATFILESBACKUPDIR &&
wait
echo "Done. Your old dat_files are located in $BACKUPDIR$DATFILESBACKUPDIR";
while true; do
read -p "Do you want to enable Full Streaming Mode (F) or Local Storage Mode (L)?[F/L]" fl
case $fl in
[Ff]* )
storage_mode="F";
break;;
[Ll]* )
storage_mode="L";
break;;
* ) echo "Please answer F (Full Streaming Mode) or L (Local Storage Mode).";;
esac
done
echo "Copying Master dat_files... "
rm -rf $DATFILESDIR* && wait
#Read Master dat_files and check the config file for inclusion
for f in ${PWD}/$DATFILESMASTERDIR*; do
wfile=`basename "$f"`;
#search in the config file
current_dat_file="";
while read line; do
current_dat_file=$line;
test_file=$(echo $current_dat_file |cut -f1 -d' ');
if [[ "$wfile" == "$test_file" ]]; then
break;
fi
done < $dat_files_conf;
if [ ! -z "$current_dat_file" ]; then
dat_check=$(echo $current_dat_file |cut -f2 -d' ');
dat_path=$(echo $current_dat_file |cut -f3 -d' ');
if [ $dat_check -eq 1 ]; then
echo -n "Copy of $wfile... ";
cp -rf ${PWD}/$DATFILESMASTERDIR"$wfile" $DATFILESDIR && wait
if [[ "$storage_mode" == "F" ]]; then
sed -i -e "s|<emu_downloadpath>.*</emu_downloadpath>|<emu_downloadpath>default</emu_downloadpath>|g" $DATFILESDIR"$wfile" && wait;
else
sed -i -e "s|<emu_downloadpath>.*</emu_downloadpath>|<emu_downloadpath>$dat_path</emu_downloadpath>|g" $DATFILESDIR"$wfile" && wait && echo -n "Path changed to $dat_path... ";
fi
echo "done.";
else
echo "Copy of $wfile skipped (Disabled in conf file)";
fi
fi
done
echo "dat_files successfully updated";
break;;
[Nn]* )
echo "Your dat_files have not been updated."
break;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Do you want to replace your BIOS roms by the Master ones?[y/n]" yn
case $yn in
[Yy]* )
#backing-up dat files
echo -n "Backing up your BIOS roms... "
if [ ! -d "$BIOSDIR" ]; then
echo "ERROR: $BIOSDIR NOT FOUND";
exit;
fi
mkdir $BACKUPDIR$BIOSBACKUPDIR &&
cp -rf $BIOSDIR* $BACKUPDIR$BIOSBACKUPDIR &&
wait
echo "done. Your old BIOS roms are located in $BACKUPDIR$BIOSBACKUPDIR";
echo -n "Copying Master BIOS roms... "
rm -rf $BIOSDIR* &&
cp -rf ${PWD}/$BIOSMASTERDIR* $BIOSDIR &&
wait
echo "done";
break;;
[Nn]* )
echo "Your BIOS roms have not been updated."
break;;
* ) echo "Please answer yes or no.";;
esac
done
#Check if Transmission is running
ps -ef | grep transmission | grep -v grep > /dev/null
if [ $? -eq "0" ]; then
transmission_check=0;
else
transmission_check=1;
fi
if [ $transmission_check -eq 0 ]; then
while true; do
read -p "Transmission Daemon is running - Do you want to disable it ? [y/n]" yn
case $yn in
[Yy]* )
systemctl disable transmission.service && systemctl stop transmission && wait
echo "Transmission Daemon disabled."
break;;
[Nn]* )
echo "Transmission Daemon configuration skipped."
break;;
* ) echo "Please answer yes or no.";;
esac
done
else
while true; do
read -p "Transmission Daemon is not running. Do you want to install it? [y/n]" yn
case $yn in
[Yy]* )
systemctl enable transmission.service && systemctl start transmission && wait
echo "Transmission Daemon installed and running."
echo "Download directory: /storage/downloads/";
echo "For more settings, please check /storage/.config/transmission-daemon/settings.json";
break;;
[Nn]* )
echo "Transmission Daemon configuration skipped."
break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
echo "Update process complete. Enjoy!"
exit
break;;
[Nn]* ) echo "See you Space Cowboy...";exit;;
* ) echo "Please answer yes or no.";;
esac
done