Skip to content
This repository has been archived by the owner on Oct 27, 2022. It is now read-only.

fix patterns in udev rule to work for multiple digits again #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion 999-aws-ebs-nvme.rules
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SUBSYSTEM=="block", KERNEL=="nvme[0-9]*n1", ATTRS{model}=="Amazon Elastic Block Store", PROGRAM+="/usr/local/sbin/ebs-nvme-mapping.sh /dev/%k" SYMLINK+="%c"
SUBSYSTEM=="block", KERNEL=="nvme[0-9]*n[0-9]*", ATTRS{model}=="Amazon Elastic Block Store", PROGRAM+="/usr/local/sbin/ebs-nvme-mapping.sh /dev/%k" SYMLINK+="%c"
10 changes: 5 additions & 5 deletions ebs-nvme-mapping.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# To be used with the udev rule: /etc/udev/rules.d/999-aws-ebs-nvme.rules

if [[ -z nvme ]]; then
if [[ -z $(command -v /usr/sbin/nvme) ]]; then
echo "ERROR: NVME tools not installed." >> /dev/stderr
exit 1
fi
Expand All @@ -16,9 +16,9 @@ fi
# use `xvd` prefix instead of `sd`
# remove all trailing space
nvme_link=$( \
nvme id-ctrl --output binary "${1}" | \
cut -c3073-3104 | \
sed 's/^\/dev\///g'| \
tr -d '[:space:]' \
/usr/sbin/nvme id-ctrl --output binary "${1}" | \
/usr/bin/cut -c3073-3104 | \
/bin/sed 's/^\/dev\///g'| \
/usr/bin/tr -d '[:space:]' \
);
echo $nvme_link;