Differences between current version and previous revision of KnowledgeBase/FreeBSD/SambaZfs.
Other diffs: Previous Major Revision, Previous Author
| Newer page: | version 2 | Last edited on Saturday, 13 April 2013 17:26:07 | by CyberLeo | |
| Older page: | version 1 | Last edited on Sunday, 13 January 2013 2:04:31 | by CyberLeo | Revert |
@@ -1,10 +1,47 @@
smb.conf:
<code brush="plain">
[homes]
...
- root preexec = /root
/bin/createhome
.sh '%S'
+ root preexec = /users
/.create_home
.sh '%S'
</code>
+
+_I lost the one that I was using. -- CyberLeo_
createhome.sh:
<code brush="bash">
+#!/bin/sh -e
+
+pebkac() {
+ echo "Usage: $(basename "${0}") <username>" >&2
+ echo "" >&2
+ echo "Create the zfs home directories for the given user if they do not exist." >&2
+ exit 1
+}
+
+fsbase="$(realpath "$(dirname "${0}")")"
+zpbase="$(mount | grep ' on '"${fsbase}"' ' | cut -d' ' -f1)"
+
+user="${1}"
+[ "${user}" ] || pebkac
+
+zpuser="${zpbase}/${user}"
+fsuser="${fsbase}/${user}"
+
+[ ! -e "${fsuser}" ] || exit 0
+
+fspublic="${fsuser}/Public"
+fsprivate="${fsuser}/Private"
+fsdropbox="${fsuser}/DropBox"
+fsrecycle="${fsuser}/.recycle"
+
+zfs create "${zpuser}"
+mkdir -p "${fspublic}"
+chmod 755 "${fspublic}"
+mkdir -p "${fsprivate}"
+chmod 700 "${fsprivate}"
+mkdir -p "${fsdropbox}"
+chmod 1777 "${fsdropbox}"
+mkdir -p "${fsrecycle}"
+chmod 777 "${fsrecycle}"
+chown -R "${user}" "${fsuser}"
</code>
current version
smb.conf:
[homes] ... root preexec = /users/.create_home.sh '%S'
I lost the one that I was using. -- CyberLeo
createhome.sh:
#!/bin/sh -e
pebkac() {
echo "Usage: $(basename "${0}") <username>" >&2
echo "" >&2
echo "Create the zfs home directories for the given user if they do not exist." >&2
exit 1
}
fsbase="$(realpath "$(dirname "${0}")")"
zpbase="$(mount | grep ' on '"${fsbase}"' ' | cut -d' ' -f1)"
user="${1}"
[ "${user}" ] || pebkac
zpuser="${zpbase}/${user}"
fsuser="${fsbase}/${user}"
[ ! -e "${fsuser}" ] || exit 0
fspublic="${fsuser}/Public"
fsprivate="${fsuser}/Private"
fsdropbox="${fsuser}/DropBox"
fsrecycle="${fsuser}/.recycle"
zfs create "${zpuser}"
mkdir -p "${fspublic}"
chmod 755 "${fspublic}"
mkdir -p "${fsprivate}"
chmod 700 "${fsprivate}"
mkdir -p "${fsdropbox}"
chmod 1777 "${fsdropbox}"
mkdir -p "${fsrecycle}"
chmod 777 "${fsrecycle}"
chown -R "${user}" "${fsuser}"
