-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·77 lines (70 loc) · 2.99 KB
/
update.sh
File metadata and controls
executable file
·77 lines (70 loc) · 2.99 KB
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
#!/bin/bash
# Filename: update.sh
# Author: Víctor Molina Ferreira (github.com/victormln)
# Creation date: 26/12/2016
# Version: 1.0
# 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 2 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
TODAY=$(date +%Y-%m-%d)
if ! command -v curl >/dev/null 2>&1; then
echo -e "$CURL_NOT_INSTALLED_MESSAGE"
exit 10
fi
if [[ "$TODAY" > "$LAST_UPDATE_CHECKED_IN" ]] || [ "$1" == "--update" ]; then
echo -e "$FORCE_UPDATE_MESSAGE"
if [ "$OS_TYPE" == "Darwin" ]; then
sed_cmd=(sed -i '')
else
sed_cmd=(sed -i)
fi
SCRIPT_DIRECTORY=$(cd $(dirname $0) && pwd)
"${sed_cmd[@]}" 's,^\(LAST_UPDATE_CHECKED_IN=\).*,\1'"$TODAY"',' "$SCRIPT_DIRECTORY"/conf/user.conf
if $SEARCH_OTA || [ "$1" == "--update" ]; then
last_version=$(curl -s --connect-timeout 5 https://raw.githubusercontent.com/victormln/alias/master/alias.sh | grep '# Version:' | cut -d: -f 2 | head -1)
if [ -z "$last_version" ]; then
echo -e "$NO_INTERNET_CONNECTION_MESSAGE"
else
last_version=${last_version//[[:blank:]]/}
last_version_without_dots=$(echo "$last_version" | tr -d ".")
actual_version_without_dots=$(echo "$CURRENT_VERSION" | tr -d ".")
if ((actual_version_without_dots < last_version_without_dots)); then
echo "###########################################"
echo -e "$NEW_UPDATE_MESSAGE${NC}"
echo "$YOU_HAVE_VERSION_MESSAGE: $CURRENT_VERSION"
echo "$AVAILABLE_VERSION_MESSAGE: $last_version"
echo "###########################################"
if $AUTOMATIC_UPDATE; then
echo "$AVAILABLE_VERSION_MESSAGE"
git stash >/dev/null
git pull origin master | tee >(echo "$UPDATING_PLEASE_WAIT_MESSAGE")
echo -e "$UPDATE_DONE_MESSAGE"
else
echo "$AVAILABLE_UPDATE_MESSAGE"
echo -en "$ASK_TO_DOWNLOAD_MESSAGE ${CYAN}$CONFIRM_OPTIONS${NC}: "; read -r want_to_update
if [ "$want_to_update" == "s" ] || [ "$want_to_update" == "y" ] || [ "$want_to_update" == "S" ] || [ "$want_to_update" == "Y" ]; then
git stash >/dev/null
git pull | tee >(echo "$UPDATING_PLEASE_WAIT_MESSAGE")
echo -e "$UPDATE_DONE_MESSAGE"
exit
else
echo -e "$NOT_UPDATED_MESSAGE"
echo -e "**************************"
fi
fi
fi
fi
fi
[ "$1" == "--update" ] && exit
fi