#!/bin/sh -e
#
# Univention PAM
#  helper script: creates and mounts home directory if necessary
#
# SPDX-FileCopyrightText: 2004-2025 Univention GmbH
# SPDX-License-Identifier: AGPL-3.0-only

test -z "$USER" && exit 1
test -z "$HOME" && exit 1

if [ -x "/usr/sbin/univention-mount-homedir" ]; then
	exec /usr/sbin/univention-mount-homedir
elif ! [ -d "$HOME" ]; then
	mkdir $HOME
	chown `getent passwd $USER | awk -F : '{print $3":"$4}'` $HOME
fi
