blob: 4c69713405881b8f474e5ea382c4fa667cca9741 [file] [log] [blame]
Gunnar Millsbde58222018-01-22 18:29:31 -06001#!/bin/bash
2set -eo pipefail
Adriana Kobylaka290eff2017-06-27 09:39:57 -05003
Eddie James63fa6112018-03-01 09:55:07 -06004# Check if BMC is currently booted from the alternate chip; returns "1" if true
5check_if_alt() {
6 res=0
7 wdiof_cardreset_bit=5
8 wdiof_cardreset=$((1 << $wdiof_cardreset_bit))
9
10 # Read the systemd watchdog config to see which device we should use
11 line=$(cat /etc/systemd/system.conf | grep "WatchdogDevice")
12 if [ ! -z ${line} ]; then
13 watchdog_device=${line##WatchdogDevice=/dev/}
14
15 # Check for legacy symlink to /dev/watchdog0
16 if [ ${watchdog_device} == "watchdog" ]; then
17 watchdog_device="watchdog0"
18 fi
19
20 # Check the bootstatus to see if we've been reset
21 path="/sys/class/watchdog/${watchdog_device}/bootstatus"
22 if [ -f ${path} ]; then
23 bootstatus=$(cat ${path})
24 res=$((($bootstatus & $wdiof_cardreset) >> $wdiof_cardreset_bit))
25 fi
26 fi
27
28 echo "${res}"
29}
30
Adriana Kobylak54c9f792017-08-17 14:08:20 -050031# Get the root mtd device number (mtdX) from "/dev/ubiblockX_Y on /"
32findrootmtd() {
33 rootmatch=" on / "
34 m="$(mount | grep "${rootmatch}" | grep "ubiblock")"
35 m="${m##*ubiblock}"
36 m="${m%_*}"
37 if [ -z "${m}" ]; then
38 # default to bmc mtd (0)
39 m=0
40 fi
41 echo "mtd${m}"
42}
43
Adriana Kobylak582bdea2017-08-22 14:51:18 -050044findrootubi() {
45 rootmatch=" on / "
46 m="$(mount | grep "${rootmatch}")"
47 m="${m##*ubiblock}"
48 m="${m% on*}"
49 echo "ubi${m}"
50}
51
Adriana Kobylaka290eff2017-06-27 09:39:57 -050052# Get the mtd device number (mtdX)
53findmtd() {
54 m="$(grep -xl "$1" /sys/class/mtd/*/name)"
55 m="${m%/name}"
56 m="${m##*/}"
57 echo "${m}"
58}
59
Eddie Jamesa804bc42018-02-01 16:46:40 -060060# Get the mtd device number only (return X of mtdX)
61findmtdnum() {
62 m="$(findmtd "$1")"
63 m="${m##mtd}"
64 echo "${m}"
65}
66
Adriana Kobylaka290eff2017-06-27 09:39:57 -050067# Get the ubi device number (ubiX_Y)
68findubi() {
69 u="$(grep -xl "$1" /sys/class/ubi/ubi?/subsystem/ubi*/name)"
70 u="${u%/name}"
71 u="${u##*/}"
72 echo "${u}"
73}
74
Adriana Kobylakac5ce002017-09-13 12:59:26 -050075# Get the ubi device number (ubiX_Y) on a specific mtd
Adriana Kobylak582bdea2017-08-22 14:51:18 -050076findubi_onmtd() {
Adriana Kobylakac5ce002017-09-13 12:59:26 -050077 u="$(grep -xl "$1" /sys/class/ubi/ubi"$2"/subsystem/ubi"$2"*/name)"
78 u="${u%/name}"
79 u="${u##*/}"
80 echo "${u}"
81}
82
83# Get all ubi device names on a specific mtd that match requested string
84findubiname_onmtd() {
Adriana Kobylak582bdea2017-08-22 14:51:18 -050085 u="$(grep -h "$1" /sys/class/ubi/ubi"$2"/subsystem/ubi"$2"*/name)"
86 u="${u%/name}"
87 u="${u##*/}"
88 echo "${u}"
89}
90
Adriana Kobylakac5ce002017-09-13 12:59:26 -050091# Get the name from the requested ubiX_Y volume
92findname() {
93 n="$(cat /sys/class/ubi/$1/name)"
94 echo "${n}"
95}
96
Adriana Kobylak582bdea2017-08-22 14:51:18 -050097# Make space on flash before creating new volumes. This can be enhanced
98# determine current flash usage. For now only keep a "keepmax" number of them
99ubi_remove_volumes()
100{
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500101 rootubi="$(findrootubi)"
Adriana Kobylakac5ce002017-09-13 12:59:26 -0500102 rootname="$(findname "${rootubi}")"
103 rootversion="${rootname##*-}"
104 rootkernel="kernel-${rootversion}"
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500105
106 # Just keep max number of volumes before updating, don't delete the version
107 # the BMC is booted from, and when a version is identified to be deleted,
108 # delete both the rofs and kernel volumes for that version.
Adriana Kobylakac5ce002017-09-13 12:59:26 -0500109 rmnames="$(findubiname_onmtd "${name%-*}-" "${ro}")"
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500110 rmnames=(${rmnames})
111 ubicount="${#rmnames[@]}"
112 while [ ${ubicount} -ge ${keepmax} ]; do
113 # Loop through existing volumes and skip currently active ones
114 for (( index=0; index<${#rmnames[@]}; index++ )); do
115 rmname="${rmnames[${index}]}"
116 rmversion="${rmname##*-}"
Adriana Kobylakac5ce002017-09-13 12:59:26 -0500117 [ "${rmversion}" == "${version}" ] && continue
118 rmubi="$(findubi_onmtd "rofs-${rmversion}" "${ro}")"
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500119 if [[ ( "${rmubi}" != "${rootubi}" ) &&
Adriana Kobylakac5ce002017-09-13 12:59:26 -0500120 ( "${rmname}" != "${rootkernel}" ) ]]; then
121 ubi_remove "rofs-${rmversion}" "${ro}"
122 ubi_remove "kernel-${rmversion}" "${ro}"
123 # Remove priority value
124 fw_setenv "${rmversion}"
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500125 break
126 fi
127 done
128 # Decrease count regardless to avoid an infinite loop
129 (( ubicount-- ))
130 done
131}
132
Adriana Kobylaka290eff2017-06-27 09:39:57 -0500133ubi_rw() {
134 rwmtd="$(findmtd "${reqmtd}")"
135 rw="${rwmtd#mtd}"
136 ubidev="/dev/ubi${rw}"
137
Adriana Kobylakf846e172018-03-06 14:12:03 -0600138 # Update rwfs_size, check imgsize was specified, otherwise it'd clear the var
139 if [ ! -z "$imgsize" ]; then
140 rwsize="$(fw_printenv -n rwfs_size 2>/dev/null)" || true
141 if [[ "${imgsize}" != "${rwsize}" ]]; then
142 fw_setenv rwfs_size "${imgsize}"
143 fi
Adriana Kobylakb7059982018-02-14 16:35:30 -0600144 fi
145
Adriana Kobylaka290eff2017-06-27 09:39:57 -0500146 vol="$(findubi "${name}")"
147 if [ -z "${vol}" ]; then
Adriana Kobylakb7059982018-02-14 16:35:30 -0600148 ubimkvol "${ubidev}" -N "${name}" -s "${imgsize}"
Adriana Kobylaka290eff2017-06-27 09:39:57 -0500149 fi
150}
151
Adriana Kobylake9939492017-07-11 11:34:23 -0500152ubi_ro() {
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500153 keepmax=2 # Default 2 volumes per mtd
Adriana Kobylake9939492017-07-11 11:34:23 -0500154 romtd="$(findmtd "${reqmtd}")"
Adriana Kobylak54c9f792017-08-17 14:08:20 -0500155 romtd2="$(findmtd "${reqmtd2}")"
156
157 if [ ! "${romtd}" == "${romtd2}" ]; then
158 # Request to use alternate mtd device, choose the non-root one
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500159 keepmax=1 # 1 volume on each of the requested mtds
Adriana Kobylak54c9f792017-08-17 14:08:20 -0500160 rootmtd="$(findrootmtd)"
161 if [ "${rootmtd}" == "${romtd}" ]; then
162 romtd="${romtd2}"
163 fi
164 fi
Adriana Kobylake9939492017-07-11 11:34:23 -0500165 ro="${romtd#mtd}"
166 ubidev="/dev/ubi${ro}"
167
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500168 ubi_remove_volumes
169
Michael Tritzd8ac7f22018-02-07 17:04:07 -0600170 if [ -z "${imgfile}" ]; then
171 echo "Unable to create read-only volume. Image file not specified."
172 return 1
173 fi
174
175 # Create a ubi volume, dynamically sized to fit BMC image if size unspecified
176 img="/tmp/images/${version}/${imgfile}"
177 imgsize="$(stat -c '%s' ${img})"
178
Adriana Kobylake9939492017-07-11 11:34:23 -0500179 vol="$(findubi "${name}")"
Adriana Kobylakddc9dca2017-09-05 15:44:35 -0500180 if [ ! -z "${vol}" ]; then
181 # Allow a duplicate kernel volume on the alt mtd
182 if [[ "${name}" =~ "kernel" ]]; then
Adriana Kobylakac5ce002017-09-13 12:59:26 -0500183 vol="$(findubi_onmtd "${name}" "${ro}")"
Adriana Kobylakddc9dca2017-09-05 15:44:35 -0500184 fi
185 fi
Adriana Kobylake9939492017-07-11 11:34:23 -0500186 if [ -z "${vol}" ]; then
187 ubimkvol "${ubidev}" -N "${name}" -s "${imgsize}" --type=static
188 vol="$(findubi "${name}")"
189 fi
190}
191
192# Squashfs images need a ubi block
193ubi_block() {
194 vol="$(findubi "${name}")"
195 ubidevid="${vol#ubi}"
196 block="/dev/ubiblock${ubidevid}"
197 if [ ! -e "$block" ]; then
198 ubiblock --create "/dev/ubi${ubidevid}"
199 fi
200}
201
202ubi_updatevol() {
203 vol="$(findubi "${name}")"
204 ubidevid="${vol#ubi}"
205 img="/tmp/images/${version}/${imgfile}"
206 ubiupdatevol "/dev/ubi${ubidevid}" "${img}"
207}
208
Michael Tritza694eed2017-07-13 16:26:15 -0500209ubi_remove() {
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500210 rmname="$1"
Adriana Kobylakac5ce002017-09-13 12:59:26 -0500211 rmmtd="$2"
212 if [ ! -z "${rmmtd}" ]; then
213 vol="$(findubi_onmtd "${rmname}" "${rmmtd}")"
214 else
215 vol="$(findubi "${rmname}")"
216 fi
Michael Tritza694eed2017-07-13 16:26:15 -0500217
218 if [ ! -z "$vol" ]; then
219 vol="${vol%_*}"
220
Saqib Khanf8d2a662017-09-07 13:57:43 -0500221 if grep -q "$rmname" /proc/mounts; then
222 mountdir=$(grep "$rmname" /proc/mounts | cut -d " " -f 2)
Michael Tritza694eed2017-07-13 16:26:15 -0500223 umount "$mountdir"
224 rm -r "$mountdir"
225 fi
226
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500227 ubirmvol "/dev/${vol}" -N "$rmname"
Michael Tritza694eed2017-07-13 16:26:15 -0500228 fi
229}
230
Michael Tritz18781172017-09-21 00:41:15 -0500231ubi_cleanup() {
232 # When ubi_cleanup is run, it expects one or no active version.
233 activeVersion=$(busctl --list --no-pager tree \
234 xyz.openbmc_project.Software.BMC.Updater | \
235 grep /xyz/openbmc_project/software/ | tail -c 9)
236
237 if [[ -z "$activeVersion" ]]; then
238 vols=$(ubinfo -a | grep -e "kernel-" -e "rofs-" | cut -c 14-)
239 vols=(${vols})
240 else
241 vols=$(ubinfo -a | grep -e "kernel-" -e "rofs-" | \
242 grep -v "$activeVersion" | cut -c 14-)
243 vols=(${vols})
244 fi
245
246 for (( index=0; index<${#vols[@]}; index++ )); do
247 ubi_remove ${vols[index]}
248 done
249}
250
Saqib Khanbb93e642017-08-10 11:24:38 -0500251remount_ubi() {
Saqib Khand6d1c442017-09-06 23:24:40 -0500252 bmcmtd="$(findmtd "bmc")"
253 altbmcmtd="$(findmtd "alt-bmc")"
254 mtds="${bmcmtd: -1}","${altbmcmtd: -1}"
Saqib Khanbb93e642017-08-10 11:24:38 -0500255
256 IFS=',' read -r -a mtds <<< "$mtds"
257 mtds=($(echo "${mtds[@]}" | tr ' ' '\n' | sort -u | tr '\n' ' '))
258 for mtd in ${mtds[@]}; do
Saqib Khanbb93e642017-08-10 11:24:38 -0500259 # Get information on all ubi volumes
260 ubinfo=$(ubinfo -d ${mtd})
261 presentVolumes=${ubinfo##*:}
262 IFS=', ' read -r -a array <<< "$presentVolumes"
263 for element in ${array[@]}; do
264 elementProperties=$(ubinfo -d $mtd -n $element)
265 # Get ubi volume name by getting rid of additional properties
266 name=${elementProperties#*Name:}
267 name="${name%Character*}"
268 name="$(echo -e "${name}" | tr -d '[:space:]')"
269
Adriana Kobylak2c7c8d12017-08-21 11:00:56 -0500270 if [[ ${name} == rofs-* ]]; then
Saqib Khanbb93e642017-08-10 11:24:38 -0500271 mountdir="/media/${name}"
Saqib Khand793f2d2017-09-13 14:05:31 -0500272
273 if [ ! -d ${mountdir} ]; then
274 mkdir -p "${mountdir}"
Gunnar Millsbde58222018-01-22 18:29:31 -0600275 # U-Boot will create the ubiblock for the running version, but not
276 # for the version on the other chip
277 if [ ! -e "/dev/ubiblock${mtd}_${element}" ]; then
278 ubiblock --create /dev/ubi${mtd}_${element}
279 fi
Saqib Khand793f2d2017-09-13 14:05:31 -0500280 mount -t squashfs -o ro "/dev/ubiblock${mtd}_${element}" "${mountdir}"
281 fi
Saqib Khanbb93e642017-08-10 11:24:38 -0500282 fi
283 done
284 done
285}
286
Adriana Kobylak8cdb82e2017-08-22 14:18:39 -0500287# Read the current env variable and set it on the alternate boot env
288copy_env_var_to_alt() {
289 varName=$1
290 value="$(fw_printenv -n "${varName}")"
291 fw_setenv -c /etc/alt_fw_env.config "${varName}" "${value}"
292}
293
Eddie Jamesa804bc42018-02-01 16:46:40 -0600294# When the alternate bmc chip boots, u-boot thinks its the primary mtdX.
295# Therefore need to swap the chip numbers when copying the ubiblock and root to
296# alternate bmc u-boot environment.
297copy_ubiblock_to_alt() {
298 value="$(fw_printenv -n ubiblock)"
299 bmcNum="$(findmtdnum "bmc")"
300 altNum="$(findmtdnum "alt-bmc")"
301 replaceAlt="${value/${altNum},/${bmcNum},}"
302
303 if [[ "${value}" == "${replaceAlt}" ]]; then
304 replaceBmc="${value/${bmcNum},/${altNum},}"
305 value=${replaceBmc}
306 else
307 value=${replaceAlt}
308 fi
309
310 fw_setenv -c /etc/alt_fw_env.config ubiblock "${value}"
311}
312
313copy_root_to_alt() {
314 value="$(fw_printenv -n root)"
315 bmcNum="$(findmtdnum "bmc")"
316 altNum="$(findmtdnum "alt-bmc")"
317 replaceAlt="${value/${altNum}_/${bmcNum}_}"
318
319 if [[ "${value}" == "${replaceAlt}" ]]; then
320 replaceBmc="${value/${bmcNum}_/${altNum}_}"
321 value=${replaceBmc}
322 else
323 value=${replaceAlt}
324 fi
325
326 fw_setenv -c /etc/alt_fw_env.config root "${value}"
327}
328
Michael Tritza694eed2017-07-13 16:26:15 -0500329ubi_setenv() {
Michael Tritz3e0b0672017-12-15 15:35:14 -0600330 # The U-Boot environment maintains two banks of environment variables.
331 # The banks need to be consistent with each other to ensure that these
332 # variables can reliably be read from file. In order to guarantee that the
333 # banks are both correct, we need to run fw_setenv twice.
Adriana Kobylak8cdb82e2017-08-22 14:18:39 -0500334 variable=$1
Michael Tritz8863f702017-08-25 15:47:07 -0500335 if [[ "$variable" == *"="* ]]; then
336 varName="${variable%=*}"
337 value="${variable##*=}"
Adriana Kobylakf5ac32c2018-02-09 11:21:57 -0600338 # Write only if var is not set already to the requested value
Adriana Kobylakffd46ba2018-03-02 14:16:43 -0600339 currentValue="$(fw_printenv -n "${varName}" 2>/dev/null)" || true
Adriana Kobylakf5ac32c2018-02-09 11:21:57 -0600340 if [[ "${currenValue}" != "${value}" ]]; then
341 fw_setenv "$varName" "$value"
342 fw_setenv "$varName" "$value"
343 fi
Michael Tritz8863f702017-08-25 15:47:07 -0500344 else
345 fw_setenv "$variable"
Michael Tritz3e0b0672017-12-15 15:35:14 -0600346 fw_setenv "$variable"
Michael Tritz8863f702017-08-25 15:47:07 -0500347 fi
Michael Tritza694eed2017-07-13 16:26:15 -0500348}
349
Adriana Kobylak1fa612c2017-08-17 21:56:14 -0500350mtd_write() {
351 flashmtd="$(findmtd "${reqmtd}")"
352 img="/tmp/images/${version}/${imgfile}"
353 flashcp -v ${img} /dev/${flashmtd}
354}
355
Adriana Kobylake2fd46d2017-09-05 12:38:19 -0500356backup_env_vars() {
357 copy_env_var_to_alt kernelname
Eddie Jamesa804bc42018-02-01 16:46:40 -0600358 copy_ubiblock_to_alt
359 copy_root_to_alt
Adriana Kobylake2fd46d2017-09-05 12:38:19 -0500360}
361
362update_env_vars() {
363 vol="$(findubi rofs-"${version}")"
364 if [ -z "${vol}" ]; then
365 return 1
366 fi
367 ubidevid="${vol#ubi}"
368 block="/dev/ubiblock${ubidevid}"
369 if [ ! -e "${block}" ]; then
370 return 1
371 fi
372 ubi_setenv "kernelname=kernel-${version}"
373 ubi_setenv "ubiblock=$(echo "${ubidevid}" | sed 's/_/,/')"
374 ubi_setenv "root=${block}"
375}
376
Saqib Khandfc9b0c2017-09-08 10:10:08 -0500377#TODO: Replace the implementation with systemd-inhibitors lock
378# once systemd/systemd#949 is resolved
379rebootguardenable() {
380 dir="/run/systemd/system/"
381 file="reboot-guard.conf"
382 units=("reboot" "poweroff" "halt")
383
384 for unit in "${units[@]}"; do
385 mkdir -p ${dir}${unit}.target.d
386 echo -e "[Unit]\nRefuseManualStart=yes" >> ${dir}${unit}.target.d/${file}
387 done
388}
389
390#TODO: Replace the implementation with systemd-inhibitors lock
391# once systemd/systemd#949 is resolved
392rebootguarddisable() {
393 dir="/run/systemd/system/"
394 file="reboot-guard.conf"
395 units=("reboot" "poweroff" "halt")
396
397 for unit in "${units[@]}"; do
398 rm -rf ${dir}${unit}.target.d/${file}
399 done
400}
401
Adriana Kobylakddc9dca2017-09-05 15:44:35 -0500402# Create a copy in the alt mtd
403create_vol_in_alt() {
404 alt="alt-bmc"
405 altmtd="$(findmtd "${alt}")"
406 if [ ! -z "${altmtd}" ]; then
407 reqmtd="${alt}"
408 reqmtd2="${alt}"
409 ubi_ro
410 ubi_updatevol
411 fi
412}
413
Eddie James63fa6112018-03-01 09:55:07 -0600414# Copy contents of one MTD device to another
415mtd_copy() {
416 in=$1
417 out=$2
418
419 # Must erase MTD first to prevent corruption
420 flash_eraseall "${out}"
421 dd if="${in}" of="${out}"
422}
423
424mirroruboot() {
425 bmc="$(findmtd "u-boot")"
426 bmcdev="/dev/${bmc}"
427 alt="$(findmtd "alt-u-boot")"
428 altdev="/dev/${alt}"
429
430 checksum_bmc="$(md5sum "${bmcdev}")"
431 checksum_bmc="${checksum_bmc% *}"
432 checksum_alt="$(md5sum "${altdev}")"
433 checksum_alt="${checksum_alt% *}"
434
435 if [[ "${checksum_bmc}" != "${checksum_alt}" ]]; then
436 bmcenv="$(findmtd "u-boot-env")"
437 bmcenvdev="/dev/${bmcenv}"
438 altenv="$(findmtd "alt-u-boot-env")"
439 altenvdev="/dev/${altenv}"
440 is_alt="$(check_if_alt)"
441
442 if [[ "${is_alt}" == "1" ]]; then
443 echo "Mirroring U-boot; alt to bmc"
444 mtd_copy "${altdev}" "${bmcdev}"
445 mtd_copy "${altenvdev}" "${bmcenvdev}"
446 else
447 echo "Mirroring U-boot; bmc to alt"
448 mtd_copy "${bmcdev}" "${altdev}"
449 mtd_copy "${bmcenvdev}" "${altenvdev}"
450 fi
451
452 copy_ubiblock_to_alt
453 copy_root_to_alt
454 fi
455}
456
Adriana Kobylaka290eff2017-06-27 09:39:57 -0500457case "$1" in
Adriana Kobylak1fa612c2017-08-17 21:56:14 -0500458 mtduboot)
459 reqmtd="$2"
460 version="$3"
461 imgfile="image-u-boot"
462 mtd_write
463 ;;
Adriana Kobylaka290eff2017-06-27 09:39:57 -0500464 ubirw)
465 reqmtd="$2"
466 name="$3"
Adriana Kobylakb7059982018-02-14 16:35:30 -0600467 imgsize="$4"
Adriana Kobylaka290eff2017-06-27 09:39:57 -0500468 ubi_rw
469 ;;
Adriana Kobylake9939492017-07-11 11:34:23 -0500470 ubiro)
Adriana Kobylak54c9f792017-08-17 14:08:20 -0500471 reqmtd="$(echo "$2" | cut -d "+" -f 1)"
472 reqmtd2="$(echo "$2" | cut -d "+" -f 2)"
Adriana Kobylake9939492017-07-11 11:34:23 -0500473 name="$3"
474 version="$4"
475 imgfile="image-rofs"
Adriana Kobylake9939492017-07-11 11:34:23 -0500476 ubi_ro
Adriana Kobylake9939492017-07-11 11:34:23 -0500477 ubi_updatevol
Adriana Kobylak8cdb82e2017-08-22 14:18:39 -0500478 ubi_block
Adriana Kobylake9939492017-07-11 11:34:23 -0500479 ;;
480 ubikernel)
Adriana Kobylak54c9f792017-08-17 14:08:20 -0500481 reqmtd="$(echo "$2" | cut -d "+" -f 1)"
482 reqmtd2="$(echo "$2" | cut -d "+" -f 2)"
Adriana Kobylake9939492017-07-11 11:34:23 -0500483 name="$3"
484 version="$4"
485 imgfile="image-kernel"
Adriana Kobylake9939492017-07-11 11:34:23 -0500486 ubi_ro
487 ubi_updatevol
Adriana Kobylakddc9dca2017-09-05 15:44:35 -0500488 create_vol_in_alt
Adriana Kobylake9939492017-07-11 11:34:23 -0500489 ;;
Michael Tritza694eed2017-07-13 16:26:15 -0500490 ubiremove)
491 name="$2"
Adriana Kobylak582bdea2017-08-22 14:51:18 -0500492 ubi_remove "${name}"
Michael Tritza694eed2017-07-13 16:26:15 -0500493 ;;
Michael Tritz18781172017-09-21 00:41:15 -0500494 ubicleanup)
495 ubi_cleanup
496 ;;
Michael Tritza694eed2017-07-13 16:26:15 -0500497 ubisetenv)
Adriana Kobylak8cdb82e2017-08-22 14:18:39 -0500498 ubi_setenv "$2"
Michael Tritza694eed2017-07-13 16:26:15 -0500499 ;;
Saqib Khanbb93e642017-08-10 11:24:38 -0500500 ubiremount)
501 remount_ubi
502 ;;
Saqib Khan7e4a3f22017-09-12 09:23:28 -0500503 createenvbackup)
Adriana Kobylake2fd46d2017-09-05 12:38:19 -0500504 backup_env_vars
505 ;;
Saqib Khan7e4a3f22017-09-12 09:23:28 -0500506 updateubootvars)
Adriana Kobylake2fd46d2017-09-05 12:38:19 -0500507 version="$2"
508 update_env_vars
509 ;;
Saqib Khandfc9b0c2017-09-08 10:10:08 -0500510 rebootguardenable)
511 rebootguardenable
512 ;;
513 rebootguarddisable)
514 rebootguarddisable
515 ;;
Eddie James63fa6112018-03-01 09:55:07 -0600516 mirroruboot)
517 mirroruboot
518 ;;
Adriana Kobylaka290eff2017-06-27 09:39:57 -0500519 *)
520 echo "Invalid argument"
521 exit 1
522 ;;
523esac