Last active
March 21, 2020 11:55
-
-
Save chihchun/d458c7a48cad67a9bb42faefbb09cb45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# set -x | |
if [ -z $1 ] ; then | |
echo "Usage: $0 url_of_zsync" | |
exit -1 | |
fi | |
cd $(dirname $0) | |
# Find the folder. | |
DIR=$(dirname $1 | cut -b 8-) | |
# Find the reference ISO image. | |
ISO=$(find $(dirname ${DIR}) -type f -exec stat -c '%Y %n' {} \; | sort -nr | awk 'NR==1 {print $2}') | |
BASENAME=$(basename $1 .zsync) | |
mkdir -p ${DIR} | |
if [ -f ${DIR}/${BASENAME} ] ; then | |
echo "${DIR}/${BASENAME} exist" | |
exit -1 | |
fi | |
if [ -z ${ISO} ] ; then | |
zsync $1 -o ${DIR}/${BASENAME} | |
else | |
zsync $1 -i ${ISO} -o ${DIR}/${BASENAME} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment