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