Browse Source

Fixes #4

- Exit if PKGMGR is not set.
- Changed runcmd to list of strings and changed order to avoid to shellify error.
- Run function to set network restart command so that hostname is sent to dnsmasq and libvirt-nss works.
- Change delete_vm() to remove() when overwriting an exiting VM to avoid storage pool creation error.
pull/6/head
Giovanni Torres 8 years ago
parent
commit
852a67c8c1
  1. 18
      kvm-install-vm

18
kvm-install-vm

@ -266,8 +266,8 @@ function get_pkg_mgr ()
SUDOGROUP="sudo"
;;
*)
PKGMGR=
SUDOGROUP=
echo "OS not supported."
exit 2
;;
esac
}
@ -334,17 +334,11 @@ ssh_authorized_keys:
timezone: ${TIMEZONE}
_EOF_
if [ ! -z ${PKGMGR} ]
then
cat >> $USER_DATA << _EOF_
# Remove cloud-init when finished with it
runcmd:
- [ ${PKGMGR}, -y, remove, cloud-init ]
- ${NETRESTART}
- ${PKGMGR} -y remove cloud-init
_EOF_
fi
{ echo "instance-id: ${VMNAME}"; echo "local-hostname: ${VMNAME}"; } > $META_DATA
@ -461,7 +455,6 @@ function remove ()
storpool_exists "${1}"
delete_vm "${1}"
exit 0
fi
}
@ -555,13 +548,16 @@ function create ()
echo -n "[WARNING] ${VMNAME} already exists. "
read -p "Do you want to overwrite ${VMNAME} [y/N]? " -r
if [[ $REPLY =~ ^[Yy]$ ]]; then
delete_vm ${VMNAME}
remove ${VMNAME}
else
echo -e "\nNot overwriting ${VMNAME}. Exiting..."
exit 1
fi
fi
# Set network restart command
set_network_restart_cmd
# Set package manager
get_pkg_mgr

Loading…
Cancel
Save