aboutsummaryrefslogtreecommitdiff
path: root/kvm-creator
diff options
context:
space:
mode:
Diffstat (limited to 'kvm-creator')
-rwxr-xr-xkvm-creator13
1 files changed, 8 insertions, 5 deletions
diff --git a/kvm-creator b/kvm-creator
index 744cb96..e2c0ca9 100755
--- a/kvm-creator
+++ b/kvm-creator
@@ -45,9 +45,8 @@ destroy() {
update-service --remove "/etc/sv/kvm/$NAME"
rm -rf "/etc/sv/kvm/$NAME"
- deluser "$NAME"
+ deluser --remove-home "$NAME"
lvremove "$VG/$NAME"
- rm -rf "/home/$NAME"
}
@@ -69,9 +68,13 @@ create() {
set -e
validate
adduser "$NAME" --disabled-password --gecos "$NAME KVM user,,,"
- mkdir -p "/home/$NAME/"{.ssh,vms,"vms/$NAME"}
- chown "$NAME:$NAME" "/home/$NAME/"{.ssh,vms,"vms/$NAME"}
- cp /root/.ssh/authorized_keys "/home/$NAME/.ssh/"
+ USERHOMEDIR=$(getent passwd "$NAME" | cut -f6 -d:)
+ mkdir -p "$USERHOMEDIR/"{.ssh,vms,"vms/$NAME"}
+ chown "$NAME:$NAME" "$USERHOMEDIR/"{.ssh,vms,"vms/$NAME"}
+ if [ -f /root/.ssh/authorized_keys ]; then
+ # is this really the right thing to do?
+ cp /root/.ssh/authorized_keys "$USERHOMEDIR/.ssh/"
+ fi
lvcreate --name "$NAME" --size "$SIZE" $VG
mkdir "/etc/sv/kvm/$NAME"{,/log,/env}
cat > "/etc/sv/kvm/$NAME/log/run" <<EOF