Skip to content

Instantly share code, notes, and snippets.

@epcim epcim/indexer
Last active Feb 13, 2020

Embed
What would you like to do?
udev rules ordered interface
#!/bin/sh
#if [ $# -lt 1 ]; then
# echo "Usage: $0 prefix [initial] [database/file] " >&2
# exit 1
#fi
key="${1:-"eth"}"
initial="${2:-0}"
datfile="${3:-/run/indexerdb_$key}"
lockfile="${datfile}.lck"
(
flock -x 9
num=$initial
if [ -e "$datfile" ]; then
read -r num < "$datfile"
fi
next=`expr $num + 1`;
echo $next > "$datfile"
echo "$key$num"
) 9> "$lockfile"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="?*", ATTRS{class}=="0x0200*", PROGRAM="/opt/bin/indexer eth" NAME:="%c"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.