mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-20 12:24:12 +00:00
docker-ce: improve error handling
This commit is contained in:
parent
9a938f8d83
commit
18849d10cd
19
docker-ce.sh
19
docker-ce.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# requires: wget, lftp, jq, python3.5, lxml, pyquery
|
# requires: lftp, jq, python3.5, lxml, pyquery
|
||||||
# set -x
|
# set -x
|
||||||
set -e
|
set -e
|
||||||
set -u
|
set -u
|
||||||
@ -17,8 +17,8 @@ LOCAL_FILELIST="${TUNASYNC_WORKING_DIR}/.filelist.local"
|
|||||||
|
|
||||||
function cleanup () {
|
function cleanup () {
|
||||||
echo "cleaning up"
|
echo "cleaning up"
|
||||||
[[ -f $REMOTE_FILELIST ]] && rm $REMOTE_FILELIST
|
[[ -f $REMOTE_FILELIST ]] && rm $REMOTE_FILELIST || true
|
||||||
[[ -f $LOCAL_FILELIST ]] && rm $LOCAL_FILELIST
|
[[ -f $LOCAL_FILELIST ]] && rm $LOCAL_FILELIST || true
|
||||||
}
|
}
|
||||||
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
@ -32,10 +32,10 @@ while read remote_url; do
|
|||||||
echo "${dst_rel_file}" >> $REMOTE_FILELIST
|
echo "${dst_rel_file}" >> $REMOTE_FILELIST
|
||||||
|
|
||||||
if [[ -f ${dst_file} ]]; then
|
if [[ -f ${dst_file} ]]; then
|
||||||
remote_meta=`curl -sI ${remote_url}`
|
remote_meta=`curl -sI "${remote_url}"`
|
||||||
remote_filesize=`echo -e "$remote_meta" | grep -i '^content-length:' | awk '{print $2}' | tr -d '\n\r'`
|
remote_filesize=`echo -e "$remote_meta" | grep -i '^content-length:' | awk '{print $2}' | tr -d '\n\r' || echo 0`
|
||||||
remote_date=`echo -e "$remote_meta" | grep -i '^last-modified:' | sed 's/^last-modified: //I' | tr -d '\n\r'`
|
remote_date=`echo -e "$remote_meta" | grep -i '^last-modified:' | sed 's/^last-modified: //I' | tr -d '\n\r' || echo 0`
|
||||||
remote_date=`date --date="$remote_date" +%s`
|
remote_date=`date --date="${remote_date}" +%s`
|
||||||
|
|
||||||
local_filesize=`stat -c "%s" ${dst_file}`
|
local_filesize=`stat -c "%s" ${dst_file}`
|
||||||
local_date=`stat -c "%Y" ${dst_file}`
|
local_date=`stat -c "%Y" ${dst_file}`
|
||||||
@ -50,7 +50,10 @@ while read remote_url; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "downloading ${remote_url}"
|
echo "downloading ${remote_url}"
|
||||||
(cd ${dst_dir} && wget -N -q ${remote_url} || rm ${dst_file})
|
curl -o ${dst_file} -s -L --remote-time --show-error --fail ${remote_url} || {
|
||||||
|
echo "Failed: ${remote_url}"
|
||||||
|
[[ -f ${dst_file} ]] && rm ${dst_file}
|
||||||
|
}
|
||||||
done < <($GET_FILELIST $BASE_URL)
|
done < <($GET_FILELIST $BASE_URL)
|
||||||
|
|
||||||
# remove old files
|
# remove old files
|
||||||
|
Loading…
x
Reference in New Issue
Block a user