fix initial commit

This commit is contained in:
Dhya 2024-10-17 15:04:16 -07:00
parent 0b812638f6
commit 68f39098fd
5 changed files with 279 additions and 0 deletions

22
kvm/get-kvm-link-local Executable file
View file

@ -0,0 +1,22 @@
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "USAGE: $0 <domain>"
exit 0
else
domain="$1"
fi
if [[ ! -e /etc/libvirt/qemu/${domain}.xml ]]; then
echo "Error: ${domain} configuration not found on this system"
exit 1
fi
macAddress=$(sudo grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' /etc/libvirt/qemu/${domain}.xml)
# courtesy of https://stackoverflow.com/a/48378567
printf "%02x%s" $(( 16#${macAddress:0:2} ^ 2#00000010 )) "${macAddress:2}" \
| sed -E -e 's/([0-9a-zA-Z]{2})*/0x\0|/g' \
| tr -d ':\n' \
| xargs -d '|' \
printf "fe80::%02x%02x:%02xff:fe%02x:%02x%02x\n"