-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathomaha_cros_update.sh
executable file
·78 lines (72 loc) · 2.22 KB
/
omaha_cros_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
#!/bin/bash
# 2019-2020 (c) Muntashir Al-Islam. All rights reserved.
# Get script directory
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
[ command -v debug >/dev/null 2>&1 ] || source "${SCRIPT_DIR}/debug_utils.sh"
#
# Echo to stderr
#
function echo_stderr {
>&2 echo "$@"
}
# Print Usage
function print_usage {
echo_stderr "Usage: ${0##*/} [-chv]"
echo_stderr "Run ${0##*/} without any argument to update Chrome OS"
echo_stderr " -c, --check-only Only check for update."
echo_stderr " -h, --help This help page."
echo_stderr " -v, --version Print version information"
}
function main {
case "$1" in
'--check-only'|'-c')
if [ $UID -ne 0 ]; then
echo_stderr "Only root can do that."
exit 1
fi
. "${SCRIPT_DIR}/image_properties.sh"
. "$SCRIPT_DIR/omaha_request_params.sh"
. "$SCRIPT_DIR/omaha_request_action.sh"
OmahaRequestParams_Init
OmahaRequestAction_TransferComplete || print_env && exit 1
if [ ${ORA_update_exists} ]; then
echo_stderr "A new update is available!"
echo_stderr "Version: ${ORA_version}"
echo_stderr "Download URL: ${ORA_payload_urls[1]}"
exit 0
fi
;;
'--help'|'-h')
print_usage
exit 0
;;
'--version'|'-v')
. "$SCRIPT_DIR/version.sh"
echo_stderr "Version: ${OCU_VERSION}.${OCU_PATCH}"
exit 0
;;
'')
if [ $UID -ne 0 ]; then
echo_stderr "Only root can do that."
exit 1
fi
. "${SCRIPT_DIR}/image_properties.sh"
. "$SCRIPT_DIR/omaha_request_params.sh"
. "$SCRIPT_DIR/omaha_request_action.sh"
. "$SCRIPT_DIR/postinstall_runner_action.sh"
OmahaRequestParams_Init
OmahaRequestAction_TransferComplete || print_env && exit 1
OmahaResponseHandlerAction_PerformAction || print_env && exit 1
DownloadAction_PerformAction || print_env && exit 1
DownloadAction_TransferComplete || print_env && exit 1
PostinstallRunnerAction_PerformAction || print_env && exit 1
exit 0
;;
*)
echo_stderr "Illegal option $@."
print_usage
exit 1
esac
}
main "$@"
exit 0