-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpressvpn-version-upgrader.sh
executable file
·99 lines (86 loc) · 3.19 KB
/
expressvpn-version-upgrader.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
#!/bin/bash
#: Title :expressvpn-version-upgrader.sh
#: Date :2021-01-26
#: Author : "Damola Adebayo" <adebayo10k@domain.com>
#: Description :use to safely update this frequently upgraded,
#: Description :not apt- or snap- package managed program
command_fullpath="$(readlink -f $0)"
command_basename="$(basename $command_fullpath)"
command_dirname="$(dirname $command_fullpath)"
# verify existence of library dependencies
if [ -d "${command_dirname}/shared-functions-library" ] && \
[ -n "$(ls ${command_dirname}/shared-functions-library | grep 'shared-bash-')" ]
then
for file in "${command_dirname}/shared-functions-library"/shared-bash-*
do
source "$file"
done
else
# return a non-zero exit code with native exit
echo "Required file not found. Returning non-zero exit code. Exiting now..."
exit 1
fi
### Library functions have now been read-in ###
# verify existence of included dependencies
if [ -d "${command_dirname}/includes" ] && \
[ -n "$(ls ${command_dirname}/includes)" ]
then
for file in "${command_dirname}/includes"/*
do
source "$file"
done
else
msg="Required file not found. Returning non-zero exit code. Exiting now..."
lib10k_exit_with_error "$E_REQUIRED_FILE_NOT_FOUND" "$msg"
fi
### Included file functions have now been read-in ###
# CALLS TO FUNCTIONS DECLARED IN helper.inc.sh
#==========================
check_all_program_preconditions
function main(){
#########################
# GLOBAL VARIABLE DECLARATIONS:
#########################
pkg_file_url=
pkg_sig_file_url=
identified_pkg_file=
identified_pkg_sig_file=
verified_pkg_file=
original_dir=
#########################
# FUNCTION CALLS:
#########################
# CALLS TO FUNCTIONS DECLARED IN setup.inc.sh
#==========================
# no point going further if this state ...
check_for_installed_public_key
# CALLS TO FUNCTIONS DECLARED IN controller.inc.sh
#==========================
# user manually selects which ...
get_user_platform_choice "${os_platforms[@]}"
# CALLS TO FUNCTIONS DECLARED IN setup.inc.sh
#==========================
# retreive the url string for the latest package and compare with existing version.
get_currently_installed_pkg_version "$user_selected_os_platform"
#test_call_get_user_continue_response
get_available_pkg_file_url "$user_selected_os_platform"
## cURL the package file to the Downloads directory.
download_pkg_file "$pkg_file_url" "$pkg_sig_file_url" "$downloads_dir"
# identify both package and package signature files
identify_downloaded_pkg_file "$pkg_file_url" "$pkg_sig_file_url" "$downloads_dir" "$pkg_file_regex" "$pkg_sig_file_regex"
## then to verify its' signature against the expressvpn public key
verify_downloaded_pkg_file "$identified_pkg_file" "$identified_pkg_sig_file"
#
## CALLS TO FUNCTIONS DECLARED IN pkg-installation.inc.sh
##==========================
#do the installation
install_package "$verified_pkg_file"
#
## CALLS TO FUNCTIONS DECLARED IN cleanup.inc.sh
##==========================
# remove the downloaded files after installation
cleanup_and_revert "$original_dir" "$downloads_dir" "$pkg_file_regex" "$pkg_sig_file_regex"
# try to restart the network by brute
reconnect_expressvpn
} # end main
main "$@"; exit $?