#!/bin/bash PROGRAM="$(basename $0)" logit(){ ak-logthis "<$PROGRAM>" "$1" "$2" } if [ ! -z "$1" ] then if [ -f "$AK_ZBLOCKDIR/$1" ] && [ "$(du -b $AK_ZBLOCKDIR | awk '{ print $1 }')" != "0" ] then if [ "$(sha512sum $AK_ZBLOCKDIR/$1 | awk '{ print $1 }')" == "$(ak-zblock-show $1 | sha512sum | awk '{ print $1 }')" ] then logit "[INFO]" "Cache already there and updated" else logit "[INFO]" "Updating cache" ak-zblock-show "$1" > $AK_CACHEDIR/fzblocks/$1 fi logit "[INFO]" "No cache found. Caching..." ak-zblock-show "$1" if [ "$?" -ne "0" ] then logit "[ERROR]" "ak-zblock-show failed..." exit 2 fi ak-zblock-show "$1" > $AK_CACHEDIR/fzblocks/$1 else ak-zblock-show "$1" > $AK_CACHEDIR/fzblocks/$1 if [ "$?" -ne "0" ] then logit "[ERROR]" "ak-zblock-show failed..." exit 2 fi logit "[ERROR]" "Could not find zblock $1..." exit 1 fi exit 0 else printf "Usage:\n\t%s \n" "$PROGRAM" 1>&2 exit 1 fi