Skip to content

Commit

Permalink
add the combine_certs.sh tool
Browse files Browse the repository at this point in the history
  • Loading branch information
kiekerjan committed Jan 3, 2025
1 parent eedee13 commit 5c99641
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions setup/additionals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,6 @@ rkhunter --propupd
hide_output install -m 755 tools/fail2ban-block-ip-range.py /usr/local/bin
cp -f conf/cron/miab-fail2ban-subnet-blocker /etc/cron.d/
# Logrotation is done via generic mail in a box logrotate config

# Install combine_certs.sh tool
hide_output install -m 755 tools/combine_certs.sh /usr/local/bin
32 changes: 32 additions & 0 deletions tools/combine_certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
#
# Copyright (c) 2017 Angus Ainslie
# Mods for Mail in a Box 2024
#

IN_PATH=$1
CERT_NAME_FULL=$2
CERT_NAME_PRIV=$3
OUT_PATH=$4
PEM_NAME=$5

CHAIN_SUM=`md5sum ${IN_PATH}/${CERT_NAME_FULL}`
KEY_SUM=`md5sum ${IN_PATH}/${CERT_NAME_PRIV}`

echo "Chain sum ${CHAIN_SUM}"
echo "Key sum ${KEY_SUM}"

if [ ! -e ${OUT_PATH}/sums ]; then
touch ${OUT_PATH}/sums
fi

md5sum --status -c ${OUT_PATH}/sums

if [ $? -eq 0 ]; then
echo "Keys match"
else
echo "Keys don't match. re-creating pem file"
cat ${IN_PATH}/${CERT_NAME_FULL} ${IN_PATH}/${CERT_NAME_PRIV} > ${OUT_PATH}/${PEM_NAME}
echo ${CHAIN_SUM} > ${OUT_PATH}/sums
echo ${KEY_SUM} >> ${OUT_PATH}/sums
fi

0 comments on commit 5c99641

Please sign in to comment.