scripts-github-mirror/cmurl

37 lines
498 B
Bash

#!/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 -