#!/usr/bin/bash

if [ "$1" = "renewed" ]; then
  # save state for later apache reload
  touch /var/lib/httpd/reload-needed
  #echo "Certificate for $2 renewed" \
  #  | mail -s "mod_md OK for $2" root
elif [ "$1" = "renewing" ]; then
  echo "Renewing certificate for $2"
elif [ "$1" = "errored" ]; then
  echo "Unable to refresh certificate for $2" \
    | mail -s "mod_md error for $2" root
elif [ "$1" = "expiring" ]; then
  echo "$0: expiring for $2"
elif [ "$1" = "installed" ]; then
  # just ignore
  :
elif [[ "$1" =~ ^challenge-setup: ]]; then
  # ignore LE challenge setups
  :
else
  echo "$0: ERROR: unknown arguments: $@"
fi

exit 0
