#!/bin/bash

pushd $1 || exit 1
FIRSTPEM=`ls *.pem 2>/dev/null | head -1`

if [ "x$FIRSTPEM" == "x" ]; then
    echo Error: no PEM files found
    exit 1
fi

rm -f `ff -hal`

for file in *.pem
do
    ln -nsf $file "$(openssl x509 -hash -noout -in $file)".0
done
popd
