czf4bfu |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/bin/sh
#
# skript na synchronizaci CZF4BFU serveru
# by Unreal][
# verze 1.6
#
### 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 (bez http://) ... /servers.list
LIST='www.jklir.net'
###########################################################################################
cd $DATADIR
# stahneme si aktualni servers.list
if wget -T 3 -t 3 -N http://$LIST/servers.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
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
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" != "" ]; then
if wget -T 3 -t 3 -N -U CZF4BFU $ICONURL -O $DATADIR/cache/"$TMPSVR"_"$ICONNAME"
then
echo "***** podarilo se stahnout ikonku $ICONNAME ze serveru $TMPSVR *****"
else
PRESKOC=0
for SERVER in `cat servers.list`
do
if [ $PRESKOC -lt 1 ]; then
if wget -T 3 -t 3 -N -U CZF4BFU http://$SERVER/czf4bfu/cache/"$SERVER"_"$ICONNAME" -O $DATADIR/cache/"$SERVER"_"$ICONNAME"
then
echo "***** podarilo se stahnout ikonku $ICONNAME ze serveru $SERVER *****"
PRESKOC=1
fi
fi
done
fi
fi
done
done
IFS=$OLD_IFS