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