]> gitweb.fluxo.info Git - kvmx.git/commitdiff
Support for custom username and password at kvmx-create
authorSilvio Rhatto <rhatto@riseup.net>
Wed, 29 Mar 2017 22:11:36 +0000 (19:11 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Wed, 29 Mar 2017 22:11:36 +0000 (19:11 -0300)
kvmx
kvmx-create

diff --git a/kvmx b/kvmx
index 4d94cfb40c34c331034ec8cc9265e2a3bda02f97..2d78897e726cda1084f31ca29adb62813941362c 100755 (executable)
--- a/kvmx
+++ b/kvmx
@@ -79,7 +79,6 @@ function __kvmx_initialize {
   # Default parameters
   PORT="$(($RANDOM + 1024))"
   SSH="$(($PORT + 22))"
-  SSH_LOGIN="user"
 
   # Initalize
   mkdir -p $GLOBAL_USER_CONFIG_FOLDER
@@ -123,6 +122,12 @@ function __kvmx_initialize {
       SSHKEY="$APP_BASE/share/ssh/insecure_private_key"
     fi
 
+    if [ ! -z "$user" ]; then
+      SSH_LOGIN="$user"
+    else
+      SSH_LOGIN="user"
+    fi
+
     __kvmx_ssh_command $SSHKEY
 
     mkdir -p $STATE_DIR
index 38405a3a3fdcf5e103f952cde7a0db5c5a2ef9b7..7f9270de53d782369682296300a08c029dbc9864 100755 (executable)
@@ -105,6 +105,8 @@ function kvmx_config {
   kvmx_user_config   mirror            http://http.debian.net/debian/   "Debian mirror"
   kvmx_user_config   ssh_support       y                                "Administration using passwordless SSH (y/n)"
   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"
 }
 
 # Load config file
@@ -240,7 +242,7 @@ function kvmx_create_custom {
   echo 'root:root' | kvmx_sudo_run chroot $WORK/ chpasswd
 
   # Initial user
-  kvmx_sudo_run chroot $WORK/ useradd user -G sudo -s /bin/bash
+  kvmx_sudo_run chroot $WORK/ useradd $user -G sudo -s /bin/bash
 
   if [ "$ssh_support" == "y" ];
     if [ "$ssh_custom" == "y" ]; then
@@ -259,7 +261,7 @@ function kvmx_create_custom {
   fi
 
   kvmx_sudo_run chroot $WORK/ chown -R user.user /home/user
-  echo 'user:user' | kvmx_sudo_run chroot $WORK/ chpasswd
+  echo "$user:$password" | kvmx_sudo_run chroot $WORK/ chpasswd
 
   # Networking
   cat <<-EOF | $SUDO tee $WORK/etc/network/interfaces.d/ens3 > /dev/null