Jens Wiklander | c0bc808 | 2018-02-27 20:25:25 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # /etc/init.d/optee |
| 4 | # |
| 5 | # Start/stop tee-supplicant (OP-TEE normal world daemon) |
| 6 | # |
| 7 | case "$1" in |
| 8 | start) |
| 9 | if [ -e /usr/sbin/tee-supplicant -a -e /dev/teepriv0 ]; then |
Jerome Forissier | d97413e | 2018-08-17 14:00:01 +0200 | [diff] [blame] | 10 | # 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 Forissier | 749527c | 2018-08-22 17:42:18 +0200 | [diff] [blame] | 14 | chown root:tee /dev/teepriv0 && chmod 0660 /dev/teepriv0 && \ |
| 15 | chown root:teeclnt /dev/tee0 && chmod 0660 /dev/tee0 |
Jerome Forissier | d97413e | 2018-08-17 14:00:01 +0200 | [diff] [blame] | 16 | [ $? = 0 ] && echo "OK" || echo "FAIL" |
Jerome Forissier | cc483d3 | 2018-08-30 14:58:33 +0200 | [diff] [blame] | 17 | 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 |
Joakim Bech | f7ffa9d | 2019-02-01 12:48:05 +0100 | [diff] [blame] | 22 | printf "Create and set permissions on /data... " |
| 23 | mkdir -p /data/tee && chown -R tee:tee /data/tee && \ |
| 24 | chmod 0770 /data/tee |
| 25 | [ $? = 0 ] && echo "OK" || echo "FAIL" |
Jerome Forissier | 0a9644d | 2018-08-17 10:34:59 +0200 | [diff] [blame] | 26 | printf "Starting tee-supplicant... " |
Jerome Forissier | d97413e | 2018-08-17 14:00:01 +0200 | [diff] [blame] | 27 | su tee -c '/usr/sbin/tee-supplicant -d' |
Jerome Forissier | 0a9644d | 2018-08-17 10:34:59 +0200 | [diff] [blame] | 28 | [ $? = 0 ] && echo "OK" || echo "FAIL" |
Jens Wiklander | c0bc808 | 2018-02-27 20:25:25 +0100 | [diff] [blame] | 29 | else |
| 30 | echo "tee-supplicant or TEE device not found" |
| 31 | exit 1 |
| 32 | fi |
| 33 | |
| 34 | ;; |
| 35 | stop) |
| 36 | killall tee-supplicant |
| 37 | ;; |
| 38 | status) |
| 39 | cat /dev/teepriv0 2>&1 | grep -q "Device or resource busy" || not="not " |
| 40 | echo "tee-supplicant is ${not}active" |
| 41 | ;; |
| 42 | esac |