aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2009-11-11 17:16:30 -0500
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2009-11-11 17:16:30 -0500
commit4c74e5346f55dfe5f22f0d8a25a3a712ff27b6cf (patch)
treec0256eb620c8a9165f698daddb43d2c5aaf8ed1c
parent7ec0b002eba10c12d3687fec7ee8afa7b1d03729 (diff)
downloadkvm-manager-4c74e5346f55dfe5f22f0d8a25a3a712ff27b6cf.tar.gz
kvm-manager-4c74e5346f55dfe5f22f0d8a25a3a712ff27b6cf.tar.bz2
abstract away the choice of placement of homedir for non-standard systems
-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