#!/bin/bash if [ $# -eq 1 ] && [[ "$1" == *".kernel.org/"* ]] then curl "$1" | \ gpg --verify - "$0" 2>&1 | \ grep '^gpg: Signature made .* using \S\+ key ID [0-9A-F]\+$' | \ sed 's|^gpg: Signature made .* using \S\+ key ID \([0-9A-F]\+\)$|0x\1|' exit 0 fi [ $# -eq 1 ] && lvl=$1 || lvl=2 signatures="$( curl 'https://kernel.org/' 2>/dev/null | \ tr '"' '\n' | \ grep '\.sign$' )" alteKeyIds="$( echo "${signatures}" | \ parallel -j0 "$0" "{}" \; 2> /dev/null | \ sort -u )" for ((i=0; i<$lvl; i++)) do keyIds="$( gpg --list-sigs --fast-list-mode --fixed-list-mode --with-colons --no-auto-check-trustdb ${alteKeyIds} | \ grep '^sig:' | \ cut -d: -f 5 | \ sed 's|^|0x|' | \ sort -u )" echo "stage ${i}:" $(echo "${alteKeyIds}" | wc -l) "keys ->" $(echo "${keyIds}" | wc -l) "keys." bekannteKeyIds="$( gpg --list-keys --fast-list-mode --fixed-list-mode --with-colons --no-auto-check-trustdb | \ grep '^pub:' | \ cut -d: -f 5 | \ sed 's|^|0x|' | \ sort -u )" alleKeyIds="$( ( echo "${keyIds}" echo "${bekannteKeyIds}" ) | \ sort -u )" ( echo "${alleKeyIds}" echo "${bekannteKeyIds}" ) | \ sort | \ uniq -u | \ xargs -n50 gpg --recv-keys --no-auto-check-trustdb alteKeyIds="${keyIds}" done echo "checking trustdb ..." gpg --check-trustdb echo "... done"