samba/samba-mkhomedir.sh

35 lines
797 B
Bash
Raw Permalink Normal View History

#!/bin/sh
# mkhomedir.sh -- automatically create user homedirs for Samba DC users
# Copyright (C) 2005 Silvan Calarco <silvan.calarco@qilinux.it>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License version 2 as published by the
# Free Software Foundation. There is NO warranty; not even for MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.
#
# me=${0##*/}
[ "$1" ] || {
echo "Usage: $0 <user>"
exit 1;
}
getent passwd $1 >/dev/null || {
echo "Error: user $1 does not exits. Exiting."
exit 1;
}
[ -e "/home" ] || {
echo "Error: directory /home does not exits. Exiting."
exit 1;
}
HOMEUSER=$1
HOMEDIR=/home/$1
[ -e "$HOMEDIR" ] && exit 0;
cp -a /etc/skel $HOMEDIR
chown -R "$HOMEUSER":"Domain Users" $HOMEDIR