Richard Marian Thomaiyar | 14fddef | 2018-07-13 23:55:56 +0530 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | ### BEGIN INIT INFO |
| 4 | # Provides: tpm2-abrmd |
| 5 | # Required-Start: $local_fs $remote_fs $network |
| 6 | # Required-Stop: $local_fs $remote_fs $network |
| 7 | # Should-Start: |
| 8 | # Should-Stop: |
| 9 | # Default-Start: 2 3 4 5 |
| 10 | # Default-Stop: 0 1 6 |
| 11 | # Short-Description: starts tpm2-abrmd |
| 12 | # Description: tpm2-abrmd implements the TCG resource manager |
| 13 | ### END INIT INFO |
| 14 | |
| 15 | PATH=/sbin:/bin:/usr/sbin:/usr/bin |
| 16 | DAEMON=/usr/sbin/tpm2-abrmd |
| 17 | NAME=tpm2-abrmd |
| 18 | DESC="TCG TSS2 Access Broker and Resource Management daemon" |
| 19 | USER="tss" |
| 20 | |
| 21 | test -x "${DAEMON}" || exit 0 |
| 22 | |
| 23 | # Read configuration variable file if it is present |
| 24 | [ -r /etc/default/$NAME ] && . /etc/default/$NAME |
| 25 | |
| 26 | case "${1}" in |
| 27 | start) |
| 28 | echo -n "Starting $DESC: " |
| 29 | |
| 30 | if [ ! -e /dev/tpm* ] |
| 31 | then |
| 32 | echo "device driver not loaded, skipping." |
| 33 | exit 0 |
| 34 | fi |
| 35 | |
| 36 | start-stop-daemon --start --quiet --oknodo --background --pidfile /var/run/${NAME}.pid --user ${USER} --chuid ${USER} --exec ${DAEMON} -- ${DAEMON_OPTS} |
| 37 | RETVAL="$?" |
| 38 | echo "$NAME." |
| 39 | [ "$RETVAL" = 0 ] && pidof $DAEMON > /var/run/${NAME}.pid |
| 40 | exit $RETVAL |
| 41 | ;; |
| 42 | |
| 43 | stop) |
| 44 | echo -n "Stopping $DESC: " |
| 45 | |
| 46 | start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/${NAME}.pid --user ${USER} --exec ${DAEMON} |
| 47 | RETVAL="$?" |
| 48 | echo "$NAME." |
| 49 | rm -f /var/run/${NAME}.pid |
| 50 | exit $RETVAL |
| 51 | ;; |
| 52 | |
| 53 | restart|force-reload) |
| 54 | "${0}" stop |
| 55 | sleep 1 |
| 56 | "${0}" start |
| 57 | exit $? |
| 58 | ;; |
| 59 | *) |
| 60 | echo "Usage: ${NAME} {start|stop|restart|force-reload|status}" >&2 |
| 61 | exit 3 |
| 62 | ;; |
| 63 | esac |
| 64 | |
| 65 | exit 0 |