mirror of https://github.com/armbian/build.git
avoid binary led parameters, better handle :link triggers (#7337)
This commit is contained in:
parent
8b9fd1507e
commit
2960ffaff2
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Armbian leds state
|
Description=Armbian leds state
|
||||||
After=timers.target
|
After=sysinit.target
|
||||||
Conflicts=shutdown.target
|
Conflicts=shutdown.target
|
||||||
DefaultDependencies=no
|
DefaultDependencies=no
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,18 +35,25 @@ function store_led() {
|
||||||
|
|
||||||
# In case the trigger is any of the kbd-*, don't store any other parameter
|
# In case the trigger is any of the kbd-*, don't store any other parameter
|
||||||
# This avoids num/scroll/capslock from being restored at startup
|
# This avoids num/scroll/capslock from being restored at startup
|
||||||
# In case trigger is representing link-state for any network, don't store its previous state
|
[[ "$TRIGGER_VALUE" =~ kbd-* ]] && return
|
||||||
# This avoids ghost wan/lan/etc (led up while cable unplugged)
|
|
||||||
[[ "$TRIGGER_VALUE" =~ kbd-* || "$TRIGGER_VALUE" == *":link" ]] && return
|
|
||||||
|
|
||||||
COMMAND_PARAMS="$CMD_FIND $PATH/ -maxdepth 1 -type f ! -iname uevent ! -iname trigger -perm /u+w -printf %f\\n"
|
COMMAND_PARAMS="$CMD_FIND $PATH/ -maxdepth 1 -type f ! -iname uevent ! -iname trigger -perm /u+w -printf %f\\n"
|
||||||
PARAMS=$($COMMAND_PARAMS)
|
PARAMS=$($COMMAND_PARAMS)
|
||||||
|
|
||||||
|
# In case trigger is representing link-state for any network, use
|
||||||
|
# bash substitution to remove the brightness parameter and avoid
|
||||||
|
# ghost wan/lan/etc (led up while cable unplugged)
|
||||||
|
[[ "$TRIGGER_VALUE" == *":link" ]] && PARAMS=${PARAMS//"brightness"/}
|
||||||
|
|
||||||
for PARAM in $PARAMS; do
|
for PARAM in $PARAMS; do
|
||||||
|
|
||||||
PARAM_PATH="$PATH/$PARAM"
|
PARAM_PATH="$PATH/$PARAM"
|
||||||
VALUE=$(<$PARAM_PATH)
|
VALUE=$(<$PARAM_PATH)
|
||||||
|
|
||||||
|
# If the variable contains non-printable characters
|
||||||
|
# suppose it contains binary and skip it
|
||||||
|
[[ "$VALUE" =~ [[:cntrl:]] ]] && continue
|
||||||
|
|
||||||
echo "$PARAM=$VALUE" >> $DESTINATION
|
echo "$PARAM=$VALUE" >> $DESTINATION
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
@ -60,9 +67,7 @@ for LED in /sys/class/leds/*; do
|
||||||
[[ -d "$LED" ]] || continue
|
[[ -d "$LED" ]] || continue
|
||||||
|
|
||||||
# Skip saving state for directories starting with enP e.g. enP1p1s0-0::lan enP2p1s0-2::lan etc. etc.
|
# Skip saving state for directories starting with enP e.g. enP1p1s0-0::lan enP2p1s0-2::lan etc. etc.
|
||||||
if [[ "$(/usr/bin/basename "$LED")" == enP* ]]; then
|
[[ "$(/usr/bin/basename "$LED")" == enP* ]] && continue
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
store_led $LED $STATE_PATH
|
store_led $LED $STATE_PATH
|
||||||
echo >> $STATE_PATH
|
echo >> $STATE_PATH
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue