8481d4
#! /bin/bash
8481d4
8481d4
MODSECKEY="./signing_key.priv"
8481d4
MODPUBKEY="./signing_key.x509"
c8da8f
moddir=$1
c8da8f
c8da8f
modules=`find $moddir -type f -name '*.ko'`
8481d4
c8da8f
NPROC=`nproc`
c8da8f
[ -z "$NPROC" ] && NPROC=1
8481d4
c8da8f
# NB: this loop runs 2000+ iterations. Try to be fast.
c8da8f
echo "$modules" | xargs -r -n16 -P $NPROC sh -c "
c8da8f
for mod; do
c8da8f
    ./scripts/sign-file sha256 $MODSECKEY $MODPUBKEY \$mod
c8da8f
    rm -f \$mod.sig \$mod.dig
8481d4
done
c8da8f
" DUMMYARG0   # xargs appends ARG1 ARG2..., which go into $mod in for loop.
8481d4
c8da8f
RANDOMMOD=$(echo "$modules" | sort -R | tail -n 1)
8481d4
if [ "~Module signature appended~" != "$(tail -c 28 $RANDOMMOD)" ]; then
8481d4
	echo "*** Modules are unsigned! ***"
8481d4
	exit 1
8481d4
fi
8481d4
8481d4
exit 0