#!/bin/sh set -e cache_dir='/var/cache/buff-di-wuff' mkdir -p "${cache_dir}" grep '^[^#]' '/etc/buff-di-wuff.list' | \ while read -r url; do if ! wget -O "${cache_dir}/tmp" "${url}" 2> /dev/null; then continue fi sum512="$( sha512sum "${cache_dir}/tmp" | \ cut -d' ' -f1 )" sum256="$( sha256sum "${cache_dir}/tmp" | \ cut -d' ' -f1 )" if [ ! -f "${cache_dir}/${sum512}" ]; then mv "${cache_dir}/tmp" "${cache_dir}/${sum512}" else rm "${cache_dir}/tmp" fi if [ ! -f "${cache_dir}/${sum256}" ]; then ln "${cache_dir}/${sum512}" "${cache_dir}/${sum256}" fi done