forked from venice1200/MiSTer_tty2oled
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_tty2oled.sh
88 lines (71 loc) · 4 KB
/
update_tty2oled.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
#!/bin/bash
# v1.2 - Copyright (c) 2021 ojaksch, venice
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# You can download the latest version of this script from:
# https://github.com/venice1200/MiSTer_tty2oled
# Changelog:
# v1.2 New parameter in INI file, which selects the used tty2xxx device
# v1.1 Use of an INI file (tty2oled.ini)
# v1.0 Base updater script. Downloads and executes a second script (Main updater), which in turn completes all tasks.
REPOSITORY_URL="https://raw.githubusercontent.com/venice1200/MiSTer_tty2oled/main"
#REPOSITORY_URL="https://raw.githubusercontent.com/venice1200/MiSTer_tty2oled/testing" # Testing branch
SCRIPTNAME="/tmp/update_tty2oled_script.sh"
NODEBUG="-q -o /dev/null"
wget ${NODEBUG} --no-cache "${REPOSITORY_URL}/tty2oled.ini" -O /tmp/tty2oled.ini
if ! [ -f /media/fat/Scripts/tty2oled.ini ]; then
echo -e "\e[1;33mCreating tty2oled.ini File \e[1;35m${PICNAME}\e[0m"
mv -f /tmp/tty2oled.ini /media/fat/Scripts/tty2oled.ini
elif ! [[ "$(head -n1 /tmp/tty2oled.ini)" = "$(head -n1 /media/fat/Scripts/tty2oled.ini)" ]]; then
echo -e "\e[1;31mThere is a newer version of \e[1;33m/media/fat/Scripts/tty2oled.ini\e[1;31m availble.\e[0m"
echo -e "\e[1;31mIt is very likely that something will break if we continue. You should backup\e[0m"
echo -e "\e[1;31myour INI file and move or delete the original afterwards. After re-running\e[0m"
echo -e "\e[1;31mthis updater and receiving the new INI file, compare both versions and edit\e[0m"
echo -e "\e[1;31mthe new INI file, if necessary.\e[0m"
echo -e "\n\e[1;35mIf you would like that we continue and automagically doing the rest,"
echo -e "please answer YES\e[0m"
read ANSWER
if [ "${ANSWER}" = "YES" ]; then
mv -f /media/fat/Scripts/tty2oled.ini /media/fat/Scripts/tty2oled.ini.bak
mv -f /tmp/tty2oled.ini /media/fat/Scripts/tty2oled.ini
echo -e "\n\e[1;33mThese are the differences:\e[0m\n"
diff -u /media/fat/Scripts/tty2oled.ini.bak /media/fat/Scripts/tty2oled.ini
echo -e "\n\e[1;33mPlease edit the new INI file and make necessary changes,"
echo -e "then re-run this updater.\e[0m\n"
else
echo -e "\n\e[1;33mAborting.\e[0m"
fi
exit 1
fi
wget ${NODEBUG} --no-cache "${REPOSITORY_URL}/update_tty2oled.sh" -O /tmp/update_tty2oled.sh
if ! cmp -s /tmp/update_tty2oled.sh /media/fat/Scripts/update_tty2oled.sh; then
echo -e "\e[1;33mDownloading Updater-Update \e[1;35m${PICNAME}\e[0m"
mv -f /tmp/update_tty2oled.sh /media/fat/Scripts/update_tty2oled.sh
exec /media/fat/Scripts/update_tty2oled.sh
exit 255
else
rm /tmp/update_tty2oled.sh
fi
wget ${NODEBUG} --no-cache "${REPOSITORY_URL}/update_tty2oled_script.sh" -O ${SCRIPTNAME}
case ${?} in
0) bash ${SCRIPTNAME} ${1} ;;
1) echo -e "\e[1;33mwget: \e[1;31mGeneric error code.\e[0m" ;;
2) echo -e "\e[1;33mwget: \e[1;31mParse error---for instance, when parsing command-line options, the .wgetrc or .netrc..." ;;
3) echo -e "\e[1;33mwget: \e[1;31mFile I/O error.\e[0m" ;;
4) echo -e "\e[1;33mwget: \e[1;31mNetwork failure.\e[0m" ;;
5) echo -e "\e[1;33mwget: \e[1;31mSSL verification failure.\e[0m" ;;
6) echo -e "\e[1;33mwget: \e[1;31mUsername/password authentication failure.\e[0m" ;;
7) echo -e "\e[1;33mwget: \e[1;31mProtocol errors.\e[0m" ;;
8) echo -e "\e[1;33mwget: \e[1;31mServer issued an error response.\e[0m" ;;
*) echo -e "\e[1;31mUnexpected and uncatched error.\e[0m" ;;
esac
[[ -f ${SCRIPTNAME} ]] && rm ${SCRIPTNAME}
exit 0