1#!/bin/sh 2# 3# SPDX-License-Identifier: GPL-2.0-only 4# 5# Simple script to show a manual power prompt for when you want to use 6# automated hardware testing with testimage.bbclass but you don't have a 7# web-enabled power strip or similar to do the power on/off/cycle. 8# 9# You can enable it by enabling testimage (see the Yocto Project 10# Development manual "Performing Automated Runtime Testing" section) 11# and setting the following in your local.conf: 12# 13# TEST_POWERCONTROL_CMD = "${COREBASE}/scripts/contrib/dialog-power-control" 14# 15 16PROMPT="" 17while true; do 18 case $1 in 19 on) 20 PROMPT="Please turn device power on";; 21 off) 22 PROMPT="Please turn device power off";; 23 cycle) 24 PROMPT="Please click Done, then turn the device power off then on";; 25 "") 26 break;; 27 esac 28 shift 29done 30 31if [ "$PROMPT" = "" ] ; then 32 echo "ERROR: no power action specified on command line" 33 exit 2 34fi 35 36if [ "`which kdialog 2>/dev/null`" != "" ] ; then 37 DIALOGUTIL="kdialog" 38elif [ "`which zenity 2>/dev/null`" != "" ] ; then 39 DIALOGUTIL="zenity" 40else 41 echo "ERROR: couldn't find program to display a message, install kdialog or zenity" 42 exit 3 43fi 44 45if [ "$DIALOGUTIL" = "kdialog" ] ; then 46 kdialog --yesno "$PROMPT" --title "TestImage Power Control" --yes-label "Done" --no-label "Cancel test" 47elif [ "$DIALOGUTIL" = "zenity" ] ; then 48 zenity --question --text="$PROMPT" --title="TestImage Power Control" --ok-label="Done" --cancel-label="Cancel test" 49fi 50 51if [ "$?" != "0" ] ; then 52 echo "User cancelled test at power prompt" 53 exit 1 54fi 55 56