Hi,
I want to build a little script which performs to get a mirror lists from two servers and compares it with original one on my box.
my question is, how to know if wget was failed to get the mirror lists ( no internet connection, servers was down, etc ) . I had try to put return codes but to no avail. here is my script:
Code:
#!/bin/bash
ROOT_DIR=$(pwd)
PHAILED=666
check() {
bash md5check
}
belek () {
if [ $? -ne 0 ]; then
echo "return exit, DONE!"
exit
else
echo "return exit, FAILED!"
exit
fi
}
[ ! -d "dl" ] && mkdir -p dl
cd dl
wget -q --ftp-user=myuser --ftp-password=mypasswd -c -i ../mirror.lst
belek
cd $ROOT_DIR
if [ -f "./dl/update.txt" ]; then
while read f; do
MD5=
FILE=
MD5=$(echo $f |cut -d ' ' -f 1)
FILE=$(echo $f |cut -d ' ' -f 2)
NM=
if [ -f "dl/$FILE" ]; then
echo "OK"
NM=$(md5sum ./dl/$FILE)
fi
echo "==> $FILE $NM"
done < ./dl/update.txt
else
exit $PHAILED
fi
if [ -f "./dl/mirror.lst" ]; then
mv mirror.lst mirror.lst.old
cp -v ./dl/mirror.lst mirror.lst
else
exit $PHAILED
fi
check
exit 0
can anyone tell me what is wrong with my script?
Bookmarks