Last active
March 12, 2019 15:53
-
-
Save jaysonsantos/e26a355e1fc3cae5f2788515b9efad3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find_kafka_device() { | |
for device in $(nvme list | grep ^/dev | awk '{print $1}') | |
do | |
local found_device="$(nvme id-ctrl -v $device | grep -Po '/dev/[a-z0-9]+' || true)" | |
if [[ -n "$found_device" ]]; then | |
echo "$device" | |
return 0 | |
fi | |
done | |
return 1 | |
} | |
main() { | |
kafka_device="$(find_kafka_device)" | |
already_formatted="$(blkid "$kafka_device" | grep kafka || true )" | |
if [[ -n "$already_formatted" ]]; then | |
echo "Kafka partition already created" | |
else | |
mkfs.ext4 -L kafka "$kafka_device" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment