nltrigger (1191B)
1 #!/bin/busybox ash 2 3 usage() { 4 printf "usage: %s [add|list|del|action] [subsystem]\n" "$(basename $1)" >&2 5 exit 1 6 } 7 8 action="list" 9 if [ $# -gt 0 ]; 10 then 11 action="$1" 12 fi 13 14 if [ "$action" = "list" ]; 15 then 16 printf "class:\n" 17 for i in /sys/class/*; 18 do 19 printf "\t%s\n" $(basename $i) 20 done 21 22 printf "bus:\n" 23 for i in /sys/bus/*; 24 do 25 printf "\t%s\n" $(basename $i) 26 done 27 28 printf "devices:\n" 29 for i in /sys/devices/*; 30 do 31 printf "\t%s\n" $(basename $i) 32 done 33 34 exit 0 35 fi 36 37 if [ $# -lt 2 ]; 38 then 39 usage "$0" 40 fi 41 subsystem="$2" 42 43 if [ "$subsystem" != "all" ]; 44 then 45 if [ -d /sys/class/$subsystem ]; 46 then 47 for i in /sys/class/$subsystem/*/uevent; 48 do 49 echo $action > $i 50 done 51 exit 0 52 fi 53 54 if [ -d /sys/bus/$subsystem ]; 55 then 56 for i in /sys/bus/$subsystem/devices/*/uevent; 57 do 58 echo $action > $i 59 done 60 exit 0 61 fi 62 63 if [ -d /sys/devices/$subsystem ]; 64 then 65 for i in /sys/devices/$subsystem/*/uevent \ 66 /sys/devices/$subsystem/*/*/uevent; 67 do 68 echo $action > $i 69 done 70 exit 0 71 fi 72 73 printf "Could not find subsystem '%s'.\n" $i >&2 74 exit 1 75 fi 76 77 for i in $(find /sys -name uevent -print | sed -e 's/ /,/g'); 78 do 79 echo $action > "$(echo $i | sed -e 's/,/ /g')" 80 done 81 82 exit 0 83