2 ################################################################################
4 # File: add_synchronize
5 # RCS: $Header: add_synchronize,v 1.2 97/05/27 15:35:51 defaria Exp
7 # Description: This script adds a new person to synchronize
8 # Author: Andrew DeFaria, California Language Labs
9 # Created: Mon May 19 15:56:06 PDT 1997
11 # Language: Korn Shell
13 # (c) Copyright 2001, Andrew@DeFaria.com, all rights reserved
15 ################################################################################
16 # Set me to command name
20 adm_base=${adm_base:-$HOME/adm}
23 adm_fpath=${adm_fpath:-$adm_base/functions}
29 print -u2 "Usage: $me -username <username> -fullname <fullname>"
30 print -u2 "\t-groupname <groupname>"
34 function add_to_synchronize {
36 check_out_file=$synchro_users
37 co -q -l $check_out_file
40 error "Unable to checkout $check_out_file"
44 trap cancel_checkout INT ERR
46 print "$fullname,\t$username,\t$username@cup.hp.com" >> $check_out_file
49 error "Unable to add entry to $check_out_file"
53 ci -u -q -m"Added $fullname" $check_out_file
55 error "Unable to check in $check_out_file!"
62 } # add_to_synchronize
64 function add_to_synchronize_group {
65 cd $synchro_db/GroupTemplates
66 check_out_file=$groupname
67 co -q -l $check_out_file
70 error "Unable to checkout $check_out_file"
74 trap cancel_checkout INT ERR
76 print "$fullname" >> $check_out_file
79 error "Unable to add entry to $check_out_file"
83 ci -u -q -m"Added $fullname to $check_out_file" $check_out_file
85 error "Unable to check in $check_out_file!"
94 error "Rebuilding of Synchronize groups failed"
99 } # add_to_synchronize_group
101 function cancel_checkout {
102 info "Canceling checkout"
103 rcs -q -u $check_out_file
104 chmod -w $check_out_file
105 co -q $check_out_file
109 function user_exists {
110 grep -ve "^#" $synchro_users | cut -f1 -d',' |
111 grep "^$username$" >/dev/null 2>&1
116 if [ -d /net/cllapp/opt/synchronize ]; then
117 synchro_dir=/net/cllapp/opt/synchronize
119 error "Internal error: Unable to ascertain synchro_dir!"
123 synchro_db=$synchro_dir/db
124 synchro_users=$synchro_db/users
130 while [ $# -ge 1 ]; do
137 if [ $# -le 1 ]; then
138 error "Username not specified!"
146 if [ $# -le 1 ]; then
147 error "Full name not specified!"
154 if [ $# -le 1 ]; then
155 error "Groupname not specified!"
163 error "Unknown parameter encounter: \"$1\""
170 if [ "_$username" = "_" -o \
171 "_$fullname" = "_" -o \
172 "_$groupname" = "_" ]; then
173 error "Missing parameter"
177 if $(user_exists); then
178 error "$username already exists in the Synchronize database"
179 elif [ ! -f $synchro_db/GroupTemplates/$groupname ]; then
180 error "Unknown Synchronize group $groupname"
183 if [ $? -eq 0 ]; then
184 info "$fullname has been added as a Synchronize user"
186 error "Problems encountered trying to create Synchronize user for
189 add_to_synchronize_group
190 if [ $? -eq 0 ]; then
191 info "$fullname has been successfully added to $groupname"
193 error "Problems encountered trying to add $fullname to $groupname"