aboutsummaryrefslogtreecommitdiff
path: root/bin/ak-zblock-cache
blob: 6d11cde9af1a7fd5ac84f81463c1966eb71d0445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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_ZBLOCKDIR/$1
        fi
        logit "[INFO]" "No cache found. Caching..."
        ak-zblock-show "$1" > $AK_ZBLOCKDIR/$1
    fi
    exit 0
else
    echo not ok
    exit 1
fi