]> gitweb.fluxo.info Git - kvm-manager.git/commitdiff
abstract away the choice of placement of homedir for non-standard systems
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Wed, 11 Nov 2009 22:16:30 +0000 (17:16 -0500)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Wed, 11 Nov 2009 22:16:30 +0000 (17:16 -0500)
kvm-creator

index 744cb960fc6e38223c62abf98067b74eeffab3b7..e2c0ca9bd8fc7e719d3809f7f45a627dd32680df 100755 (executable)
@@ -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