Files
aad-local-file-share/samba/samba-private-mkdir.sh
Ludwig Lehnert 70fe6076a4 initial commit
2026-02-03 16:39:37 +01:00

25 lines
608 B
Bash

#!/usr/bin/env bash
set -euo pipefail
user="$1"
domain="${2:-}"
target="/data/private/${user}"
if [ ! -d "${target}" ]; then
mkdir -p "${target}"
chmod 0700 "${target}"
fi
if getent passwd "${user}" >/dev/null 2>&1; then
uid=$(getent passwd "${user}" | cut -d: -f3)
gid=$(getent passwd "${user}" | cut -d: -f4)
chown "${uid}:${gid}" "${target}"
exit 0
fi
if [ -n "${domain}" ] && getent passwd "${domain}\\${user}" >/dev/null 2>&1; then
uid=$(getent passwd "${domain}\\${user}" | cut -d: -f3)
gid=$(getent passwd "${domain}\\${user}" | cut -d: -f4)
chown "${uid}:${gid}" "${target}"
fi