Commit 7b1a1695 authored by remy's avatar remy
Browse files

update check_certs.sh to match #issue1

parent b907613c
......@@ -28,7 +28,7 @@ Then, just run:
bash check_certs.sh
```
This will produce a json output on the standard output.
This will produce a json output on the standard output and in the output directory (defined in `profile.conf`).
## How to use checks.sh
......
......@@ -3,34 +3,48 @@
CURDIR=`pwd`
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DATE=`date '+%Y%m%d_%H%M%S'`
cd ${DIR}
. ./profile.conf
websites=`cat host_https_list.txt`
TOTAL_WEBSITES=`echo ${websites}|awk '{print NF}'`
if [ -z "${OUTPUT_DIR}" ]; then
OUTPUT_DIR="./results"
fi
if [ ! -d ${OUTPUT_DIR} ]; then
mkdir -p ${OUTPUT_DIR};
fi
OUTPUT="${OUTPUT_DIR}/${DATE}_check_certs.json"
#formatting output for jsonreader
i=1
echo "{"
results="{"
for host in ${websites}
do
echo -e "\t\"${host}\":{"
echo -en "\t\t\"enddate\":\t\""
bash ${DIR}/ssl-cert-info.sh --host $host --end | sed "s/$/\",/"
echo -en "\t\t\"status\":\t\""
bash ${DIR}/ssl-cert-info.sh --host $host --end-check|sed "s/$/\"/"
results="${results}\n\t\"${host}\":{"
results="${results}\n\t\t\"enddate\":\t\""
END_DATE=`bash ${DIR}/ssl-cert-info.sh --host $host --end | sed "s/$/\",/"`
results="${results}${END_DATE}"
results="${results}\n\t\t\"status\":\t\""
END_OK=`bash ${DIR}/ssl-cert-info.sh --host $host --end-check|sed "s/$/\"/"`
results="${results}${END_OK}"
if [ $i -eq $TOTAL_WEBSITES ]; then
echo -e "\t}"
else
echo -e "\t},"
results="${results}\n\t}"
else
results="${results}\n\t},"
fi
i=$((i+1))
done
echo "}"
results="${results}\n}"
echo -e ${results} | tee ${OUTPUT}
ssl_answers=`for host in ${websites}; do echo -n "$host:" && bash ${DIR}/ssl-cert-info.sh --host $host --end-check; done`
count=`echo "${ssl_answers}" | grep -c "Ok"`
# 9 machines should answer Ok...
if [ $count -ne $TOTAL_WEBSITES ]; then
echo "${ssl_answers}" |mail -s "${MAIL_SUBJECT}" $MAIL
fi
......
......@@ -4,3 +4,4 @@ MAIL_SUBJECT="certificate error"
# following must be set to false if you have some autosigns certificates website
# otherwise, you can set it to true
CHECK_CERT=false
OUTPUT_DIR="./results"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment