Split virtinst to a shell script
This commit is contained in:
parent
3c1701f150
commit
aacef5c12a
3 changed files with 36 additions and 38 deletions
|
@ -389,44 +389,6 @@ tlscheck () {
|
|||
fi
|
||||
}
|
||||
|
||||
virtinst () {
|
||||
_acp_vm_root="$HOME/virt/images"
|
||||
_acp_vm_session=qemu:///session
|
||||
|
||||
case "$1" in
|
||||
"--help" | -*)
|
||||
echo "Usage: virtinst vmname --cdrom install.iso [other virt-install options]" >&2
|
||||
return
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Create the directory if it doesn't exist already.
|
||||
if ! [ -d "$_acp_vm_root" ]
|
||||
then
|
||||
mkdir -p "$_acp_vm_root"
|
||||
fi
|
||||
|
||||
_acp_vm_name=$1
|
||||
|
||||
virt-install --connect $_acp_vm_session \
|
||||
--osinfo linux2020 \
|
||||
--boot uefi \
|
||||
--cpu host-passthrough \
|
||||
--disk "$_acp_vm_root/$_acp_vm_name.qcow2,size=20" \
|
||||
--graphics vnc \
|
||||
--console pty,target.type=virtio \
|
||||
--channel unix,target.type=virtio,target.name=org.qemu.guest_agent.0 \
|
||||
--video virtio \
|
||||
--autoconsole none \
|
||||
--name "$@"
|
||||
|
||||
unset _acp_vm_name
|
||||
unset _acp_vm_session
|
||||
unset _acp_vm_root
|
||||
}
|
||||
|
||||
if [ -r "$XDG_CONFIG_HOME/profile.local" ]
|
||||
then
|
||||
. "$XDG_CONFIG_HOME/profile.local"
|
||||
|
|
31
roles/home-cli/files/virtinst.sh
Executable file
31
roles/home-cli/files/virtinst.sh
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
_acp_vm_root="$HOME/virt/images"
|
||||
_acp_vm_session=qemu:///session
|
||||
_acp_vm_name=$1
|
||||
|
||||
case "$_acp_vm_name" in
|
||||
"--help" | -*)
|
||||
echo "Usage: virtinst vmname --cdrom install.iso [other virt-install options]" >&2
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# Create the directory if it doesn't exist already.
|
||||
if ! [ -d "$_acp_vm_root" ]
|
||||
then
|
||||
mkdir -p "$_acp_vm_root"
|
||||
fi
|
||||
|
||||
virt-install --connect $_acp_vm_session \
|
||||
--osinfo linux2020 \
|
||||
--boot uefi \
|
||||
--cpu host-passthrough \
|
||||
--disk "$_acp_vm_root/$_acp_vm_name.qcow2,size=20" \
|
||||
--graphics vnc \
|
||||
--console pty,target.type=virtio \
|
||||
--channel unix,target.type=virtio,target.name=org.qemu.guest_agent.0 \
|
||||
--video virtio \
|
||||
--autoconsole none \
|
||||
--name "$@"
|
|
@ -66,3 +66,8 @@
|
|||
ansible.builtin.copy:
|
||||
src: Microsoft.PowerShell_profile.ps1
|
||||
dest: "{{ ansible_env.XDG_CONFIG_HOME }}/powershell/Microsoft.PowerShell_profile.ps1"
|
||||
- name: Create $HOME/.local/bin/virtinst
|
||||
ansible.builtin.copy:
|
||||
src: virtinst.sh
|
||||
dest: "{{ ansible_env.HOME }}/.local/bin/virtinst"
|
||||
mode: '0755'
|
||||
|
|
Loading…
Reference in a new issue