#!/bin/sh

action=${DPKG_HOOK_ACTION:-$(ps ax | grep $PPID | sed -n 's/.* \([u]pdate\|[u]pgrade\|[d]ist-upgrade\|[i]nstall\|[r]emove\)\( .*\|$\)/\1/p')}

if [ "$action" ]; then
  for script in $(ls $0.d/* 2>/dev/null | sort); do 
    $script $1 $action; 
  done
fi
