blob: df4662f6d83ff7c5b21aa27a553995f55ff6e7c1 [file] [log] [blame]
William A. Kennington III32e440d2021-12-03 18:19:07 -08001#!/bin/bash
2# Copyright 2021 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16[ -z "${inplace_gbmc_upgrade-}" ] || exit
17
18# SC doesn't know another file depends on this variable
19# shellcheck disable=SC2034
20GBMC_UPGRADE_IMG=/run/initramfs/bmc-image
21
22gbmc_upgrade_internal() {
23 local version
24 version="$(gbmc_upgrade_fetch)" || return
25
26 echo "IMG Version: $version" >&2
27 local active_version
28 active_version="$(inplace-gbmc-version.sh)" || return
29 echo "Active Version: $active_version" >&2
30 if [[ "$version" == "$active_version" ]]; then
31 echo 'Version already active' >&2
32 return 0
33 fi
34
35 echo 'Verifying image' >&2
36 systemctl start inplace-gbmc-verify || return
37 echo 'Rebooting to perform update' >&2
38 reboot || return
39}
40
41inplace_gbmc_upgrade=1