/
sensord-daemon-conf-setup
executable file
·32 lines (31 loc) · 1.4 KB
/
sensord-daemon-conf-setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# Set up a configuration for sensord for "primary use"
# The way we choose the configuration is as follows:
# 1. Prefer the hybris plugin (if available)
# 2. If not, try to pick the best-match from the boardname
cd /etc/sensorfw/
if [ -x /usr/sbin/sensorfwd ]; then
if ldconfig -p | grep libhybrissensorfw ; then
# Always prefer hybris sensor backend to anything else (also overwrite
# old setting, as sometimes the boardname matches, e.g. on grouper)
if [ "$(readlink primaryuse.conf)" != sensord-hybris.conf ]; then
ln -sf sensord-hybris.conf primaryuse.conf
fi
elif [ ! -f primaryuse.conf -a -f /etc/boardname ]; then
# Determine the correct "primary" config file: the first conf file
# whose basename is a substring of boardname, if any (i.e. 'foo.conf'
# matches all devices which have 'foo' in their /etc/boardname)
for f in sensord-*.conf; do
fbase="${f#sensord-}"
if grep -q "${fbase%.conf}" /etc/boardname; then
# N9/N950 (RM-696/RM-680) boardname containts rm_680 for both
# use /proc/1/environ to tell them apart
if [ "$f" = "sensord-rm_680.conf" ] && grep -q 'RM-696' /proc/1/environ; then
f="sensord-rm_696.conf"
fi
ln -s $f primaryuse.conf
break
fi
done
fi
fi