aboutsummaryrefslogtreecommitdiff
path: root/kvmx-create
diff options
context:
space:
mode:
Diffstat (limited to 'kvmx-create')
-rwxr-xr-xkvmx-create22
1 files changed, 17 insertions, 5 deletions
diff --git a/kvmx-create b/kvmx-create
index fed0292..4ea8755 100755
--- a/kvmx-create
+++ b/kvmx-create
@@ -21,6 +21,7 @@
# Parameters
BASENAME="`basename $0`"
DIRNAME="`dirname $0`"
+GLOBAL_USER_CONFIG_FILE="$HOME/.config/kvmxconfig"
# Load configuration
function kvmx_config_load {
@@ -94,10 +95,10 @@ function kvmx_sudo_run {
# Make sure there is provision config.
function kvmx_config {
- kvmx_user_config image /var/cache/qemu/debian/box.img "Destination image (ending in .img)"
- kvmx_user_config size 3G "Image size"
- kvmx_user_config format qcow2 "Image format: raw or qcow2"
- kvmx_user_config method custom "Bootstrap method: custom or vmdeboostrap"
+ if [ -e "$GLOBAL_USER_CONFIG_FILE" ]; then
+ source $GLOBAL_USER_CONFIG_FILE
+ fi
+
kvmx_user_config hostname machine "Hostname"
kvmx_user_config domain example.org "Domain"
kvmx_user_config arch amd64 "System arch"
@@ -107,6 +108,17 @@ function kvmx_config {
kvmx_user_config ssh_custom y "Setup a custom SSH keypair (y/n)"
kvmx_user_config user user "Initial user name"
kvmx_user_config password $RANDOM "Initial user password"
+
+ if [ ! -z "$image_base" ]; then
+ image="$image_base/$hostname/box.img"
+ else
+ image_base="$HOME/.local/share/kvmx"
+ kvmx_user_config image $image_base/debian/box.img "Destination image (ending in .img)"
+ fi
+
+ kvmx_user_config size 3G "Image size"
+ kvmx_user_config format qcow2 "Image format: raw or qcow2"
+ kvmx_user_config method custom "Bootstrap method: custom or vmdeboostrap"
}
# Load config file
@@ -244,7 +256,7 @@ function kvmx_create_custom {
# Initial user
kvmx_sudo_run chroot $WORK/ useradd $user -G sudo -s /bin/bash
- if [ "$ssh_support" == "y" ];
+ if [ "$ssh_support" == "y" ]; then
if [ "$ssh_custom" == "y" ]; then
privkey="`dirname $image`/ssh/`basename $image .img`.key"
pubkey="${privkey}.pub"