Skip to content

Instantly share code, notes, and snippets.

@epcim
Last active February 13, 2020 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epcim/39449dc7ce926bafb476dad99cd5205e to your computer and use it in GitHub Desktop.
Save epcim/39449dc7ce926bafb476dad99cd5205e to your computer and use it in GitHub Desktop.
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