xref: /unit/auto/modules/java_chk_sha512 (revision 1340)
1*1340Smax.romanov@nginx.com
2*1340Smax.romanov@nginx.com# Copyright (C) NGINX, Inc.
3*1340Smax.romanov@nginx.com
4*1340Smax.romanov@nginx.com# NXT_JAR_FILE=
5*1340Smax.romanov@nginx.com# NXT_JAR_CHK_FILE=
6*1340Smax.romanov@nginx.com
7*1340Smax.romanov@nginx.comNXT_SHA512_TOOL=${NXT_SHA512_TOOL=}
8*1340Smax.romanov@nginx.com
9*1340Smax.romanov@nginx.comif [ -z "$NXT_SHA512_TOOL" ]; then
10*1340Smax.romanov@nginx.com    $echo -n "looking for sha512 check tool ..."
11*1340Smax.romanov@nginx.com    $echo "looking for sha512 check tool ..." >> $NXT_AUTOCONF_ERR
12*1340Smax.romanov@nginx.com
13*1340Smax.romanov@nginx.com    if sha512sum --version >/dev/null 2>&1; then
14*1340Smax.romanov@nginx.com        NXT_SHA512_TOOL="sha512sum --check"
15*1340Smax.romanov@nginx.com    else
16*1340Smax.romanov@nginx.com        if shasum --version >/dev/null 2>&1; then
17*1340Smax.romanov@nginx.com            NXT_SHA512_TOOL="shasum -a 512 --check"
18*1340Smax.romanov@nginx.com        else
19*1340Smax.romanov@nginx.com            if openssl version >/dev/null 2>&1; then
20*1340Smax.romanov@nginx.com                NXT_SHA512_TOOL="openssl dgst -sha512"
21*1340Smax.romanov@nginx.com            fi
22*1340Smax.romanov@nginx.com        fi
23*1340Smax.romanov@nginx.com    fi
24*1340Smax.romanov@nginx.com
25*1340Smax.romanov@nginx.com    if [ -z "$NXT_SHA512_TOOL" ]; then
26*1340Smax.romanov@nginx.com        $echo " not found"
27*1340Smax.romanov@nginx.com        $echo
28*1340Smax.romanov@nginx.com        $echo $0: error: no sha512 tool found.
29*1340Smax.romanov@nginx.com        $echo
30*1340Smax.romanov@nginx.com        $echo "error: no sha512 tool found" >> $NXT_AUTOCONF_ERR
31*1340Smax.romanov@nginx.com        exit 1
32*1340Smax.romanov@nginx.com    fi
33*1340Smax.romanov@nginx.com
34*1340Smax.romanov@nginx.com    $echo " $NXT_SHA512_TOOL"
35*1340Smax.romanov@nginx.com    $echo "found $NXT_SHA512_TOOL" >> $NXT_AUTOCONF_ERR
36*1340Smax.romanov@nginx.comfi
37*1340Smax.romanov@nginx.com
38*1340Smax.romanov@nginx.comif [ -f "$NXT_JAR_CHK_FILE" ]; then
39*1340Smax.romanov@nginx.com    NXT_JAR_SHA512=`grep -F $NXT_JAR_FILE auto/modules/java_jar.sha512 | head -c 128`
40*1340Smax.romanov@nginx.com    NXT_JAR_CHK=${NXT_JAR_CHK_FILE}.sha512.$$
41*1340Smax.romanov@nginx.com    $echo "$NXT_JAR_SHA512  $NXT_JAR_CHK_FILE" > $NXT_JAR_CHK
42*1340Smax.romanov@nginx.com
43*1340Smax.romanov@nginx.com    if ! $NXT_SHA512_TOOL $NXT_JAR_CHK >/dev/null 2>&1; then
44*1340Smax.romanov@nginx.com        $echo "SHA512 not matched for $NXT_JAR_FILE, removing $NXT_JAR_CHK_FILE"
45*1340Smax.romanov@nginx.com        rm -f $NXT_JAR_CHK_FILE
46*1340Smax.romanov@nginx.com    fi
47*1340Smax.romanov@nginx.com
48*1340Smax.romanov@nginx.com    rm -f $NXT_JAR_CHK
49*1340Smax.romanov@nginx.comfi
50