fix initial commit
This commit is contained in:
parent
0b812638f6
commit
68f39098fd
5 changed files with 279 additions and 0 deletions
32
kvm/vclone
Executable file
32
kvm/vclone
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [[ $# -ne 2 ]]; then
|
||||
echo "USAGE: $0 <source> <dest>"
|
||||
exit 0
|
||||
else
|
||||
orig="$1"
|
||||
dest="$2"
|
||||
fi
|
||||
|
||||
sudo virt-clone --original "${orig}" --name "${dest}" --auto-clone
|
||||
|
||||
sudo virt-sysprep \
|
||||
-d "${dest}" \
|
||||
--operations defaults,-ssh-userdir \
|
||||
--hostname "${dest}" \
|
||||
--edit /etc/hosts:"s/${orig}/${dest}/" \
|
||||
--edit /etc/hostname:"s/${orig}/${dest}/" \
|
||||
--edit /etc/motd:"s/${orig}/${dest}/" \
|
||||
--firstboot-command 'dpkg-reconfigure openssh-server' \
|
||||
--firstboot-command 'systemctl restart sshd'
|
||||
|
||||
getLinkLocalAddress() {
|
||||
local macAddress=$(sudo grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}' /etc/libvirt/qemu/${dest}.xml)
|
||||
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"
|
||||
}
|
||||
|
||||
printf "The link-local IP address of %s is:\n %s\n" "${dest}" "$(getLinkLocalAddress)"
|
Loading…
Add table
Add a link
Reference in a new issue