#!/bin/bash
# slacksigchk.sh
# Search Slackware tree for gpg signatures and verify them.
# mrgoblin@slackware.com, modified by mozes@slackware.com for Slackware AArch64.

[ ! -d $1 ] && { echo "Unable to find Slackware tree $1" ; exit 1 ;}

# First we'll verify any files we find in the pwd.
# This includes bootware.
gpg --verify-files *.asc || exit 1

# Enter the Slackware tree specified:
cd $1 || exit 1
#[ ! -d slackware ] && { echo "Unable to find slackware directory - are you in the correct directory?" ; exit 1 ;}
( find . -type f -name "*.t?z.asc" -o -iname "*.md5.asc" | while read sig; do
    gpg -v $sig 2>&1
  done | awk 'BEGIN {badcount=0;count=0}
              /assuming/ {print "Checking "$6; file=$6;count++}
              /BAD/ {print "\nWARNING!!! __BAD__ sig for " file"\n"; badcount++}
              END {print count " Total files with "badcount " Bad sigs"}' )
