3 # Usage get_info { all_projects |
5 # all_project_members |
6 # member_project { asok | dgross } |
7 # project_attribute { Codegen vwstation} |
8 # member_attribute { asok phone } |
17 # emit_error { error_code returned by get_info()
22 # Set me to command name
26 adm_base=${adm_base:-$HOME/adm}
29 adm_fpath=${adm_fpath:-$adm_base/functions}
32 machines=${machines:-$adm_base/data/machines}
37 DBDIR=$adm_base/data/db/get_info
41 trap "cleanup" 1 2 3 8 15
43 ####### Begin error message catalog. #############
45 MSG[0]="get_info:LDAP CONNECTION SUCCESSFUL"
46 MSG[1]="get_info:LDAP OPERATIONS ERROR"
47 MSG[2]="get_info:LDAP PROTOCOL ERROR"
48 MSG[3]="get_info:LDAP TIMELIMIT EXCEEDED"
49 MSG[4]="get_info:LDAP SIZELIMIT EXCEEDED"
50 MSG[5]="get_info:LDAP COMPARE FALSE"
51 MSG[6]="get_info:LDAP COMPARE TRUE"
52 MSG[7]="get_info:LDAP STRONG AUTH NOT SUPPORTED"
53 MSG[8]="get_info:LDAP STRONG AUTH REQUIRED"
54 MSG[9]="get_info:LDAP PARTIAL RESULTS"
56 MSG[16]="get_info:LDAP NO SUCH ATTRIBUTE"
57 MSG[17]="get_info:LDAP UNDEFINED TYPE"
58 MSG[18]="get_info:LDAP INAPPROPRIATE MATCHING "
59 MSG[19]="get_info:LDAP CONSTRAINT VIOLATION "
60 MSG[20]="get_info:LDAP TYPE OR VALUE EXISTS "
61 MSG[21]="get_info:LDAP INVALID SYNTAX "
63 MSG[32]="get_info:LDAP NO SUCH OBJECT "
64 MSG[33]="get_info:LDAP ALIAS PROBLEM "
65 MSG[34]="get_info:LDAP INVALID DN SYNTAX "
66 MSG[35]="get_info:LDAP IS LEAF "
67 MSG[36]="get_info:LDAP ALIAS DEREF PROBLEM "
68 MSG[37]="NAME ERROR(n) ((n & 0xf0) == 0x20)"
70 MSG[48]="get_info:LDAP INAPPROPRIATE AUTH "
71 MSG[49]="get_info:LDAP INVALID CREDENTIALS "
72 MSG[50]="get_info:LDAP INSUFFICIENT ACCESS "
73 MSG[51]="get_info:LDAP BUSY "
74 MSG[52]="get_info:LDAP UNAVAILABLE "
75 MSG[53]="get_info:LDAP UNWILLING TO PERFORM "
76 MSG[54]="get_info:LDAP LOOP DETECT "
78 MSG[64]="get_info:LDAP NAMING VIOLATION "
79 MSG[65]="get_info:LDAP OBJECT CLASS VIOLATION "
80 MSG[66]="get_info:LDAP NOT ALLOWED ON NONLEAF "
81 MSG[67]="get_info:LDAP NOT ALLOWED ON RDN "
82 MSG[68]="get_info:LDAP ALREADY EXISTS "
83 MSG[69]="get_info:LDAP NO OBJECT CLASS MODS "
84 MSG[70]="get_info:LDAP RESULTS TOO LARGE "
86 MSG[80]="get_info:LDAP OTHER "
87 MSG[81]="get_info:LDAP SERVER DOWN "
88 MSG[82]="get_info:LDAP LOCAL ERROR "
89 MSG[83]="get_info:LDAP ENCODING ERROR "
90 MSG[84]="get_info:LDAP DECODING ERROR "
91 MSG[85]="get_info:LDAP TIMEOUT "
92 MSG[86]="get_info:LDAP AUTH UNKNOWN "
93 MSG[87]="get_info:LDAP FILTER ERROR "
94 MSG[88]="get_info:LDAP USER CANCELLED "
95 MSG[89]="get_info:LDAP PARAM ERROR "
96 MSG[90]="get_info:LDAP NO MEMORY "
97 MSG[91]="get_info:LDAP CONNECT ERROR "
99 # errors related to remsh or OS interface.
100 MSG[201]="get_info:ERROR while fixing .rhosts file in preparation for
102 MSG[202]="get_info:ERROR remsh failed while invoking get_info on CLLWEB"
103 MSG[203]="get_info:ERROR uname returned un-supported OS."
105 # User interface errors while using get_info()
106 MSG[210]="get_info:ERROR insufficient arguments to get_info()"
107 MSG[211]="get_info:ERROR requested member project not found in data-base."
108 MSG[212]="get_info:ERROR requested project not found in data-base."
109 MSG[213]="get_info:ERROR database directory not found."
110 MSG[214]="get_info:ERROR gven member not found in data-base."
113 MSG[500]="get_info:ERROR BAD/un-implemented Error number"
114 ####### End error message catalog. #############
118 [ -z "${MSG[$1]}" ] && echo ${MSG[500]} || echo ${MSG[$1]}
127 #######################################################
128 # Start processing questions . . .
129 # Get member project name for a given member name.
130 # usage# save_get_info member_project amitp
132 # This function will save information from data-base in
133 # a temporary file, so that cleanup can prefix this
134 # output with error code. This is done to pass error
135 # code returned by the command passed to remsh.
137 # Ex: remsh "get_info member_project amitp"
139 # remsh returns status of itself(remsh) not the status
146 # Get all members for a given project.
147 [ $# -ne 2 ] && cleanup 210
148 [ ! -f $2.proj ] && cleanup 212
149 RESULT=`grep "^project:$2" *.mem | awk -F. '{print $1}'`
153 # Get member project name for a given member name.
154 [ $# -ne 2 ] && cleanup 210
155 [ ! -f $2.mem ] && cleanup 214
156 RESULT=`grep "^project:" $2.mem | awk -F: '{print $2}'`
160 # Get project attribute for a given project name.
161 [ ! -f $2.proj ] && cleanup 212
162 [ $# -eq 3 ] && RESULT=`grep "^$3:" $2.proj | awk -F: '{print $2}'`
163 || RESULT=`awk -F: '{printf "%s= %s\n", $1, $2}' $2.proj`
167 # Get member attribute for a given member name.
168 [ ! -f $2.mem ] && cleanup 212
169 [ $# -eq 3 ] && RESULT=`grep "^$3:" $2.mem | awk -F: '{print $2}'`
170 || RESULT=`awk -F: '{printf "%s = %s\n", $1, $2}' $2.mem`
174 # Get machine attribute for a given machine name.
175 [ ! -f $2.mach ] && cleanup 212
176 [ $# -eq 3 ] && RESULT=`grep "^$3:" $2.mach | awk -F: '{print $2}'`
177 || RESULT=`awk -F: '{printf "%s = %s\n", $1, $2}' $2.mach`
181 # Get project attribute for a given project name.
182 [ $# -ne 2 ] && cleanup 210
183 [ ! -f $2.proj ] && cleanup 212
184 RESULT=`grep "^project:" $2.proj | awk -d: '{print $2}'`
188 RESULT=`/bin/ls *.proj | awk -F. '{print $1}'`
192 RESULT=`/bin/ls *.mem | awk -F. '{print $1}'`
196 [ $# -ne 2 ] && cleanup 210
199 grepfor="Build Server"
202 grepfor="Mail Server"
205 grepfor="View Server"
208 grepfor="Virtual Workstation"
220 # RESULT=`grep "^server:$2" *.mach | awk -F. '{print $1}'`
221 RESULT=`grep -v "^#" $machines | grep ":Infrastructure:" | grep
222 "$grepfor" | awk -F: '{print $1}'`
225 # Error in input argument.
231 ######################## Main starts here ############
237 typeset integer MULTILINE=1
241 # old version compatibility
245 [ $# -eq 2 ] && print_error_msg $2 || exit 210 # Incorrect argument
249 # go to processing outside case block
253 [ ! -d $DBDIR ] && cleanup 213
256 [ $MULTILINE ] && echo "$RESULT" || echo $RESULT