]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Adds kvmx_install
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 6 Oct 2017 21:21:14 +0000 (18:21 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 6 Oct 2017 21:21:14 +0000 (18:21 -0300)
README.md
kvmx

index 52a64e718dc6bf2a7405fe308fae2556c5a3db22..0ae49a4632a2621e203532dc7d20c91151c86d2e 100644 (file)
--- a/README.md
+++ b/README.md
@@ -58,24 +58,26 @@ resides.
 ## Manually creating a guest
 
 Alternativelly, you might create a new one by hand. To do so, proceed as usual
-with `kvmx init` and `kvmx edit` acording to the Basic Usage stated above.
+with `kvmx init` and `kvmx edit` acording to the Basic Usage stated above and
+then type
 
-Then, before, doing `kvmx up`, do something like the following example:
+    kvmx install <project-name> ~/path/to/install.iso
 
-    # Create the environment
-    kvmx init <guest> /var/cache/qemu/<guest>
-    qemu-img create -f qcow2 /var/cache/qemu/<guest>box.img 10G
-
-    # Install the Operating System
-    kvm -m 2048 -net nic,model=virtio -net user -drive file=/var/cache/qemu/<guest>/box.img -cdrom ~/path/to/install.iso 
+This will boot and installation media with you guest's disk available for
+regular system install.
 
 If you want OpenSSH functionality, make sure to create an user and set a password
-related to the configuration present at the project's `kvmxfile`. Also, make sure
-to to create an OpenSSH keypair for this virtual machine and put the public key
-into the guest user's home folder. Passwordless sudo might also be desired for the
-full development functionality.
+related to the configuration present at the project's `kvmxfile`.
+
+Also, make sure to to create an OpenSSH keypair for this virtual machine and
+put the public key into the guest user's home folder. That can be done simply
+by cloning `kvmx` repo inside the guest and installing the provided insecure
+key into place (once the machine is fully acessible via `kvmx ssh` you can
+rotate the keys with the `rotate_sshkeys` action).
+
+Passwordless sudo might also be desired for the full development functionality.
 
-Test your new system with
+You can test your new system with
 
     kvm -m 2048 -net nic,model=virtio -net user -drive file=box.img
 
diff --git a/kvmx b/kvmx
index 2ed3dd4b3197be50d87fb416fc4ad9e195ce8ffb..0b8dc145db6ecd9cb56bbcc1d1c52d8b1da50777 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -184,7 +184,8 @@ function __kvmx_initialize {
 
     mkdir -p $STATE_DIR $LOG_DIR
 
-    if [ ! -e "$image" ] && [ "$ACTION" != "up" ] && [ "$ACTION" != "purge" ] && [ "$ACTION" != "destroy" ]; then
+    if [ ! -e "$image" ] && [ "$ACTION" != "up" ] && [ "$ACTION" != "purge" ] \
+                         && [ "$ACTION" != "destroy" ] && [ "$ACTION" != "install" ]; then
       echo "$BASENAME: file not found: $image"
       exit 1
     fi
@@ -1295,6 +1296,30 @@ function kvmx_mv {
   kvmx_rename $*
 }
 
+# Install system
+function kvmx_install {
+  local media="$3"
+
+  if [ -z "$media" ]; then
+    echo "usage: $BASENAME install $VM <installation-media>"
+    exit 1
+  elif [ ! -e "$media" ]; then
+    echo "$BASENAME: file not found: $media"
+    exit 1
+  fi
+
+  if [ -z "$memory" ]; then
+    memory="2048"
+  fi
+
+  if [ ! -e "$image" ]; then
+    echo "Creating $image with size $size..."
+    qemu-img create -f qcow2 $image $size
+  fi
+
+  kvm -m $memory -net nic,model=virtio -net user -drive file=$image -cdrom $media
+}
+
 # Dispatch
 if type kvmx_$ACTION 2> /dev/null | grep -q "kvmx_$ACTION ()"; then
   __kvmx_initialize