mzs: adjust relative paths to match ipreg repo
[ipreg/sccs2rcs2cvs2git.git] / ipreg-pre-uplift
1 #!/bin/sh
2
3 # remove file if it is a duplicate
4 # usage: rm-dup <keep-dir> <dup-dir> <basename>
5 rm_dup() {
6         if [ -f "$2/$3" ] && diff "$1/$3" "$2/$3"
7         then rm -f "$2/$3"
8         fi
9 }
10
11 # move a file or directory if it exists
12 mvp() {
13         if [ -e "$1" ] && ! [ -e "$2" ]
14         then mv "$1" "$2"
15         fi
16 }
17
18 B="\e[32m"
19 D="\e[0m"
20
21 set -e -x
22
23 : $B PRE-UPLIFT START $(date +%Y-%m-%d.%H:%M:%S) $D
24
25 : $B correct permissions $D
26 chmod -R u+w ip-register
27
28 : $B move mail archives out $D
29 mkdir -p ipreg-mail/old
30 mvp ip-register/old-group-Internet/Institutions ipreg-mail/Institutions
31 for f in ip-register/Mail/mboxx.*
32 do
33         [ ! -f "$f" ] && break
34         suffix=${f#*mboxx.}
35         dir=ipreg-mail/${suffix%-??.gz}
36         mkdir -p $dir
37         mvp $f $dir/$suffix
38 done
39 # I think these are duplicates of what has already been moved
40 mvp ip-register/archive/dump/Mail.960326.tar.gz \
41               ipreg-mail/old/Mail.19960326.tar.gz
42 mvp ip-register/archive/dump/Mail.20000303.tar.gz \
43               ipreg-mail/old/Mail.20000303.tar.gz
44 mvp ip-register/archive/dump/Institutions.tar.gz \
45               ipreg-mail/old/Institutions.19960111.tar.gz
46 mvp ip-register/archive/dump/Institutions.960326.tar.gz \
47               ipreg-mail/old/Institutions.19960326.tar.gz
48 mvp ip-register/archive/dump/Institutions.20000303.tar.gz \
49               ipreg-mail/old/Institutions.20000303.tar.gz
50
51 : $B move secrets out $D
52 mkdir -p ipreg-secrets/passwords
53
54 mvp ip-register/Mail/password     ipreg-secrets/passwords/internet@hermes.cam.ac.uk
55 mvp ip-register/DNS/dlv-password  ipreg-secrets/passwords/cambuniv@dlv.isc.org
56 mvp ip-register/DNS/ripe-password ipreg-secrets/passwords/CAM-AC-UK-HOSTMASTER-MNT@ripe.net
57
58 mvp ip-register/DNS/keys    ipreg-secrets/tsigkeys
59 mvp ip-register/DNS/dnskeys ipreg-secrets/dnskeys
60 mvp ip-register/DNS/.ssh    ipreg-secrets/sshkeys
61
62 : $B saner archive filenames $D
63 mvp ip-register/archive/archive/DB/s.DB.cam.23.06.93.gz \
64     ip-register/archive/archive/DB/s.DB.cam.19930623.gz
65 mvp ip-register/archive/archive/DB/s.DB.cam.31.03.94.gz \
66     ip-register/archive/archive/DB/s.DB.cam.19950331.gz # sic!
67 mvp ip-register/archive/archive/DB/s.DB.cam.08.09.94.gz \
68     ip-register/archive/archive/DB/s.DB.cam.19940908.gz
69 mvp ip-register/archive/archive/DB/s.DB.cam.23.11.95.gz \
70     ip-register/archive/archive/DB/s.DB.cam.19951123.gz
71 mvp ip-register/archive/archive/DB/s.DB.cam.961015.gz \
72     ip-register/archive/archive/DB/s.DB.cam.19961015.gz
73 mvp ip-register/archive/archive/DB/s.DB.cam.970211.gz \
74     ip-register/archive/archive/DB/s.DB.cam.19970211.gz
75 mvp ip-register/archive/archive/Hosts/s.hosts.131.111.23June93.gz \
76     ip-register/archive/archive/Hosts/s.hosts.131.111.19930623.gz
77 mvp ip-register/archive/archive/Hosts/s.hosts.131.111.17Feb94.gz \
78     ip-register/archive/archive/Hosts/s.hosts.131.111.19940217.gz
79 mvp ip-register/archive/archive/Hosts/s.hosts.131.111.14Jun94.gz \
80     ip-register/archive/archive/Hosts/s.hosts.131.111.19940614.gz
81 mvp ip-register/archive/archive/Hosts/s.hosts.131.111.950403.gz \
82     ip-register/archive/archive/Hosts/s.hosts.131.111.19950403.gz
83 mvp ip-register/archive/archive/Hosts/s.hosts.131.111.951123.gz \
84     ip-register/archive/archive/Hosts/s.hosts.131.111.19951123.gz
85 mvp ip-register/archive/archive/Hosts/s.hosts.131.111.961014.gz \
86     ip-register/archive/archive/Hosts/s.hosts.131.111.19961014.gz
87 mvp ip-register/archive/archive/Hosts/s.hosts.131.111.970211.gz \
88     ip-register/archive/archive/Hosts/s.hosts.131.111.19970211.gz
89 mvp ip-register/archive/dump/DNS.960326.tar.gz \
90     ip-register/archive/dump/DNS.19960326.tar.gz
91 mvp ip-register/archive/dump/adm.960326.tar.gz \
92     ip-register/archive/dump/adm.19960326.tar.gz
93 mvp ip-register/archive/dump/bin.960326.tar.gz \
94     ip-register/archive/dump/bin.19960326.tar.gz
95
96 : $B extract tarballs $D
97 mvp ip-register/old-group-Internet/MAC.addresses.ancient.tar.gz \
98     ip-register/old-group-Internet/MAC.addresses.tar.gz
99 if [ -e ip-register/archive/archive/migration/done.tar.gz ]
100 then
101         owd=$(pwd)
102         cd ip-register/archive/archive/migration
103         tar fx done.tar.gz
104         rm done.tar.gz
105         cd $owd
106 fi
107 rm -f ipreg-tarballs/usermap
108 find ip-register -name '*.tar.gz' |
109 while read pathname
110 do
111         owd=$(pwd)
112         subdir=$(dirname $pathname)
113         f=$(basename $pathname)
114         d=${f%.tar.gz}
115         cd $subdir
116         [ ! -d $d ]
117         set -- $(tar tf $f | sed 's|/.*||' | sort -u)
118         case $# in
119         1)      tar xf $f
120                 [ $1 != $d ] && mv $1 $d
121                 remove=$1/
122                 ;;
123         *)      mkdir $d
124                 cd $d
125                 tar xf ../$f
126                 remove=""
127                 ;;
128         esac
129         cd $owd
130         mkdir -p ipreg-tarballs/$subdir
131         mv $pathname ipreg-tarballs/$subdir
132         tar tfv ipreg-tarballs/$subdir/$f |
133         tar2usermap -mipreg-tarballs/usermap "$remove" "$owd/$subdir/$d/"
134 done
135 : $B case-insensitivity fixup for testing on Mac OS $D
136 uclc() {
137     rm -f $2 $3
138     tar xf $1 $2
139     if [ ! -f $3 ]
140     then tar xf $1 $3
141     else : $B WARNING omitting $3 $D
142     fi
143 }
144 DNS1996=ip-register/archive/dump/DNS.19960326
145 DNS2000=ip-register/archive/dump/DNS.20000303
146 (
147     cd $DNS1996
148     uclc ../../../../ipreg-tarballs/$DNS1996.tar.gz DB.cam db.cam
149     uclc ../../../../ipreg-tarballs/$DNS1996.tar.gz DB.cambridge db.cambridge
150 )
151 (
152     cd $DNS2000
153     uclc ../../../../ipreg-tarballs/$DNS2000.tar.gz DNS/DB.cam DNS/db.cam
154     uclc ../../../../ipreg-tarballs/$DNS2000.tar.gz DNS/DB.cam.ipv6 DNS/db.cam.ipv6
155     uclc ../../../../ipreg-tarballs/$DNS2000.tar.gz DNS/DB.cambridge DNS/db.cambridge
156     for f in $(ls DNS)
157     do  rm -f $f
158         mv DNS/$f $f
159     done
160     rmdir DNS
161 )
162
163 : $B fix keyword corruption $D
164 # do this before cleaning duplicated history!
165 (
166         cd ip-register/nameserver_config
167         mv sbin-named sbin-named.tmp.$$
168         sccs get -k sbin-named
169         touch -r sbin-named.tmp.$$ sbin-named
170         rm -f sbin-named.tmp.$$
171 )
172 (
173         cd ip-register/DNS/historic
174         mv makezones makezones.tmp.$$
175         sccs get -k makezones
176         touch -r makezones.tmp.$$ makezones
177         rm -f makezones.tmp.$$
178 )
179
180 : $B remove duplicated archive files $D
181 rm_dup ip-register/archive/archive/DB    ip-register/archive/dump/DNS.20000303/SCCS        s.DB.cam.20000202.gz
182 rm_dup ip-register/archive/archive/DB    ip-register/DNS/SCCS                              s.DB.cam.20020718.gz
183 rm_dup ip-register/archive/archive/Hosts ip-register/archive/dump/adm.20000303/SCCS s.hosts.131.111.20000303.gz
184 rm_dup ip-register/archive/archive/Hosts ip-register/adm/SCCS                       s.hosts.131.111.20020910.gz
185 rm_dup ip-register/archive/archive/Hosts ip-register/adm/SCCS                       s.hosts.131.111.20051206.gz
186 rm_dup ip-register/archive/archive/Hosts ip-register/adm                         tombstones.131.111.20020910.gz
187 # this file is almost exactly a prefix of s.hosts.131.111.951123
188 # there are minor differences in the last revision of this file
189 # which it would be annoyingly difficult to preserve
190 rm -f ip-register/archive/archive/Hosts/s.hosts.131.111.back.950725.gz
191 # this file just contains a timestamp so isn't worth preserving
192 rm -f ip-register/archive/archive/Hosts/tombstones.131.111.2002.02.05
193
194 : $B unzip archived SCCS files $D
195 for f in ip-register/archive/archive/DB/*.gz \
196          ip-register/archive/archive/Hosts/*.gz
197 do
198         [ -f "$f" ] && gunzip "$f"
199 done
200
201 : $B unzip text files $D
202 for f in ip-register/archive/dump/ip_in_cam.gz \
203          ip-register/archive/dump/adm.19960326/diffs.951123.gz \
204          ip-register/archive/dump/adm.19960326/hosts.131.111.dump951117.gz
205 do [ -e $f ] && gunzip $f
206 done
207
208 : $B remove duplicated SCCS history $D
209 for d in 19960326 20000303
210 do
211         for f in DB.cam.ipv6 \
212                  DB.cambridge \
213                  db.cache.byhand \
214                  Makefile \
215                  makezones \
216                  mgrs.dl \
217                  named.boot.zones.tomb
218         do
219                 s=SCCS/s.$f
220                 if [ -f ip-register/archive/dump/DNS.$d/$s ] &&
221                    [ -f ip-register/DNS/historic/$s ] &&
222                    sccsprefix ip-register/archive/dump/DNS.$d/$s \
223                            ip-register/DNS/historic/$s
224                 then rm -f ip-register/archive/dump/DNS.$d/$s
225                 elif [ -f ip-register/archive/dump/DNS.$d/$s ] &&
226                      [ -f ip-register/DNS/$s ] &&
227                      sccsprefix ip-register/archive/dump/DNS.$d/$s \
228                            ip-register/DNS/$s
229                 then rm -f ip-register/archive/dump/DNS.$d/$s
230                 fi
231         done
232 done
233 for d in 19960326 19990226 20000303
234 do      for f in hosts2DB mailarch
235         do      if [ -f ip-register/archive/dump/bin.$d/SCCS/s.$f ] &&
236                    [ -f ip-register/old-group-Internet/bin/SCCS/s.$f ] &&
237                    sccsprefix ip-register/archive/dump/bin.$d/SCCS/s.$f \
238                               ip-register/old-group-Internet/bin/SCCS/s.$f
239                 then rm -f    ip-register/archive/dump/bin.$d/SCCS/s.$f
240                 fi
241         done
242 done
243 if sccsprefix ip-register/archive/dump/adm.20000303/SCCS/s.Makefile \
244               ip-register/adm/SCCS/s.Makefile
245 then rm -f    ip-register/archive/dump/adm.20000303/SCCS/s.Makefile
246 fi
247 if sccsprefix ip-register/archive/dump/adm.19960326/SCCS/s.Makefile \
248               ip-register/adm/SCCS/s.Makefile
249 then rm -f    ip-register/archive/dump/adm.19960326/SCCS/s.Makefile
250 fi
251 if : sccsprefix ip-register/archive/dump/adm.19960326/SCCS/s.hosts.131.111 \
252                 ip-register/archive/archive/Hosts/s.hosts.131.111.19961014
253 then rm -f      ip-register/archive/dump/adm.19960326/SCCS/s.hosts.131.111
254 fi
255 if sccsprefix ip-register/archive/dump/DNS.19960326/SCCS/s.DB.cam \
256               ip-register/archive/archive/DB/s.DB.cam.19961015
257 then rm -f    ip-register/archive/dump/DNS.19960326/SCCS/s.DB.cam
258 fi
259 if sccsprefix ip-register/archive/dump/DNS.20000303/SCCS/s.DB.cam \
260               ip-register/archive/archive/DB/s.DB.cam.20000713
261 then rm -f    ip-register/archive/dump/DNS.20000303/SCCS/s.DB.cam
262 fi
263 if sccsprefix ip-register/archive/dump/DNS.20000303/SCCS/s.named.conf.zones \
264               ip-register/DNS/SCCS/s.named.conf.shared
265 then rm -f    ip-register/archive/dump/DNS.20000303/SCCS/s.named.conf.zones
266 fi
267 if sccsprefix ip-register/archive/dump/DNS.19960326/SCCS/s.named.boot \
268               ip-register/DNS/SCCS/s.named.boot.zones.tomb
269 then rm -f    ip-register/archive/dump/DNS.19960326/SCCS/s.named.boot
270 fi
271 if sccsprefix ip-register/archive/dump/DNS.19960326/SCCS/s.db.cache \
272               ip-register/DNS/historic/SCCS/s.db.cache.byhand
273 then rm -f    ip-register/archive/dump/DNS.19960326/SCCS/s.db.cache
274 fi
275
276 : $B correct dates on tombstones $D
277 untouch ip-register/archive/archive/Hosts/tombstones.*
278
279 : $B remove working files $D
280 ## these are part of the zone update machinery
281 # apexNS/*      <- apexzones
282 # checkns/*     KEEP config and scripts
283 # delegations/* KEEP config files
284 # fakezones/*   <- fake1zone <- updatezones
285 # newzones/*    <- update1zone <- updatezones
286 # updates/*     <- update1zone <- updatezones
287 # zones/*       <- buildzones
288 for z in apexNS fakezones newzones savezones updates zones
289 do
290         rm -f ip-register/DNS/$z/*
291 done
292 # checkns/.??*     <- checkns/checkns.pl
293 # delegations/.??* <- deletagezones
294 # fakezones/.??*   <- fake1zone <- updatezones
295 # newzones/.??*    <- update1zone <- updatezones
296 # updates/.??*     <- update1zone <- updatezones
297 for z in checkns delegations fakezones newzones updates
298 do
299         rm -f ip-register/DNS/$z/.??*
300 done
301 ## name server configuration machinery
302 # config_*/* <- Makefile
303 for ch in ip-register/DNS/config_*
304 do
305         rm -f $ch/*
306 done
307 rm -f ip-register/DNS/apex_timestamp
308 rm -f ip-register/DNS/database_timestamps
309 # <- adm/mkslave
310 rm -f ip-register/IPreg.*
311 # object code
312 rm -f ip-register/DNS/lockDNS
313 # and its lock file
314 rm -f ip-register/DNS/.lock
315 # <- db/ipfilter/cronjob
316 rm -f ip-register/db/ipfilter/data/*
317
318 : $B PRE-UPLIFT DONE $(date +%Y-%m-%d.%H:%M:%S) $D