czf4bfu |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/bin/sh
#
# skript na synchronizaci CZF4BFU serveru
# by Unreal][
# verze 1.9
#
### DATADIR - adresar kam se maj ukladat soubory se zdroji (nejcasteji '/var/www/czf4bfu')
DATADIR='/var/www/www.kobylisy.czf/czf4bfu'
### MYIP - ip adresa nebo DNS zaznam serveru
MYIP='czf4bfu.kobylisy.czf'
### LIST - server s aktualnim seznamem rozcestniku
LIST='http://www.jklir.net/servers.list'
###########################################################################################
cd $DATADIR
# stahneme si aktualni servers.list
if wget -T 3 -t 3 -N $LIST
then
echo "*** podarilo se ziskat servers.list z $LIST ***"
else
echo "*** servers.list z $LIST nelze stahnout, pracuju se starym seznamem... ***"
fi
for IP in `cat servers.list`
do
if [ $IP != $MYIP ]; then
if wget -T 3 -t 3 -N -U CZF4BFU http://$IP/czf4bfu/global-$IP.txt
then
echo "*** podarilo se ziskat global-$IP.txt z $IP ***"
else
if wget -T 2 -t 2 -N -U CZF4BFU http://$IP/global-$IP.txt
then
echo "*** podarilo se ziskat global-$IP.txt z $IP ***"
else
echo "*** zkousim jine servery na global-$IP.txt... *** "
PRESKOC=0
for SERVER in `cat servers.list`
do
if [ $SERVER != $MYIP ] && [ $PRESKOC -lt 1 ]; then
if wget -T 3 -t 3 -N -U CZF4BFU http://$SERVER/czf4bfu/global-$IP.txt
then
echo "***** podarilo se ziskat global-$IP.txt z $SERVER *****"
PRESKOC=1
fi
fi
done
fi
fi
fi
done
### zkontrolujeme, jestli neni nejaky global navic
GLOBALS=`ls global-*.txt | sed 's/^global-//' | sed 's/\.txt$//'`
for TMPSVR in $GLOBALS
do
OBSAHUJE=$(cat servers.list | grep $TMPSVR | wc -l)
if [ $OBSAHUJE != "0" ]
then
echo "*** $TMPSVR OK ***"
else
if [ $TMPSVR != $MYIP ]; then
mv ./global-$TMPSVR.txt ./global-$TMPSVR.txt.bckp
echo "*** $TMPSVR NEnalezen v servers.list a byl zalohovan ***"
fi
fi
done
### mrkneme se po externich ikonkach
OLD_IFS=$IFS; IFS=$'\n'
GLOBALS=`ls global-*.txt | sed 's/^global-//' | sed 's/\.txt$//'`
for TMPSVR in $GLOBALS
do
for ICONS in `grep 'ICON:' global-$TMPSVR.txt`; do
ICONURL=`echo "$ICONS" | sed -n "s/^ICON: \([[:space:]]+\)\?\([^[:space:]#].*\)/\2/p"`
ICONNAME=`echo "$ICONURL" | sed -n "s/^\(.*\)\/\([^[\/].*\)$/\2/p"`
if [ "$ICONNAME" != "" ] && [ ! -f "$DATADIR"/"$TMPSVR"_"$ICONNAME" ]; then
if wget -T 3 -t 3 -N -U CZF4BFU $ICONURL
then
mv $ICONNAME $DATADIR/cache/"$TMPSVR"_"$ICONNAME"
echo "***** podarilo se stahnout ikonku $ICONNAME ze serveru $TMPSVR *****"
else
PRESKOC=0
for SERVER in `cat servers.list`
do
if [ $SERVER != $MYIP ] && [ $PRESKOC -lt 1 ]; then
if wget -T 3 -t 3 -N -U CZF4BFU http://$SERVER/czf4bfu/cache/"$TMPSVR"_"$ICONNAME"
then
mv "$TMPSVR"_"$ICONNAME" $DATADIR/cache/"$TMPSVR"_"$ICONNAME"
echo "***** podarilo se stahnout ikonku $ICONNAME ze serveru $SERVER *****"
PRESKOC=1
else
if wget -T 2 -t 2 -N -U CZF4BFU http://$SERVER/cache/"$TMPSVR"_"$ICONNAME"
then
mv "$TMPSVR"_"$ICONNAME" $DATADIR/cache/"$TMPSVR"_"$ICONNAME"
echo "***** podarilo se stahnout ikonku $ICONNAME ze serveru $SERVER *****"
PRESKOC=1
fi
fi
fi
done
fi
fi
done
done
IFS=$OLD_IFS