forked from hyphanet/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert-bogus-update
executable file
·121 lines (108 loc) · 3.86 KB
/
insert-bogus-update
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
# Insert a failed update. That is, insert the source, the changelog, but not the binaries and installer, which haven't been built.
if [[ -z $1 ]]; then
echo "insert-bogus-update: Insert the changelog etc for a failed update."
echo "Usage: insert-bogus-update 1234"
exit 1
fi
TAG="build0$1"
VERSION=$1
# Put the real keys in ~/bin/insert-update-keys
SEEDNODESFILE=/usr/src/cvs/eclipse-workspace/FreenetReleased/seednodes.fref
KEYS=`mktemp -d -p /tmp temp.XXXXXXXX`
gpg -o $KEYS/keys ~/bin/insert-update-keys.gpg
source $KEYS/keys || exit
echo Deleting old temporary files
rm -R /usr/src/cvs/freenet-temp*
TEMPLOC=/usr/src/cvs/freenet-temp-$RANDOM
echo Temporary file location: $TEMPLOC
cp -a /usr/src/cvs/eclipse-workspace/fred/ $TEMPLOC
cd $TEMPLOC
git reset --hard
git checkout $TAG
cp /usr/src/cvs/eclipse-workspace/FreenetReleased/freenet-ext.jar lib/freenet-ext.jar || exit
ant clean
cp /usr/src/cvs/eclipse-workspace/FreenetReleased/freenet-${TAG}.jar lib/freenet-cvs-snapshot.jar
# Not inserting the jar.
# Do insert the source code however.
SOURCENAME=/var/lib/freenet-experimental/freenet-cvs-r${VERSION}-src.tar.bz2
if [[ -e /usr/src/cvs/eclipse-workspace/FreenetReleased/freenet-${TAG}-source.tar.bz2 ]];
then
cp /usr/src/cvs/eclipse-workspace/FreenetReleased/freenet-${TAG}-source.tar.bz2 $SOURCENAME
else
echo Source not found. Packaging...
git archive --format=tar HEAD | bzip2 -v9 > "/usr/src/cvs/eclipse-workspace/FreenetReleased/freenet-${TAG}-source.tar.bz2" || exit 11
cp /usr/src/cvs/eclipse-workspace/FreenetReleased/freenet-${TAG}-source.tar.bz2 $SOURCENAME
fi
chown freenete.toad $SOURCENAME
echo Inserting changelog, source and seednodes for build number $VERSION
set -m
# SECURITY: Insert via secondary testing node, NOT VIA MAIN NODE
# This avoids the insert keys ever being known to the main node.
for PORT in 9482; do
TEMPFILE1=`mktemp /tmp/insert.temp.XXXXXXXXXX`
echo Temp file $TEMPFILE1
echo ClientHello > $TEMPFILE1
echo "Name=Toad-update-$VERSION" >> $TEMPFILE1
echo ExpectedVersion=2 >> $TEMPFILE1
echo End >> $TEMPFILE1
echo >> $TEMPFILE1
# Not inserting installers.
for WHAT in source seednodes fullchangelog; do
# Insert the binary LAST so that the node doesn't restart before completing the insert.
PCLASS=2
URI=NEWKEY
IDENT=update-new-$VERSION
if [[ $WHAT == "source" ]]; then
INSERTFILE=$SOURCENAME
PCLASS=$((PCLASS+3))
URI=${URI}/update-source-$VERSION
IDENT=${IDENT}-source
fi
if [[ $WHAT == "seednodes" ]]; then
INSERTFILE=$SEEDNODESFILE
URI=${URI}/seednodes-$VERSION
IDENT=${IDENT}-seednodes
fi
if [[ $WHAT == "fullchangelog" ]]; then
INSERTFILE=/usr/src/cvs/eclipse-workspace/FreenetReleased/changelog.full.${TAG}.txt
URI=${URI}/fullchangelog-$VERSION
IDENT=${IDENT}-fullchangelog
fi
TEMPFILE=`mktemp /tmp/insert.temp.XXXXXXXXXX`
echo ClientPut >> $TEMPFILE
echo "DontCompress=true" >> $TEMPFILE
echo "CompatibilityMode=COMPAT_1250_EXACT" >> $TEMPFILE
echo "URI=$URI" >> $TEMPFILE
echo "Identifier=$IDENT" >> $TEMPFILE
echo Verbosity=1023 >> $TEMPFILE
echo MaxRetries=-1 >> $TEMPFILE
echo UploadFrom=direct >> $TEMPFILE
echo DataLength=`ls -l $INSERTFILE | cut -d " " -f 5` >> $TEMPFILE
# SECURITY: Persistence=reboot so the keys are never written to disk
echo Persistence=reboot >> $TEMPFILE
echo PriorityClass=$PCLASS >> $TEMPFILE
echo Global=true >> $TEMPFILE
echo End >> $TEMPFILE
SCRIPT=$KEYS/script
echo -n "s/NEWKEY/" > $SCRIPT
cat $KEYS/keys | sed -n "s/NEWKEY=\"\(.*\)\"/\1/p" >> $SCRIPT
cat $SCRIPT | tr --delete "\n" > ${SCRIPT}.1 && mv ${SCRIPT}.1 $SCRIPT
echo "/" >> $SCRIPT
cat $TEMPFILE | sed -f $SCRIPT > $TEMPFILE.1
mv $TEMPFILE.1 $TEMPFILE
cat $TEMPFILE >> $TEMPFILE1
cat $INSERTFILE >> $TEMPFILE1
rm $TEMPFILE
done
SCRIPT=$KEYS/script
#cat $TEMPFILE1 | nc 127.0.0.1 $PORT | sed "/^URI=/d" &
cat $TEMPFILE1 | nc 127.0.0.1 $PORT | sed "/^URI=/d"
done
rm -Rf $KEYS
rm -Rf $TEMPFILE1
#jobs
#wait %1
#wait %2
#wait %3
#wait %4