-
Notifications
You must be signed in to change notification settings - Fork 405
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·203 lines (169 loc) · 4.54 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·203 lines (169 loc) · 4.54 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
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
#!/bin/sh
# Copyright (C) 2021 Alex Doyle <adoyle@nvidia.com>
# Copyright (C) 2013-2014,2016 Curt Brune <curt@cumulusnetworks.com>
# Copyright (C) 2015,2017 david_yang <david_yang@accton.com>
#
# SPDX-License-Identifier: GPL-2.0
cd $(dirname $0)
[ -r ./machine-build.conf ] || {
echo "ERROR: machine-build.conf file is missing."
exit 1
}
. ./machine-build.conf
# Default implementation is no additional args
parse_arg_arch()
{
return 1
}
[ -r ./update-type ] || {
echo "ERROR: update-type file is missing."
exit 1
}
. ./update-type
if [ "$update_type" = "onie" ] ; then
[ -r ./install-arch ] || {
echo "ERROR: install-arch file is missing."
exit 1
}
. ./install-arch
fi
# get running machine from conf file
[ -r /etc/machine.conf ] && . /etc/machine.conf
# for backward compatibility if running machine_rev is empty assume it
# is 0.
true ${onie_machine_rev=0}
# for backward compatibility if running onie_conf_version is empty
# assume it is 0.
true ${onie_config_version=0}
# for backward compatibility, if running onie_build_machine is empty
# assign the value from onie_machine.
onie_build_machine=${onie_build_machine:-$onie_machine}
args="hivfqxj${args_arch}"
usage()
{
cat <<EOF
$update_label Installer -- Installs/Updates $update_label
COMMAND LINE OPTIONS
-h
Help. Print this message.
-v
Be verbose. Print what is happening.
-q
Be quiet. Do not print what is happening.
-x
Extract image to a temporary directory.
-i
Dump image information.
-f
Force ONIE update opteration, bypassing any safety
checks.
-j
Debug.
$usage_arch
EOF
}
verbose=no
force=no
quiet=no
while getopts "$args" a ; do
case $a in
h)
usage
exit 0
;;
v)
verbose=yes
cmd_verbose=-v
quiet=no
;;
f)
force=yes
;;
q)
quiet=yes
verbose=no
;;
i)
# Dump the image information
cat ./machine-build.conf
exit 0
;;
j)
set -x
;;
*)
parse_arg_arch "$a" "$OPTARG" || {
echo "Unknown argument: $a"
usage
exit 1
}
;;
esac
done
[ -r onie-update.tar.xz ] || {
echo "ERROR:$update_label: update tar file is missing."
exit 1
}
xz -d -c onie-update.tar.xz | tar -xf -
check_machine_image()
{
if [ "$onie_build_machine" != "$image_build_machine" ] ; then
fail=yes
fi
if [ "$onie_machine_rev" != "$image_machine_rev" ] ; then
fail=yes
fi
if [ "$onie_arch" != "$image_arch" ] ; then
fail=yes
fi
}
update_syseeprom()
{
# Set platform name and ONIE version to sys_eeprom.
if [ -x /usr/bin/onie-syseeprom ] ; then
local syseeprom_log=$(mktemp)
onie-syseeprom \
-s 0x29="$image_version" \
> $syseeprom_log 2>&1 || {
echo "ERROR: Problems accessing sys_eeprom"
cat $syseeprom_log && rm -f $syseeprom_log
exit 1
}
[ "$verbose" = "yes" ] && cat $syseeprom_log
rm -f $syseeprom_log
fi
}
set_default_passwd()
{
# If secure boot extended is enabled, there is an option
# to set default password.
# This function is a template, and it is expected that the
# machine's install-platform file will have an instance of
# this function to override it.
# The template defaults to doing nothing.
return 0
}
[ -r ./install-platform ] && . ./install-platform
fail=
check_machine_image
if [ "$fail" = "yes" ] && [ "$force" = "no" ] ; then
echo "ERROR:$update_label: Machine mismatch"
echo "Running platform : ${onie_arch}-${onie_build_machine}-r${onie_machine_rev}"
echo "Update Image platform: ${image_arch}-${image_build_machine}-r${image_machine_rev}"
echo "Source URL: $onie_exec_url"
exit 1
fi
[ "$quiet" = "no" ] && echo "$update_label: Version : $image_version"
[ "$quiet" = "no" ] && echo "$update_label: Architecture : $image_arch"
[ "$quiet" = "no" ] && echo "$update_label: Machine : $image_build_machine"
[ "$quiet" = "no" ] && echo "$update_label: Machine Rev : $image_machine_rev"
[ "$quiet" = "no" ] && echo "$update_label: Config Version: $image_config_version"
[ "$quiet" = "no" ] && echo "$update_label: Build Date : $image_build_date"
# arch specific install method
install_image "$@"
ret=$?
if [ $ret -ne 0 ] ; then
echo "ERROR:$update_label: update failed."
fi
cd /
exit $ret