diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-03-10 16:25:21 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-03-10 16:25:21 -0300 |
commit | 9c9b865522dd8ce6cba31ca2179d68a1952b87c0 (patch) | |
tree | 5dfb237362941e974554d27bc107e55e2fb0172a | |
parent | 0b64d3ff8ee12c876204e544362b90836b75a649 (diff) | |
download | kvmx-9c9b865522dd8ce6cba31ca2179d68a1952b87c0.tar.gz kvmx-9c9b865522dd8ce6cba31ca2179d68a1952b87c0.tar.bz2 |
Adds kvmx_hostname and misc fixes
-rwxr-xr-x | kvmx | 41 |
1 files changed, 27 insertions, 14 deletions
@@ -86,7 +86,7 @@ function kvmx_up { exit 1 fi - echo "Copying base image $baseimage to $image" + echo "Copying base image $baseimage to $image..." cp $baseimage $image fi else @@ -120,8 +120,33 @@ function kvmx_up { while true; do echo true | $SSH_COMMAND -o ConnectTimeout=2 -p $SSH $SSH_LOGIN@127.0.0.1 &> /dev/null && break echo -n "." + sleep 2 done echo " done." + #sleep 5 + #echo "" + + # Somehow it is starting before DBUS and then crashing, so we try to start again + echo "Ensure spice-vdagent is running..." + echo "sudo /usr/sbin/service spice-vdagent start" | kvmx_ssh + + kvmx_hostname + + if [ ! -z "$shared_folder" ] && [ ! -z "$shared_folder_mountpoint" ]; then + echo "Mounting $shared_folder on $shared_folder_mountpoint on guest..." + echo "sudo mkdir -p $shared_folder_mountpoint" | kvmx_ssh + echo "sudo mount -t 9p -o trans=virtio shared $shared_folder_mountpoint -oversion=9p2000.L,posixacl,cache=loose" | kvmx_ssh + fi + + kvmx_status +} + +# Set hostname +function kvmx_hostname { + if ! kvmx_running; then + echo "$BASENAME: guest $VM is not running" + exit 1 + fi echo "Setting hostname..." $SSH_COMMAND -o ConnectTimeout=2 -p $SSH $SSH_LOGIN@127.0.0.1 <<EOF @@ -139,23 +164,11 @@ function kvmx_up { # Remove old hostname from hosts file if [ "\$OLD_HOST" != "$hostname.$domain" ]; then if grep -q \$OLD_HOST /etc/hosts; then - sudo sed -i -e '|\$OLD_HOST|d' /etc/hosts + sudo sed -i -e "/\$OLD_HOST/d" /etc/hosts fi fi ##### END REMOTE SCRIPT ####### EOF - - # Somehow it is starting before DBUS and then crashing, so we try to start again - echo "Ensure spice-vdagent is running..." - echo "sudo /usr/sbin/service spice-vdagent start" | kvmx_ssh - - if [ ! -z "$shared_folder" ] && [ ! -z "$shared_folder_mountpoint" ]; then - echo "Mounting $shared_folder on $shared_folder_mountpoint on guest..." - echo "sudo mkdir -p $shared_folder_mountpoint" | kvmx_ssh - echo "sudo mount -t 9p -o trans=virtio shared $shared_folder_mountpoint -oversion=9p2000.L,posixacl,cache=loose" | kvmx_ssh - fi - - kvmx_status } # Display usage |