forked from home-assistant/hassbian-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_libcec.sh
executable file
·84 lines (66 loc) · 2.23 KB
/
install_libcec.sh
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
function libcec-show-short-info {
echo "libcec install script for Hassbian"
}
function libcec-show-long-info {
echo "Installs the libcec package for controlling CEC devices from this Pi"
}
function libcec-show-copyright-info {
echo "Copyright(c) 2017 Fredrik Lindqvist <https://github.im/Landrash>"
}
function libcec-install-package {
libcec-show-short-info
libcec-show-copyright-info
if [ "$(id -u)" != "0" ]; then
echo "This script must be run with sudo. Use \"sudo ${0} ${*}\"" 1>&2
exit 1
fi
echo "Running apt-get preparation"
apt-get update
apt-get install -y cmake libudev-dev libxrandr-dev python-dev swig
echo "Changing to homeassistant user"
sudo -u homeassistant -H /bin/bash <<EOF
echo "Creating source directory"
mkdir -p /srv/homeassistant/src
chown -R homeassistant:homeassistant /srv/homeassistant/src
echo "Cloning Pulse-Eight platform"
cd /srv/homeassistant/src
git clone https://github.com/Pulse-Eight/platform.git
chown homeassistant:homeassistant platform
echo "Building Pulse-Eight platform"
mkdir platform/build
cd platform/build
cmake ..
make
EOF
echo "Installing Pulse-Eight platform"
cd /srv/homeassistant/src/platform/build
sudo make install
echo "Changing back to homeassistant user"
sudo -u homeassistant -H /bin/bash <<EOF
echo "Cloning Pulse-Eight libcec"
cd /srv/homeassistant/src
git clone https://github.com/Pulse-Eight/libcec.git
echo "Building Pulse-Eight platform"
chown homeassistant:homeassistant libcec
mkdir libcec/build
cd libcec/build
cmake -DRPI_INCLUDE_DIR=/opt/vc/include -DRPI_LIB_DIR=/opt/vc/lib ..
make -j4
EOF
echo "Installing Pulse-Eight libcec"
cd /srv/homeassistant/src/libcec/build
sudo make install
sudo ldconfig
echo "Linking libcec to venv site packages"
sudo -u homeassistant ln -s /usr/local/lib/python3.*/site-packages/cec /srv/homeassistant/lib/python3.*/site-packages/
echo
echo "Installation done."
echo
echo "If you have issues with this script, please contact @Landrash on gitter.im"
echo
echo "To continue have a look at https://home-assistant.io/components/hdmi_cec/"
echo "It's recomended that you restart your Pi before continuing with testing libcec."
echo
}
[[ $_ == $0 ]] && echo "hassbian-config helper script; do not run directly, use hassbian-config install instead"