chiark / gitweb /
rule_generator: fix enumeration for write_cd_rules
[elogind.git] / extras / firmware / firmware.sh
1 #!/bin/sh -e
2
3 FIRMWARE_DIRS="/lib/firmware/$(uname -r) /lib/firmware"
4
5 err() {
6         echo "$@" >&2
7         logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true
8 }
9
10 if [ ! -e /sys$DEVPATH/loading ]; then
11         err "udev firmware loader misses sysfs directory"
12         exit 1
13 fi
14
15 for DIR in $FIRMWARE_DIRS; do
16         [ -e "$DIR/$FIRMWARE" ] || continue
17         echo 1 > /sys$DEVPATH/loading
18         cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data
19         echo 0 > /sys$DEVPATH/loading
20         exit 0
21 done
22
23 echo -1 > /sys$DEVPATH/loading
24 err "Cannot find  firmware file '$FIRMWARE'"
25 mkdir -p /dev/.udev/firmware-missing
26 file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g')
27 ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file
28 exit 1