#!/sbin/openrc-run
# SPDX-License-Identifier: MIT

name="toggle indicator signals"

: "${pwr_led:="PWR_IND"}"
: "${stdwn_led:="STDWN_IND"}"

depend() {
	after mount-ro wwan-safe-poweroff
}

start() {
	local rc=0
	ebegin "Signaling external devices we are shutting down"
	if [ -e "/sys/class/leds/$pwr_led/brightness" ]; then
		echo 0 > "/sys/class/leds/$pwr_led/brightness" \
			|| rc=$?
	fi
	if [ -e "/sys/class/leds/$stdwn_led/brightness" ]; then
		cat "/sys/class/leds/$stdwn_led/max_brightness" \
			> "/sys/class/leds/$stdwn_led/brightness" \
			|| rc=$?
	fi
	eend $rc
}
