blob: df6129fbfaa704c47630c1a06680fc3fd9d02a80 [file] [log] [blame]
Jens Wiklanderc0bc8082018-02-27 20:25:25 +01001#!/bin/sh
2#
3# /etc/init.d/optee
4#
5# Start/stop tee-supplicant (OP-TEE normal world daemon)
6#
7case "$1" in
8 start)
9 if [ -e /usr/sbin/tee-supplicant -a -e /dev/teepriv0 ]; then
Jerome Forissierd97413e2018-08-17 14:00:01 +020010 # tee-supplicant and the client applications need not run as
11 # root provided that the TEE devices and the data store have
12 # proper permissions
13 printf "Setting permissions on /dev/tee*... "
Jerome Forissier749527c2018-08-22 17:42:18 +020014 chown root:tee /dev/teepriv0 && chmod 0660 /dev/teepriv0 && \
15 chown root:teeclnt /dev/tee0 && chmod 0660 /dev/tee0
Jerome Forissierd97413e2018-08-17 14:00:01 +020016 [ $? = 0 ] && echo "OK" || echo "FAIL"
Jerome Forissiercc483d32018-08-30 14:58:33 +020017 if [ -e /dev/ion ]; then
18 printf "Setting permissions on /dev/ion... "
19 chown root:ion /dev/ion && chmod 0660 /dev/ion
20 [ $? = 0 ] && echo "OK" || echo "FAIL"
21 fi
Jerome Forissier0a9644d2018-08-17 10:34:59 +020022 printf "Starting tee-supplicant... "
Jerome Forissierd97413e2018-08-17 14:00:01 +020023 su tee -c '/usr/sbin/tee-supplicant -d'
Jerome Forissier0a9644d2018-08-17 10:34:59 +020024 [ $? = 0 ] && echo "OK" || echo "FAIL"
Jens Wiklanderc0bc8082018-02-27 20:25:25 +010025 else
26 echo "tee-supplicant or TEE device not found"
27 exit 1
28 fi
29
30 ;;
31 stop)
32 killall tee-supplicant
33 ;;
34 status)
35 cat /dev/teepriv0 2>&1 | grep -q "Device or resource busy" || not="not "
36 echo "tee-supplicant is ${not}active"
37 ;;
38esac