blob: c0974a00d18de2ea205ad8a1522846bd1890f26b [file] [log] [blame]
William A. Kennington IIId230e862022-05-09 15:24:22 -07001#!/bin/bash
2# Copyright 2022 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[ -n "${gbmc_psu_hardreset-}" ] && return
17
18gbmc_psu_hardreset_needed=
19
20gbmc_psu_hardreset_hook() {
21 # We don't always need a powercycle, allow skipping
22 if [ -z "${gbmc_psu_hardreset_needed-}" ]; then
23 echo "Skipping tray powercycle" >&2
24 return 0
25 fi
26
27 echo "Powercycling" >&2
28 systemctl start gbmc-psu-hardreset.target || return
29
30 # Ensure that we don't continue the DHCP process while waiting for the
31 # powercycle.
32 exit 0
33}
34
35GBMC_BR_DHCP_HOOKS+=(gbmc_psu_hardreset_hook)
36
37gbmc_psu_hardreset=1