#!/bin/sh # @(#) automounter executable script. # @(#) $Id: auto_homedir.sh,v 1.3 2010/05/20 21:06:35 mchurchi Exp $ # ---------------------------------------------------------------------- # Create a users home directory and copy system profiles in place if # they do not exit. # # This script must be referenced in /etc/auto_master in order to have # any effect. For example: # # /home /etc/auto_homedir.sh # # Furthermore, it must have the sticky bit set: # # chmod +t+x /etc/auto_homedir.sh # # Prereq: # Solaris 10 requires patches 147774-01 (sparc) 147775-01 (x86) # 7085850 automounter fails to execute executable automounter maps # # Input: # This script receives an arg $1 which is the name of the object # (directory) that is being accessed under the moint point. # # Output: # Returns the path of the physical home dir on sdtout, ie: # localhost:johndoe # ---------------------------------------------------------------------- # ---------------------------------------------------------------------- # Set following vars to match your environment # MNTDIR=/home ; # Path of your mount point PHYSDIR=/export/home ; # Location of the physical user home directory USERGRP="staff" ; # The group name to give to the user's home dir # # NOTE: MNTDIR must match the first column in /etc/auto_master file. # ---------------------------------------------------------------------- # Check if user who is logging in exists in passwd name service getent passwd $1 >/dev/null if [ $? -ne 0 ] then exit fi # ---------------------------------------------------------------------- # Now we know that $1 is a valid user set home directory HDIR="${MNTDIR}/$1" ; # Mount point to home dir PDIR="${PHYSDIR}/$1" ; # Physical patch to home dir # ---------------------------------------------------------------------- # Next see if the user's physical home dir exist. If not create it. if [ ! -d "$PDIR" ] then # Create the physical home directory mkdir -p "${PDIR}" # Copy system profiles cp -r /etc/skel "${PDIR}/" # Set owner/group chown -R "$1":"$USERGRP" "${PDIR}" fi # ---------------------------------------------------------------------- # Return the path of the physical home dir to the automounter and exit. echo "localhost:$PDIR" exit