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 |
64 | 16 | unreal | |
65 | | | ### mrkneme se po externich ikonkach |
66 | | | |
67 | | | OLD_IFS=$IFS; IFS=$'\n' |
68 | | | GLOBALS=`ls global-*.txt | sed 's/^global-//' | sed 's/\.txt$//'` |
69 | | | for TMPSVR in $GLOBALS |
70 | | | do |
71 | | | for ICONS in `grep 'ICON:' global-$TMPSVR.txt`; do |
72 | | | ICONURL=`echo "$ICONS" | sed -n "s/^ICON: \([[:space:]]+\)\?\([^[:space:]#].*\)/\2/p"` |
73 | | | ICONNAME=`echo "$ICONURL" | sed -n "s/^\(.*\)\/\([^[\/].*\)$/\2/p"` |
74 | | | if [ "$ICONNAME" != "" ]; then |
75 | | | if wget -T 3 -t 3 -N -U CZF4BFU $ICONURL -O $DATADIR/cache/"$TMPSVR"_"$ICONNAME" |
76 | | | then |
77 | | | echo "***** podarilo se stahnout ikonku $ICONNAME ze serveru $TMPSVR *****" |
78 | | | else |
79 | | | PRESKOC=0 |
80 | | | for SERVER in `cat servers.list` |
81 | | | do |
82 | | | if [ $PRESKOC -lt 1 ]; then |
83 | | | if wget -T 3 -t 3 -N -U CZF4BFU http://$SERVER/czf4bfu/cache/"$SERVER"_"$ICONNAME" -O $DATADIR/cache/"$SERVER"_"$ICONNAME" |
84 | | | then |
85 | | | echo "***** podarilo se stahnout ikonku $ICONNAME ze serveru $SERVER *****" |
86 | | | PRESKOC=1 |
87 | | | fi |
88 | | | fi |
89 | | | done |
90 | | | fi |
91 | | | fi |
92 | | | done |
93 | | | done |
94 | | | IFS=$OLD_IFS |