The documentation for the shellcmd power control method is wrong. The return code for a successful operation for on/off is stated there as 1. But in my setup the correct return code is 0.
The following script works for me as expected. Take a look at the return codes.
#! /bin/sh
OFF=/var/cache/off
ON=/var/cache/on
PRIO='--tag PWRCTL --priority daemon.notice'
case "$1" in
on)
rm -f $OFF
: > $ON
logger $PRIO ON
exit 0
;;
off)
rm -f $ON
: > $OFF
logger $PRIO OFF
exit 0
;;
check-on)
logger $PRIO CHECK-ON
test -f $ON && exit 0
test -f $OFF && exit 1
exit 3
;;
*)
exit 3
;;
esac
I intergated this script in my mtda config as following
[power]
variant=shellcmd
on-cmd=/usr/local/sbin/mtda-pwrctl.sh on
off-cmd=/usr/local/sbin/mtda-pwrctl.sh off
check-on=/usr/local/sbin/mtda-pwrctl.sh check-on
The documentation for the shellcmd power control method is wrong. The return code for a successful operation for on/off is stated there as 1. But in my setup the correct return code is 0.
The following script works for me as expected. Take a look at the return codes.
I intergated this script in my mtda config as following