1 | 1 | simandl | #!/bin/sh |
2 | | | # |
3 | | | # skript na synchronizaci CZF4BFU serveru |
4 | 4 | simandl | # verze 1.3 |
5 | 1 | simandl | # |
6 | | | # adresar kam se maj ukladat soubory se zdroji (nejcastejc '/var/www/czf4bfu') |
7 | 4 | simandl | DATADIR='/var/www/www.kobylisy.czf/czf4bfu' |
8 | 1 | simandl | # ip adresa serveru |
9 | 4 | simandl | MYIP='czf4bfu.kobylisy.czf' |
10 | 1 | simandl | # server s aktualnim seznamem rozcestniku |
11 | | | LIST='www.jklir.net' |
12 | | | # |
13 | | | cd $DATADIR |
14 | | | # stahneme si aktualni servers.list |
15 | | | if wget -T 3 -t 3 -N servers.list http://$LIST/servers.list |
16 | | | then |
17 | | | echo "*** podarilo se ziskat servers.list z $LIST ***" |
18 | | | else |
19 | | | echo "*** servers.list z $LIST nelze stahnout, pracuju se starym seznamem... ***" |
20 | | | fi |
21 | | | for IP in `cat servers.list` |
22 | | | do |
23 | | | if [ $IP != $MYIP ]; |
24 | | | then |
25 | 4 | simandl | if wget -T 3 -t 3 -N --user-agent='CZF4BFU' http://$IP/czf4bfu/global-$IP.txt |
26 | 1 | simandl | then |
27 | | | echo "*** podarilo se ziskat global-$IP.txt z $IP ***" |
28 | | | else |
29 | | | echo "*** zkousim jine servery na global-$IP.txt... *** " |
30 | | | PRESKOC=0 |
31 | | | for SERVER in `cat servers.list` |
32 | | | do |
33 | | | if [ $SERVER != $MYIP ]; |
34 | | | then |
35 | | | if [ $PRESKOC -lt 1 ]; |
36 | | | then |
37 | 4 | simandl | if wget -T 3 -t 3 -N --user-agent='CZF4BFU' http://$SERVER/czf4bfu/global-$IP.txt |
38 | 1 | simandl | then |
39 | | | echo "*** podarilo se ziskat global-$IP.txt z $SERVER ***" |
40 | | | PRESKOC=1 |
41 | | | fi |
42 | | | fi |
43 | | | fi |
44 | | | done |
45 | | | fi |
46 | | | fi |
47 | | | done |
48 | 4 | simandl | |
49 | | | # |
50 | | | # zkontrolujeme, jestli neni nejaky global navic |
51 | | | # |
52 | | | ls global-*.txt | sed 's/^global-//' | sed 's/\.txt$//' > temp.list |
53 | | | for TMPSVR in `cat temp.list` |
54 | | | do |
55 | | | OBSAHUJE=$(cat servers.list | grep $TMPSVR | wc -l) |
56 | | | if [ $OBSAHUJE != "0" ] |
57 | | | then |
58 | | | echo "*** $TMPSVR ok ***" |
59 | | | else |
60 | | | if [ $TMPSVR != $MYIP ] |
61 | | | then |
62 | | | echo "*** $TMPSVR NEnalezen v servers.list a smazan ***" |
63 | | | rm ./global-$TMPSVR.txt |
64 | | | fi |
65 | | | fi |
66 | | | done |
67 | | | rm ./temp.list |