#!/bin/sh

set -e

# POSIX-compliant maint function recommend by devref
# to check for the existence of a command
# https://www.debian.org/doc/manuals/developers-reference/ch06.html#bpp-debian-maint-scripts
pathfind() {
	OLDIFS="$IFS"
	IFS=:
	for p in $PATH; do
		if [ -x "$p/$*" ]; then
		IFS="$OLDIFS"
		return 0
		fi
	done
	IFS="$OLDIFS"
	return 1
}

case "$1" in
	configure|reconfigure)
		if pathfind udevadm; then
			if ! udevadm control --reload; then
				echo "Failed to reload udev rules"
			fi
		else
			echo "udevadm not installed; udev rules cannot be reloaded."
		fi
		;;
	abort-upgrade|abort-remove|abort-deconfigure)
		;;
	*)
		echo "postinst called with unknown argument \`$1'" >&2
		exit 1
		;;
esac

#DEBHELPER#
