# Parameters
BASENAME="`basename $0`"
DIRNAME="`dirname $0`"
+GLOBAL_USER_CONFIG_FILE="$HOME/.config/kvmxconfig"
# Load configuration
function kvmx_config_load {
# 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"
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
# 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"