#!/bin/sh ntmakehome() { # The home directory name. NTHOME="/home/BFREE.ON.CA/$1" # Check whether the directory already exists. if [ ! -d "$NTHOME" ] then # Create the home directory. cp -r /etc/skel "$NTHOME" # Change user ownership. chown -R "$1" "$NTHOME" # Get the primary group of this user. NTGROUP=$(id -n -g "$1") # Change group ownership. chgrp -R "$NTGROUP" "$NTHOME" fi } # The winbind daemon must connect to the domain as part of the "Domain Admins" # group for the enumeration to work properly. If the winbind daemon does not # connect as an administrator, then some users will be missed. # Enumerate all accounts with winbind and convert the names to lower case. wbinfo -u | tr '[:upper:]' '[:lower:]' | while read do # Create a home directory for each user. ($REPLY is a builtin variable.) ntmakehome "$REPLY" done # Update the time stamp on this file to indicate when the script last ran. touch "/home/update-homes.$(hostname).stamp" # eof