#!/bin/sh

test -x /usr/bin/tpmd || exit 0

case "$1" in
  start)
    echo -n "Starting tpmd"
    start-stop-daemon -q -p /var/run/tpmd.pid -x /usr/bin/tpmd -S -b -m
    echo "."
    ;;
  stop)
    echo -n "Stopping tpmd"
    start-stop-daemon -q -p /var/run/tpmd.pid -x /usr/bin/tpmd -K
    echo "."
    ;;
  restart|reload|force-reload)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "Usage: /etc/init.d/tpmd {start|stop|restart|reload|force-reload}"
    exit 1
esac

exit 0
