Casper.Dik at Sun.COM
2005-Dec-01 18:32 UTC
[zfs-discuss] Automatic home directory creation
Here''s my latest /etc/auto_home script for systems with a single export/home storage pool and an administrator too lazy to create directories: #!/bin/ksh -p # # Find home directory; create directories under /export/home # with zfs if they do not exist. # hdir=$(echo ~$1) case "$hdir" in /home/$1);; *) exit;; esac # # At this point we have verified that "$1" is a valid # user with a home of the form /home/username. # h=/export/home/"$1" if [ -d "$h" ] then echo "localhost:$h" exit 0 fi /usr/sbin/zfs create "export/home/$1" || exit 1 cd /etc/skel umask 022 /bin/find . -type f | while read f; do echo $f f=$(basename $f) echo basename: $f case "$f" in local.*) t="$h/$(echo $f | sed -e s/local//)";; .*) t="$h/$f";; esac cp "$f" "$t" chown "$1" "$t" done chown "$1" $h echo "localhost:$h" exit 0