Create cmurl

Example: cmurl http://download.cyanogenmod.org hammerhead.zip /var/iso
This commit is contained in:
tianyu 2015-01-23 19:22:13 +08:00
parent 14d74e0ffc
commit 0f52b7ee79
1 changed files with 36 additions and 0 deletions

36
cmurl Normal file
View File

@ -0,0 +1,36 @@
#!/bin/bash
URL=$1
TARGET=$2
DIRECTORY=$3
URL=$(curl -k -s $URL |grep $TARGET |grep -v html| sed -n "s|.*href=\"\([^\"]*\).*|$URL\1|p")
if [ -z "$URL" ];then
echo "ERROR"
exit 0
fi
echo $URL
ZIP="${URL##*/}"
echo $ZIP
if [ -f "$DIRECTORY/$ZIP" ];then
echo "DOWNLOADED"
exit 0
fi
if [ ! -d "$DIRECTORY" ];then
echo "ERROR DIR"
exit 0
fi
cd $DIRECTORY
wget $URL > $ZIP.wget.log 2>&1
md5sum $ZIP > $ZIP.md5
alias bypy='/root/bypy/bypy.py'
bypy -v -s 10MB syncup
cd -