forked from imapsync/imapsync
-
Notifications
You must be signed in to change notification settings - Fork 2
/
memo
405 lines (338 loc) · 13.3 KB
/
memo
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
#!/bin/sh
# $Id: memo,v 1.41 2012/02/04 23:55:37 gilles Exp gilles $
software_version() {
VERSION=`cat VERSION`
}
statistics_lfo() {
# 62.147.165.21 - - [31/Oct/2010:23:45:28 +0100] "GET /prj/imapsync/VERSION HTTP/1.0" 200 6 "-" "imapsync/1.368 (linux system, perl 5.8.8, Mail::IMAPClient 2.2.9 imapsync)"
#grep prj/imapsync/VERSION /usr/local/apache/logs/access_log | sort -n | cut -d ' ' -f 1,12,13|uniq -c | sort -n # list ip
cat <<EOFF
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n" # list ip
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n |grep MSWin32" # Win32
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 13,18,19 |sort -n|uniq -c| sort -n" # OS usage+basename
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 12 |sort -n|uniq -c| sort -n" # imapsync release
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n|wc -l" # count ip
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|wc -l" # imapsync runs
tail -f /usr/local/apache/logs/access_log|cat -n|grep prj/imapsync/VERSION|cat -n |grep VERSION # lfo frequency
EOFF
}
statistics_lfo_run() {
# 62.147.165.21 - - [31/Oct/2010:23:45:28 +0100] "GET /prj/imapsync/VERSION HTTP/1.0" 200 6 "-" "imapsync/1.368 (linux system, perl 5.8.8, Mail::IMAPClient 2.2.9 imapsync)"
#grep prj/imapsync/VERSION /usr/local/apache/logs/access_log | sort -n | cut -d ' ' -f 1,12,13|uniq -c | sort -n # list ip
echo lfo list ip
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n" # list ip
echo lfo Win32
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n |grep MSWin32" # Win32
echo lfo OS usage+basename
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 13,18,19 |sort -n|uniq -c| sort -n" # OS usage+basename
echo lfo imapsync release
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 12 |sort -n|uniq -c| sort -n" # imapsync release
echo -n "lfo count ip: "
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n|wc -l" # count ip
echo -n "lfo imapsync runs: "
ssh [email protected] "grep -h prj/imapsync/VERSION /usr/local/apache/logs/access_log.bak|wc -l" # imapsync runs
date
}
statistics_ks() {
cat <<EOFF
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n" # list ip
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n |grep MSWin32" # Win32
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 13,18,19 |sort -n|uniq -c| sort -n" # OS usage+basename
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 12 |sort -n|uniq -c| sort -n" # imapsync release
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n|wc -l" # count ip
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|wc -l" # imapsync runs
tail -f /var/log/apache2/access.log |cat -n|grep prj/imapsync/VERSION|cat -n |grep VERSION # ks frequency
EOFF
}
statistics_ks_run() {
echo ks list ip
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n" # list ip
echo ks Win32
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n |grep MSWin32" # Win32
echo OS usage+basename
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 13,18,19 |sort -n|uniq -c| sort -n" # OS usage+basename
echo ks imapsync release
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 12 |sort -n|uniq -c| sort -n" # imapsync release
echo -n "ks count ip: "
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|cut -d ' ' -f 1,12,13,18,19|sort -n|uniq -c|sort -n|wc -l" # count ip
echo -n "ks imapsync runs: "
ssh root@ks "cd /var/log/apache2/;grep -h prj/imapsync/VERSION access.log_????????|wc -l" # imapsync runs
date
}
statistics_VERSION_lfo() {
TMPDIR=.
export TMPDIR
echo statistics_VERSION_getstats
statistics_VERSION_getstats() {
for f in /home/lf/backuplog/linux-france.org.??-??-201[123456789].bz2; do
b=`basename "$f" .bz2`
#echo "$b"
test -f ${b}.imapsync_VERSION && continue
echo NOT DONE ${b}.imapsync_VERSION
bzip2 -dc "$f" | grep -h /prj/imapsync/VERSION > ${b}.imapsync_VERSION
done
}
echo statistics_VERSION_monthly_ip 02 2012
statistics_VERSION_monthly_ip() {
month=${1:-`date '+%m'`}
year=${2:-`date '+%Y'`}
cut -d ' ' -f 1,12,13,18,19 linux-france.org.??-${month}-${year}.imapsync_VERSION |sort -n |uniq -c|sort -n > stats_imapsync_${year}_${month}.ip
}
echo statistics_VERSION_monthly_ip_wc 02 2012
statistics_VERSION_monthly_ip_wc() {
month=${1:-`date '+%m'`}
year=${2:-`date '+%Y'`}
test -f stats_imapsync_${year}_${month}.ip || statistics_VERSION_monthly_ip $month ${year}
wc -l stats_imapsync_${year}_${month}.ip
}
echo statistics_VERSION_monthly_runs 02 2012
statistics_VERSION_monthly_runs() {
month=${1:-`date '+%m'`}
year=${2:-`date '+%Y'`}
test -f stats_imapsync_${year}_${month}.runs || wc -l linux-france.org.??-${month}-${year}.imapsync_VERSION > stats_imapsync_${year}_${month}.runs
cat stats_imapsync_${year}_${month}.runs
}
echo statistics_VERSION_monthly 02 2012
statistics_VERSION_monthly() {
month=${1:-`date '+%m'`}
year=${2:-`date '+%Y'`}
(
statistics_VERSION_getstats
statistics_VERSION_monthly_ip $month $year
statistics_VERSION_monthly_runs $month $year
statistics_VERSION_monthly_ip_wc $month $year
)
}
echo statistics_VERSION_yearly_ip 2012
statistics_VERSION_yearly_ip() {
year=${1:-`date '+%Y'`}
(
cd /home/lf/glamiral/imapsync_stats
cut -d ' ' -f 1,12,13,18,19 linux-france.org.??-??-${year}.imapsync_VERSION |sort -n |uniq -c|sort -n > stats_imapsync_${year}.ip
)
}
echo statistics_VERSION_yearly_os 2012
statistics_VERSION_yearly_os() {
year=${1:-`date '+%Y'`}
(
cd /home/lf/glamiral/imapsync_stats
Linux=`grep linux stats_imapsync_${year}.ip | wc -l`
Win32=`grep MSWin32 stats_imapsync_${year}.ip | wc -l`
Darwin=`grep darwin stats_imapsync_${year}.ip | wc -l`
FreeBSD=`grep freebsd stats_imapsync_${year}.ip | wc -l`
Solaris=`grep solaris stats_imapsync_${year}.ip | wc -l`
OpenBSD=`grep openbsd stats_imapsync_${year}.ip | wc -l`
Nb_All=`cat stats_imapsync_${year}.ip | wc -l`
for OS in Linux Win32 Darwin FreeBSD Solaris OpenBSD; do
#echo $OS `eval "echo \\$$OS"` / $Nb_All
Nb_OS=`eval "echo \\$$OS"`
PerCent=`echo "scale=2; 100*$Nb_OS/$Nb_All" | bc -l`
echo $OS $PerCent %
done
)
}
echo statistics_VERSION_synthesis 2012
statistics_VERSION_synthesis() {
year=${1:-`date '+%Y'`}
(
cd /home/lf/glamiral/imapsync_stats
echo Nb users each month
wc -l stats_imapsync_${year}_??.ip
echo Nb users each year
wc -l stats_imapsync_????.ip
echo Nb runs each month
tail -n 1 stats_imapsync_${year}_??.runs
echo % Operating systems
statistics_VERSION_yearly_os $year
echo Biggest users
tail -n 5 stats_imapsync_${year}.ip
)
}
}
statistics_VERSION_ks() {
TMPDIR=.
export TMPDIR
echo statistics_VERSION_getstats
statistics_VERSION_getstats() {
(
cd /home/imapsync/imapsync_stats
for f in /var/log/apache2/access.log_????????.gz ; do
b=`basename "$f" .gz`
#echo "$b"
test -f ${b}.imapsync_VERSION && continue
echo NOT DONE ${b}.imapsync_VERSION
zgrep -h /prj/imapsync/VERSION "$f" > ${b}.imapsync_VERSION
done
)
}
echo statistics_VERSION_monthly_ip 08
statistics_VERSION_monthly_ip() {
month=${1:-`date '+%m'`}
year=${2:-`date '+%Y'`}
(
cd /home/imapsync/imapsync_stats
cut -d ' ' -f 1,12,13,18,19 access.log_${year}${month}??.imapsync_VERSION |sort -n |uniq -c|sort -n > stats_imapsync_${year}_${month}.ip
)
}
echo statistics_VERSION_monthly_os 08
statistics_VERSION_monthly_os() {
month=${1:-`date '+%m'`}
year=${2:-`date '+%Y'`}
(
cd /home/imapsync/imapsync_stats
Linux=`grep linux stats_imapsync_${year}_${month}.ip | wc -l`
Win32=`grep MSWin32 stats_imapsync_${year}_${month}.ip | wc -l`
Darwin=`grep darwin stats_imapsync_${year}_${month}.ip | wc -l`
FreeBSD=`grep freebsd stats_imapsync_${year}_${month}.ip | wc -l`
Solaris=`grep solaris stats_imapsync_${year}_${month}.ip | wc -l`
OpenBSD=`grep openbsd stats_imapsync_${year}_${month}.ip | wc -l`
Nb_All=`cat stats_imapsync_${year}_${month}.ip | wc -l `
for OS in Linux Win32 Darwin FreeBSD Solaris OpenBSD; do
#echo $OS `eval "echo \\$$OS"` / $Nb_All
Nb_OS=`eval "echo \\$$OS"`
PerCent=`echo "scale=2; 100*$Nb_OS/$Nb_All" | bc -l`
echo $OS $PerCent%
done
)
}
echo statistics_VERSION_yearly_os
statistics_VERSION_yearly_os() {
year=${1:-`date '+%Y'`}
(
cd /home/imapsync/imapsync_stats
Linux=`grep linux stats_imapsync_${year}.ip | wc -l`
Win32=`grep MSWin32 stats_imapsync_${year}.ip | wc -l`
Darwin=`grep darwin stats_imapsync_${year}.ip | wc -l`
FreeBSD=`grep freebsd stats_imapsync_${year}.ip | wc -l`
Solaris=`grep solaris stats_imapsync_${year}.ip | wc -l`
OpenBSD=`grep openbsd stats_imapsync_${year}.ip | wc -l`
Nb_All=`cat stats_imapsync_${year}.ip | wc -l`
for OS in Linux Win32 Darwin FreeBSD Solaris OpenBSD; do
#echo $OS `eval "echo \\$$OS"` / $Nb_All
Nb_OS=`eval "echo \\$$OS"`
PerCent=`echo "scale=2; 100*$Nb_OS/$Nb_All" | bc -l`
echo $OS $PerCent %
done
)
}
echo statistics_VERSION_yearly_ip
statistics_VERSION_yearly_ip() {
year=${1:-`date '+%Y'`}
(
cd /home/imapsync/imapsync_stats
cut -d ' ' -f 1,12,13,18,19 access.log_${year}????.imapsync_VERSION |sort -n |uniq -c|sort -n > stats_imapsync_${year}.ip
)
}
echo statistics_VERSION_monthly_ip_wc 01 2012
statistics_VERSION_monthly_ip_wc() {
month=${1:-`date '+%m'`}
year=${2:-`date '+%Y'`}
(
cd /home/imapsync/imapsync_stats
test -f stats_imapsync_${year}_${month}.ip || statistics_VERSION_monthly_ip $month ${year}
wc -l stats_imapsync_${year}_${month}.ip
)
}
echo statistics_VERSION_monthly_runs 01 2012
statistics_VERSION_monthly_runs() {
month=${1:-`date '+%m'`}
year=${2:-`date '+%Y'`}
(
cd /home/imapsync/imapsync_stats
wc -l access.log_${year}${month}??.imapsync_VERSION > stats_imapsync_${year}_${month}.runs
cat stats_imapsync_${year}_${month}.runs
)
}
echo statistics_VERSION_monthly 01 2012
statistics_VERSION_monthly() {
month=${1:-`date '+%m'`}
year=${2:-`date '+%Y'`}
(
statistics_VERSION_getstats
statistics_VERSION_monthly_ip $month $year
statistics_VERSION_monthly_runs $month $year
statistics_VERSION_monthly_ip_wc $month $year
)
}
echo statistics_VERSION_synthesis 2012
statistics_VERSION_synthesis() {
year=${1:-`date '+%Y'`}
(
cd /home/imapsync/imapsync_stats
echo Nb users each month
wc -l stats_imapsync_${year}_??.ip
echo Nb users each year
wc -l stats_imapsync_????.ip
echo Nb runs each month
tail -n 1 stats_imapsync_${year}_??.runs
echo % Operating systems
statistics_VERSION_yearly_os $year
echo Biggest users
tail -n 5 stats_imapsync_${year}.ip
)
}
}
niouzes_compil() {
(
cd /g/public_html/www.linux-france.org/html/
m4 niouzes.m4 > niouzes.xml
python ./niouzes/getmynews.py --neuf niouzes.xml > niouzes-neuf.html
python ./niouzes/getmynews.py --html niouzes.xml > niouzes-html.html
)
}
lfo_announce() {
software_version
NEWS_FILE="/g/public_html/www.linux-france.org/html/niouzes/niouzes_imapsync.xml"
if ! newer VERSION $NEWS_FILE; then
echo "$VERSION already announced"
else
cat > $NEWS_FILE << EOF
<news date="`date '+%Y%m%d'`">
`LANG=fr_FR date '+%A %d %B %Y'` : Synchronisez ou migrez vos boites
aux lettres avec économie et l'outil <A
HREF="prj/imapsync/">imapsync $VERSION</A> (Gilles LAMIRAL)
</news>
EOF
fi
niouzes_compil
}
#' nedit sucks with syntax color
fm_init() {
software_version
NEWS_FILE_FM="./freshmeat_submition"
NEWS_FILE_FM_INP=${NEWS_FILE_FM}.inp
NEWS_FILE_FM_OUT=${NEWS_FILE_FM}.json
}
fm_read_param() {
# read definitions
. $NEWS_FILE_FM_INP
}
fm_read_announce() {
fm_init
fm_read_param
cat << EOF
{
"release": {
"tag_list": "stable, $RELEASE_FOCUS",
"version": "$VERSION",
"hidden_from_frontpage": false,
"changelog": "$TEXT_BODY"
}
}
EOF
}
fm_announce() {
fm_init
if ! newer VERSION $NEWS_FILE_FM_OUT; then
echo "$VERSION already submitted on freshmeat"
else
if newer VERSION $NEWS_FILE_FM_INP; then
echo "Update $NEWS_FILE_FM_INP please"
return 1
fi
fm_read_announce > $NEWS_FILE_FM_OUT
curl -X PUT -d @../../var/pass/secret.freshmeat -d @$NEWS_FILE_FM_OUT \
-H "Content-Type: application/json" \
http://freshmeat.net/projects/imapsync.json
fi
}