#!/bin/sh

case "$1" in
  configure)
    # continue below
  ;;

  abort-upgrade|abort-remove|abort-deconfigure)
    exit 0
  ;;

  *)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 0
  ;;
esac

/sbin/ldconfig > /dev/null 2>&1

if [ -f /.dockerenv ]; then exit 0; fi

echo "Adding the pf_ring startup script"
if hash systemctl 2>/dev/null; then    
  /bin/systemctl enable pf_ring.service > /dev/null

  # Migration from old-style .start
  if ls /etc/pf_ring/pf_ring.start 1> /dev/null 2>&1;
  then
    /bin/systemctl enable pf_ring
  fi

  /bin/systemctl restart pf_ring
else
  update-rc.d pf_ring defaults 30 >/dev/null
  update-rc.d cluster defaults 40 >/dev/null

  /etc/init.d/pf_ring restart
fi

exit 0
