Skip to content

Commit

Permalink
fix patterns in udev rule to work for multiple digits again
Browse files Browse the repository at this point in the history
also fix paths in `ebs-nvme-mapping.sh`

this had previously been fixed in oogali#3 but it was changed before it was merged.

then I tried to fix it again in oogali#8 but missed some of the digits

rebased on top of @pforman-zymergen's PR oogali#13 because
I want that binary check but udev needs the full paths
  • Loading branch information
b-dean committed Feb 9, 2021
1 parent 4c8e038 commit d8b4d03
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
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 $(command -v 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;

0 comments on commit d8b4d03

Please sign in to comment.