#!/bin/sh
[ "$1" != "upgrade" ] || exit 0
if [ -n "$D" -o ! -d /run/systemd/system ] && [ -z "$D" -a ! -d /run/systemd/system ]; then
	/etc/init.d/tpmd stop
fi
OPTS=""

if [ -n "$D" ]; then
    OPTS="--root=$D"
fi

if type systemctl >/dev/null 2>/dev/null; then
	if [ -z "$D" ]; then
		systemctl stop tpmd.service
	fi

	systemctl $OPTS disable tpmd.service
fi
