blob: 869bb5b7accc3bd6ab4941267223e9e8fa243bdd [file] [log] [blame]
Jens Wiklanderc0bc8082018-02-27 20:25:25 +01001#!/bin/sh
Jens Wiklanderc0bc8082018-02-27 20:25:25 +01002
Etienne Carriere43791be2019-02-06 14:51:01 +01003DAEMON="tee-supplicant"
4DAEMON_PATH="/usr/sbin"
5DAEMON_ARGS="-d /dev/teepriv0"
6PIDFILE="/var/run/$DAEMON.pid"
7
8start() {
9 # tee-supplicant and the client applications need not run as
10 # root provided that the TEE devices and the data store have
11 # proper permissions
12 printf 'Set permissions on %s: ' "/dev/tee*"
13 chown root:tee /dev/teepriv0 && chmod 0660 /dev/teepriv0 && \
14 chown root:teeclnt /dev/tee0 && chmod 0660 /dev/tee0
15 status=$?
16 if [ "$status" -eq 0 ]; then
17 echo "OK"
18 else
19 echo "FAIL"
20 return "$status"
21 fi
Etienne Carriere43791be2019-02-06 14:51:01 +010022 printf 'Create/set permissions on %s: ' "/data/tee"
23 mkdir -p /data/tee && chown -R tee:tee /data/tee && chmod 0770 /data/tee
24 status=$?
25 if [ "$status" -eq 0 ]; then
26 echo "OK"
27 else
28 echo "FAIL"
29 return "$status"
30 fi
31 printf 'Starting %s: ' "$DAEMON"
32 start-stop-daemon -S -q -p "$PIDFILE" -c tee -x "$DAEMON_PATH/$DAEMON" \
33 -- $DAEMON_ARGS
34 status=$?
35 if [ "$status" -eq 0 ]; then
36 echo "OK"
37 else
38 echo "FAIL"
39 fi
40 return "$status"
41}
42
43stop() {
44 printf 'Stopping %s: ' "$DAEMON"
45 start-stop-daemon -K -q -p "$PIDFILE"
46 status=$?
47 if [ "$status" -eq 0 ]; then
48 echo "OK"
49 else
50 echo "FAIL"
51 fi
52 return "$status"
53}
54
55restart() {
56 stop
57 sleep 1
58 start
59}
60
61case "$1" in
62 start|stop|restart)
63 "$1";;
64 reload)
65 # Restart, since there is no true "reload" feature (does not
66 # reconfigure/restart on SIGHUP, just closes all open files).
67 restart;;
68 *)
69 echo "Usage: $0 {start|stop|restart|reload}"
70 exit 1
Jens Wiklanderc0bc8082018-02-27 20:25:25 +010071esac