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