mail-uplift fix lines before and after message separator
[ipreg/sccs2rcs2cvs2git.git] / ipreg-pre-uplift
CommitLineData
155d5402
TF
1#!/bin/sh
2
e6b3bb1f
TF
3# remove file if it is a duplicate
4# usage: rm-dup <keep-dir> <dup-dir> <basename>
e4e51d28 5rm_dup() {
e6b3bb1f 6 if [ -f "$2/$3" ] && diff "$1/$3" "$2/$3"
454945b2 7 then rm -f "$2/$3"
e6b3bb1f
TF
8 fi
9}
10
11# move a file or directory if it exists
e8bc05c2 12mvp() {
9712472e 13 if [ -e "$1" ] && ! [ -e "$2" ]
73e0818b
TF
14 then mv "$1" "$2"
15 fi
e8bc05c2
TF
16}
17
73e0818b
TF
18B="\e[32m"
19D="\e[0m"
20
155d5402
TF
21set -e -x
22
b51de266 23: $B PRE-UPLIFT START $(date +%Y-%m-%d.%H:%M:%S) $D
cba75e22 24
73e0818b 25: $B correct permissions $D
155d5402 26chmod -R u+w ip-register
e8bc05c2 27
73e0818b 28: $B move mail archives out $D
9712472e 29mkdir -p ipreg-mail/old
e8bc05c2
TF
30mvp ip-register/old-group-Internet/Institutions ipreg-mail/Institutions
31for f in ip-register/Mail/mboxx.*
32do
33 [ ! -f "$f" ] && break
34 suffix=${f#*mboxx.}
35 dir=ipreg-mail/${suffix%-??.gz}
36 mkdir -p $dir
37 mvp $f $dir/$suffix
38done
9712472e
TF
39# I think these are duplicates of what has already been moved
40mvp ip-register/archive/dump/Mail.960326.tar.gz \
41 ipreg-mail/old/Mail.19960326.tar.gz
42mvp ip-register/archive/dump/Mail.20000303.tar.gz \
43 ipreg-mail/old/Mail.20000303.tar.gz
44mvp ip-register/archive/dump/Institutions.tar.gz \
45 ipreg-mail/old/Institutions.19960111.tar.gz
46mvp ip-register/archive/dump/Institutions.960326.tar.gz \
47 ipreg-mail/old/Institutions.19960326.tar.gz
48mvp ip-register/archive/dump/Institutions.20000303.tar.gz \
49 ipreg-mail/old/Institutions.20000303.tar.gz
e8bc05c2 50
756f9df7
TF
51: $B move secrets out $D
52mkdir -p ipreg-secrets/passwords
53
54mvp ip-register/Mail/password ipreg-secrets/passwords/internet@hermes.cam.ac.uk
55mvp ip-register/DNS/dlv-password ipreg-secrets/passwords/cambuniv@dlv.isc.org
56mvp ip-register/DNS/ripe-password ipreg-secrets/passwords/CAM-AC-UK-HOSTMASTER-MNT@ripe.net
57
9b119fe9 58mvp ip-register/DNS/keys ipreg-secrets/tsigkeys
756f9df7 59mvp ip-register/DNS/dnskeys ipreg-secrets/dnskeys
9b119fe9 60mvp ip-register/DNS/.ssh ipreg-secrets/sshkeys
e8bc05c2 61
73e0818b 62: $B saner archive filenames $D
54d01df2
TF
63mvp ip-register/archive/archive/DB/s.DB.cam.23.06.93.gz \
64 ip-register/archive/archive/DB/s.DB.cam.19930623.gz
65mvp ip-register/archive/archive/DB/s.DB.cam.31.03.94.gz \
66 ip-register/archive/archive/DB/s.DB.cam.19950331.gz # sic!
67mvp ip-register/archive/archive/DB/s.DB.cam.08.09.94.gz \
68 ip-register/archive/archive/DB/s.DB.cam.19940908.gz
69mvp ip-register/archive/archive/DB/s.DB.cam.23.11.95.gz \
70 ip-register/archive/archive/DB/s.DB.cam.19951123.gz
71mvp ip-register/archive/archive/DB/s.DB.cam.961015.gz \
72 ip-register/archive/archive/DB/s.DB.cam.19961015.gz
73mvp ip-register/archive/archive/DB/s.DB.cam.970211.gz \
74 ip-register/archive/archive/DB/s.DB.cam.19970211.gz
75mvp ip-register/archive/archive/Hosts/s.hosts.131.111.23June93.gz \
76 ip-register/archive/archive/Hosts/s.hosts.131.111.19930623.gz
77mvp ip-register/archive/archive/Hosts/s.hosts.131.111.17Feb94.gz \
78 ip-register/archive/archive/Hosts/s.hosts.131.111.19940217.gz
79mvp ip-register/archive/archive/Hosts/s.hosts.131.111.14Jun94.gz \
80 ip-register/archive/archive/Hosts/s.hosts.131.111.19940614.gz
81mvp ip-register/archive/archive/Hosts/s.hosts.131.111.950403.gz \
82 ip-register/archive/archive/Hosts/s.hosts.131.111.19950403.gz
54d01df2
TF
83mvp ip-register/archive/archive/Hosts/s.hosts.131.111.951123.gz \
84 ip-register/archive/archive/Hosts/s.hosts.131.111.19951123.gz
85mvp ip-register/archive/archive/Hosts/s.hosts.131.111.961014.gz \
86 ip-register/archive/archive/Hosts/s.hosts.131.111.19961014.gz
87mvp ip-register/archive/archive/Hosts/s.hosts.131.111.970211.gz \
88 ip-register/archive/archive/Hosts/s.hosts.131.111.19970211.gz
54d01df2
TF
89mvp ip-register/archive/dump/DNS.960326.tar.gz \
90 ip-register/archive/dump/DNS.19960326.tar.gz
54d01df2
TF
91mvp ip-register/archive/dump/adm.960326.tar.gz \
92 ip-register/archive/dump/adm.19960326.tar.gz
93mvp ip-register/archive/dump/bin.960326.tar.gz \
94 ip-register/archive/dump/bin.19960326.tar.gz
e8bc05c2 95
9712472e 96: $B extract tarballs $D
18b00d7f
TF
97mvp ip-register/old-group-Internet/MAC.addresses.ancient.tar.gz \
98 ip-register/old-group-Internet/MAC.addresses.tar.gz
9712472e
TF
99if [ -e ip-register/archive/archive/migration/done.tar.gz ]
100then
101 owd=$(pwd)
102 cd ip-register/archive/archive/migration
103 tar fx done.tar.gz
104 rm done.tar.gz
105 cd $owd
106fi
3cc4042d 107rm -f ipreg-tarballs/usermap
9712472e
TF
108find ip-register -name '*.tar.gz' |
109while read pathname
110do
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
6611a4e9 121 remove=$1/
9712472e
TF
122 ;;
123 *) mkdir $d
124 cd $d
125 tar xf ../$f
3cc4042d 126 remove=""
9712472e
TF
127 ;;
128 esac
129 cd $owd
130 mkdir -p ipreg-tarballs/$subdir
131 mv $pathname ipreg-tarballs/$subdir
3cc4042d 132 tar tfv ipreg-tarballs/$subdir/$f |
6611a4e9 133 tar2usermap -mipreg-tarballs/usermap "$remove" "$owd/$subdir/$d/"
9712472e 134done
4bfbb137 135: $B case-insensitivity fixup for testing on Mac OS $D
ac8bbb7b
TF
136uclc() {
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}
072baecf 144DNS1996=ip-register/archive/dump/DNS.19960326
ac8bbb7b 145DNS2000=ip-register/archive/dump/DNS.20000303
072baecf
TF
146(
147 cd $DNS1996
ac8bbb7b
TF
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
072baecf 161)
e310d52c 162
10495f31
TF
163: $B fix keyword corruption $D
164# do this before cleaning duplicated history!
165(
166 cd ip-register/nameserver_config
598b2d81 167 mv sbin-named sbin-named.tmp.$$
10495f31 168 sccs get -k sbin-named
598b2d81
TF
169 touch -r sbin-named.tmp.$$ sbin-named
170 rm -f sbin-named.tmp.$$
10495f31
TF
171)
172(
173 cd ip-register/DNS/historic
598b2d81 174 mv makezones makezones.tmp.$$
10495f31 175 sccs get -k makezones
598b2d81
TF
176 touch -r makezones.tmp.$$ makezones
177 rm -f makezones.tmp.$$
10495f31
TF
178)
179
ec9e74d3
TF
180: $B remove duplicated archive files $D
181rm_dup ip-register/archive/archive/DB ip-register/archive/dump/DNS.20000303/SCCS s.DB.cam.20000202.gz
182rm_dup ip-register/archive/archive/DB ip-register/DNS/SCCS s.DB.cam.20020718.gz
183rm_dup ip-register/archive/archive/Hosts ip-register/archive/dump/adm.20000303/SCCS s.hosts.131.111.20000303.gz
184rm_dup ip-register/archive/archive/Hosts ip-register/adm/SCCS s.hosts.131.111.20020910.gz
185rm_dup ip-register/archive/archive/Hosts ip-register/adm/SCCS s.hosts.131.111.20051206.gz
186rm_dup ip-register/archive/archive/Hosts ip-register/adm tombstones.131.111.20020910.gz
4bfbb137
TF
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
190rm -f ip-register/archive/archive/Hosts/s.hosts.131.111.back.950725.gz
cebfef06
TF
191# this file just contains a timestamp so isn't worth preserving
192rm -f ip-register/archive/archive/Hosts/tombstones.131.111.2002.02.05
ec9e74d3 193
8ee4005d
TF
194: $B unzip archived SCCS files $D
195for f in ip-register/archive/archive/DB/*.gz \
196 ip-register/archive/archive/Hosts/*.gz
197do
198 [ -f "$f" ] && gunzip "$f"
199done
200
201: $B unzip text files $D
202for 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
205do [ -e $f ] && gunzip $f
206done
207
7ad4cb14
TF
208: $B remove duplicated SCCS history $D
209for d in 19960326 20000303
210do
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
8ee4005d
TF
220 if [ -f ip-register/archive/dump/DNS.$d/$s ] &&
221 [ -f ip-register/DNS/historic/$s ] &&
7ad4cb14 222 sccsprefix ip-register/archive/dump/DNS.$d/$s \
8ee4005d 223 ip-register/DNS/historic/$s
e0af2ad1 224 then rm -f ip-register/archive/dump/DNS.$d/$s
8ee4005d
TF
225 elif [ -f ip-register/archive/dump/DNS.$d/$s ] &&
226 [ -f ip-register/DNS/$s ] &&
7ad4cb14 227 sccsprefix ip-register/archive/dump/DNS.$d/$s \
8ee4005d 228 ip-register/DNS/$s
e0af2ad1 229 then rm -f ip-register/archive/dump/DNS.$d/$s
7ad4cb14
TF
230 fi
231 done
232done
4992df02 233for d in 19960326 19990226 20000303
7ad4cb14 234do for f in hosts2DB mailarch
8ee4005d
TF
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
7ad4cb14
TF
240 fi
241 done
242done
e5f70be6
TF
243if sccsprefix ip-register/archive/dump/adm.20000303/SCCS/s.Makefile \
244 ip-register/adm/SCCS/s.Makefile
245then rm -f ip-register/archive/dump/adm.20000303/SCCS/s.Makefile
246fi
247if sccsprefix ip-register/archive/dump/adm.19960326/SCCS/s.Makefile \
248 ip-register/adm/SCCS/s.Makefile
249then rm -f ip-register/archive/dump/adm.19960326/SCCS/s.Makefile
250fi
04f0c71d
TF
251if : sccsprefix ip-register/archive/dump/adm.19960326/SCCS/s.hosts.131.111 \
252 ip-register/archive/archive/Hosts/s.hosts.131.111.19961014
253then rm -f ip-register/archive/dump/adm.19960326/SCCS/s.hosts.131.111
10495f31
TF
254fi
255if sccsprefix ip-register/archive/dump/DNS.19960326/SCCS/s.DB.cam \
256 ip-register/archive/archive/DB/s.DB.cam.19961015
257then rm -f ip-register/archive/dump/DNS.19960326/SCCS/s.DB.cam
258fi
e0af2ad1
TF
259if sccsprefix ip-register/archive/dump/DNS.20000303/SCCS/s.DB.cam \
260 ip-register/archive/archive/DB/s.DB.cam.20000713
261then rm -f ip-register/archive/dump/DNS.20000303/SCCS/s.DB.cam
262fi
e5f70be6
TF
263if sccsprefix ip-register/archive/dump/DNS.20000303/SCCS/s.named.conf.zones \
264 ip-register/DNS/SCCS/s.named.conf.shared
265then rm -f ip-register/archive/dump/DNS.20000303/SCCS/s.named.conf.zones
266fi
267if sccsprefix ip-register/archive/dump/DNS.19960326/SCCS/s.named.boot \
268 ip-register/DNS/SCCS/s.named.boot.zones.tomb
269then rm -f ip-register/archive/dump/DNS.19960326/SCCS/s.named.boot
270fi
271if sccsprefix ip-register/archive/dump/DNS.19960326/SCCS/s.db.cache \
272 ip-register/DNS/historic/SCCS/s.db.cache.byhand
273then rm -f ip-register/archive/dump/DNS.19960326/SCCS/s.db.cache
274fi
7ad4cb14 275
afb53571
TF
276: $B correct dates on tombstones $D
277untouch ip-register/archive/archive/Hosts/tombstones.*
278
6164fb8e
TF
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
288for z in apexNS fakezones newzones savezones updates zones
289do
290 rm -f ip-register/DNS/$z/*
291done
292# checkns/.??* <- checkns/checkns.pl
293# delegations/.??* <- deletagezones
294# fakezones/.??* <- fake1zone <- updatezones
295# newzones/.??* <- update1zone <- updatezones
296# updates/.??* <- update1zone <- updatezones
297for z in checkns delegations fakezones newzones updates
298do
299 rm -f ip-register/DNS/$z/.??*
300done
301## name server configuration machinery
302# config_*/* <- Makefile
303for ch in ip-register/DNS/config_*
304do
305 rm -f $ch/*
306done
307rm -f ip-register/DNS/apex_timestamp
308rm -f ip-register/DNS/database_timestamps
309# <- adm/mkslave
310rm -f ip-register/IPreg.*
311# object code
312rm -f ip-register/DNS/lockDNS
81506d7a
TF
313# and its lock file
314rm -f ip-register/DNS/.lock
bf4a7153
TF
315# <- db/ipfilter/cronjob
316rm -f ip-register/db/ipfilter/data/*
6164fb8e 317
b51de266 318: $B PRE-UPLIFT DONE $(date +%Y-%m-%d.%H:%M:%S) $D