aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-03-31 09:58:28 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-03-31 09:58:28 -0300
commit34a57bcb0139c61d4c096477d50c0fc9d71169b9 (patch)
tree9d858640ad950eae3ab4e8608df778afba469030
parent89c1c94543c0acddd4712a1828c33cd10e735ae1 (diff)
downloadkvmx-34a57bcb0139c61d4c096477d50c0fc9d71169b9.tar.gz
kvmx-34a57bcb0139c61d4c096477d50c0fc9d71169b9.tar.bz2
Default image file on 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"