]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Replace rc.local by custom kvmx_up procedures for mounting and vdagent handling
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 10 Mar 2017 17:41:33 +0000 (14:41 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 10 Mar 2017 17:41:33 +0000 (14:41 -0300)
kvmx
kvmx-create

diff --git a/kvmx b/kvmx
index 6a67d09773a141fef8373fdaed25831db49f989e..1dd03028b3d53de0145c18eabf381667b8615778 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -50,7 +50,7 @@ function kvmx_spice {
   #spicy -h localhost -p $PORT
   #remote-viewer spice://localhost:$PORT
 
-  # Give time to boot
+  # Give time to connect
   sleep 5
 
   # Fix window titles
@@ -114,6 +114,21 @@ function kvmx_up {
   if [ "$run_spice_client" == "1" ]; then
     kvmx_spice
   fi
+
+  echo "Waiting for machine to boot..."
+  sleep 5
+
+  # 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
@@ -152,7 +167,16 @@ function kvmx_ssh {
     exit 1
   fi
 
-  shift 2
+  # Shift params according to how the program was called:
+  # either "kvmx ssh" or "kvmx ssh guest".
+  if [ "$ACTION" == "ssh" ]; then
+    if [ ! -z "$2" ]; then
+      shift 2
+    else
+      shift 1
+    fi
+  fi
+
   SSH="`cat $SSHFILE`"
   $SSH_COMMAND -p $SSH $SSH_LOGIN@127.0.0.1 $*
 }
index 9ffeb88f4275e00835afa1a64657bb9d5f9ade5f..49c6e49f74c8596f18ea2697d40f0605d8f9fce7 100755 (executable)
@@ -233,36 +233,6 @@ function kvmx_create_custom {
   echo "Installing sudo..."
   $APT_INSTALL sudo -y
   echo "%sudo ALL=NOPASSWD: ALL" | $SUDO tee $WORK/etc/sudoers.d/local > /dev/null
-  kvmx_sudo_run chmod 440 $WORK/etc/sudoers.d/local
-
-  # Initscript
-  cat <<-EOF | $SUDO tee $WORK/etc/rc.local > /dev/null
-#!/bin/sh -e
-#
-# rc.local
-#
-# This script is executed at the end of each multiuser runlevel.
-# Make sure that the script will "exit 0" on success or any other
-# value on error.
-#
-# In order to enable or disable this script just change the execution
-# bits.
-#
-# By default this script does nothing.
-
-# Somehow it is starting before DBUS and then crashing, so we try to start again
-/usr/sbin/service spice-vdagent start
-
-# Ensure file sharing between host and guest
-if [ ! -z "$shared_folder_mountpoint" ]; then
-  /bin/mkdir -p $shared_folder_mountpoint
-  /bin/mount -t 9p -o trans=virtio shared $shared_folder_mountpoint -oversion=9p2000.L,posixacl,cache=loose
-fi
-
-exit 0
-EOF
-
-  hydra_sudo_run chmod +x $WORK/etc/rc.local
 
   # Root password
   echo 'root:root' | kvmx_sudo_run chroot $WORK/ chpasswd