2 ################################################################################
5 # Description: Create password file for cygwin
6 # Author: Andrew@DeFaria.com
7 # Created: Thu Oct 4 10:21:05 2001
11 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
13 ################################################################################
15 PATH="/usr/local/bin:/usr/bin:/bin:$PATH"
17 # Set me to command name
21 commonarea="//sonscentral/Corporate/Software"
24 adm_base=${adm_base:-$commonarea/adm}
27 adm_fpath=${adm_fpath:-$adm_base/functions}
34 master_passwd="$commonarea/etc/passwd"
35 master_group="$commonarea/etc/group"
38 display "Usage: $me -[v|erbose] -[d|ebug] -[u|sage]"
42 while [ $# -ge 1 ]; do
59 # First create passwd file
60 verbose "Creating master passwd file"
61 /bin/mkpasswd -d -o 0 > $tmpfile
64 # Change home directories
65 verbose "Fixing US home directories"
66 sed 's/\/\/sonscentral/\/us/' $tmpfile > $tmpfile.2
67 mv $tmpfile.2 $tmpfile
68 verbose "Fixing China home directories"
69 sed 's/\/\/sons-shanghai/\/china/' $tmpfile > $tmpfile.2
71 # Remove unnecessary $'s
72 verbose "Removing extra $'s"
73 sed 's/\$//' $tmpfile.2 > $tmpfile
75 # Now determine the real users from the psuedo users. We determine this by
76 # verifying that there home directory exists.
77 verbose "Determining real users"
83 sed 's/\\/\\\\/' $tmpfile | while read user pass uid gid geos home shell; do
84 # sonscenter is an old machine that no longer exists. It's now sonscentral.
85 if [[ $home = \/\/sonscenter* ]]; then
86 warning "Skipping user $user because $home does not exist"
87 elif [ -z "$home" ]; then
88 verbose "Puesdo user $user found (home directory is blank)"
89 echo "$user::$uid:$gid:$geos:$home:$shell" >> $tmpfile.2
90 elif [ -d "$home" ]; then
92 if [ "$user" = "ftp" ]; then
93 verbose "Substituting /bin/false for ftp's shell"
96 if [ "$user" = "gchharbra" ]; then
97 verbose "Substituting /bin/tcsh for $user's shell"
99 echo "$user::$uid:$gid:$geos:$home:$shell" >> $tmpfile.2
101 warning "Skipping user $user because $home does not exist"
105 # Save last master password file
106 if [ -f $master_passwd ]; then
107 cp $master_passwd $master_passwd.save
110 # Move in new master password file
111 mv $tmpfile.2 $master_passwd
113 # Save last master group file
114 if [ -f $master_group ]; then
115 cp $master_group $master_group.save
119 verbose "Creating master group file"
120 /bin/mkgroup -d -o 0 > $master_group