| #!/bin/bash |
| |
| # Statically setting the BM_MODE |
| BM_MODE="@BM_MODE@" |
| |
| GPIO_CHIP="@GPIO_CHIP@" |
| GPIO_LINE="@GPIO_LINE@" |
| ENABLE_BM_FILE="@ENABLE_BM_FILE@" |
| BMREADY_FILE="@BMREADY_FILE@" |
| |
| function hide_boot_drive_in_bm_mode() { |
| # In Bare Metal mode, power off the boot drive |
| if [[ "$BM_MODE" -eq "1" || -f "$ENABLE_BM_FILE" ]]; then |
| # Turn off the power to the boot drive |
| # and keep asserting the power down |
| if ! gpioset --mode=signal --background "$GPIO_CHIP" "$GPIO_LINE"=0; then |
| echo "Unable to set the GPIO to hide cSSD/cnSSD - skip adding ${BMREADY_FILE}" |
| exit 1 |
| fi |
| echo "Successfully set the GPIO to hide cSSD/cnSSD creating ${BMREADY_FILE}" |
| # Disable usb network |
| ln -s /dev/null /run/systemd/system/google-usb-dynamic.service 2> /dev/null |
| systemctl daemon-reload |
| touch "${BMREADY_FILE}" |
| else |
| # Mask services that could disable ipmi |
| ln -s /dev/null /run/systemd/system/host-gpio-monitor.service 2> /dev/null |
| systemctl daemon-reload |
| |
| # Turn on the power to the boot drive |
| echo "Powering on the cSSD/cnSSD as we are not in BM mode - remove ${BMREADY_FILE}" |
| rm -f "${BMREADY_FILE}" |
| gpioset --mode=time -s 1 "$GPIO_CHIP" "$GPIO_LINE"=1 |
| fi |
| } |
| |
| hide_boot_drive_in_bm_mode |
| |
| exit 0 |