#!/bin/sh

ACTION=${1}

if [ -d "/etc/dehydrated/hooks_"$ACTION".d" ]; then
  echo Executing hooks for $ACTION event
  shift
  for H in $(find /etc/dehydrated/hooks_"$ACTION".d/ -type f -o -type l | sort); do
    if [ -x $H ]; then
      echo Running $H hook
      $H $@
    else
      echo $H is not executable, skiping
    fi
  done
fi
