root/releases/bedework-3.7/util/processLocationData.sh

Revision 2962 (checked in by bleibson, 3 years ago)

fix attribute typo

  • Property svn:executable set to *
Line 
1 #! /bin/bash -f
2
3 #--- Settings ---
4
5 uidPrefix="bw"
6 uidSuffix="@berkeley.edu"
7 locLdapContainer='ou=locations,ou=public,dc=bedework,dc=org'
8 peopleLdapContainer='ou=locations,dc=bedework,dc=org'
9
10 # data was generated by taking the Berkeley data and putting it through `grep '^[a-zA-Z ]* ([0-9]*)'`
11 # to get records that are likely to be a building and a room number.
12
13 # input
14 INFILE=$1
15 # field seperator used in input file
16 FS='|'
17
18 # output
19 LDAPLOC=ldapLoc.ldif
20 VCARDLOC=vcardLoc
21 LDAPPEOPLE=ldapPeople
22 VCARDPEOPLE=vcardPeople
23
24 LDAPSetLines="objectclass: top
25 objectclass: calendarresource
26 objectclass: schedapprovalinfo
27 objectclass: calEntry
28 objectclass: room"
29
30 VCARDHeader="BEGIN:VCARD
31    VERSION:4.0"
32 VCARDFooter="   END:VCARD"
33
34 #--- end settings ---
35
36 cp /dev/null $LDAPLOC
37 cp /dev/null $VCARDLOC
38 cp /dev/null $LDAPPEOPLE
39 cp /dev/null $VCARDPEOPLE
40
41 counter=0
42 while read line; do
43         buildPerson="false"     
44         counter=`expr $counter + 1`
45        
46        
47         #F1 => room description
48         F1=$(echo $line|cut -d $FS -f 1)
49         # we'll hack together a cn/FN out of the description.
50         cn=`echo $F1 | sed 's/ Hall//;s/ Building//;s/ Center//;s/ Bldg//' \
51             | sed 's/ Student Ctr//;s/ Media Room//;s/ Art History Seminar Room//;s/ Place//' \
52             | cut -d \| -f1 | cut -d ')' -f1 \
53             | sed 's/ //g;s/(//'`
54        
55         F2=$(echo $line|cut -d $FS -f 2)
56         #F3 => capacity/CAPACITY
57         F3=$(echo $line|cut -d $FS -f 3)
58         #F4 => last name of room manager
59         F4=$(echo $line|cut -d $FS -f 4)
60         #F5 => first name of room manager
61         F5=$(echo $line|cut -d $FS -f 5)
62         if [ "$F5" != "" ]; then
63                 buildPerson="true"
64                 roomManager=${F5}${F4}
65     fi
66         #F6 => phone number of room manager
67         F6=$(echo $line|cut -d $FS -f 6)
68         contactPhone=$F6
69         #F7 => fax number of room manager
70         F7=$(echo $line|cut -d $FS -f 7)
71         contactFax=$F7
72         #F8 => email of room manager
73         F8=$(echo $line|cut -d $FS -f 8)
74         contactEmail=$F8
75         #F9 =>
76         F9=$(echo $line|cut -d $FS -f 9)
77         F10=$(echo $line|cut -d $FS -f10)
78         #F11 Requires Approval
79         F11=$(echo $line|cut -d $FS -f11)
80         if [ "$F11" = "" ]; then
81           autoaccept=TRUE
82         else
83           autoaccept=FALSE
84         fi
85         F12=$(echo $line|cut -d $FS -f12)
86         F13=$(echo $line|cut -d $FS -f13)
87        
88         #generate UID
89         case $counter in
90                 ?) normalizedCounter="00000${counter}"
91                    ;;
92                 ??) normalizedCounter="0000${counter}"
93                ;;
94             ???) normalizedCounter="000${counter}"
95                ;;
96         esac
97         uid="${uidPrefix}${normalizedCounter}${uidSuffix}"
98
99     # If no info on autoaccept, turn it on.     
100         if [ "$F12" = "" ]; then
101                 F12="TRUE"
102         fi
103        
104 #### locations
105        
106     #LDAP
107 echo "dn: cn=$cn,$locLdapContainer
108 $LDAPSetLines
109 kind: location
110 uid: $uid
111 calCalAdrURI: mailto:loc_${cn}${uidSuffix}
112 mail: loc_${cn}${uidSuffix}
113 cn: $cn
114 ou: locations
115 description: $F1" >> $LDAPLOC
116   if [ "$F3" != "" ]; then
117     echo "capacity: $F3" >> $LDAPLOC
118   fi
119   echo "autoschedule: $autoaccept
120 " >> $LDAPLOC
121
122     #VCARD
123   echo "$VCARDHeader
124    UID:urn:uuid:$uid
125    KIND: location
126    FN: $cn
127    ORG: locations
128    NOTE: $F1
129    CAPACITY: $F3
130    AUTOACCEPT: $autoaccept
131 $VCARDFooter
132 " >> $VCARDLOC
133
134 ### people
135   if [ $buildPerson = "true" ]; then
136         echo "dn: cn=${roomManager}, $peopleLdapContainer" >> $LDAPPEOPLE
137   fi
138
139 done < $INFILE
140
141
Note: See TracBrowser for help on using the browser.