home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh -
- #
- # $Id: get-homes,v 5.1 89/11/17 18:24:15 jsp Exp Locker: jsp $
- #
- # Copyright (C) 1989 by Jan-Simon Pendry
- # All Rights Reserved.
- #
- # Grab copy of the password file and get the user names
- # and home directories from it.
- # Of course, the entire point is to remove the specific
- # details from the password file and replace it with /homes/username
- # so usually you only run this once to get the initial database
- # sorted out. After that just edit the database directly...
- #
- # Copes with machines running YP.
- #
- rpcinfo=/usr/etc/rpcinfo
-
- #
- # Check for optional first argument
- #
- case "$#" in
- 0)
- file=/dev/stdout;;
- 1)
- file="$1";;
- *)
- echo Usage: get-homes "[output-file]" 2>&1
- exit 1;;
- esac
-
- #
- # Figure out how to get the password file
- #
- if [ -x $rpcinfo ] && ($rpcinfo -p | grep -s ypbind) 2>/dev/null; then
- mkdata="ypcat passwd.byname"
- else
- mkdata="cat /etc/passwd"
- fi
-
- #
- # Possibly redirect stdout
- #
- if [ "$file" != /dev/stdout ]; then
- exec > "$file"
- fi
-
- #
- # Extract the required information
- #
- $mkdata | awk -F: '{printf "%s\t%s\n", $1, $6}'
-