-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_pybmc.sh
58 lines (45 loc) · 1.36 KB
/
setup_pybmc.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
#!/usr/bin/env bash
#
if [ "$1" = "-x" ]; then
set -x
fi
branch=${1:-main}
install_path=/var/www/pyBMC
user=pybmc
tmpdir=`mktemp -d`
trap "rm -r $tmpdir" EXIT
echo Downloading latest pyBMC...
cd $tmpdir
curl -sL -o pybmc.zip https://github.com/brunokc/pyBMC/archive/${branch}.zip
unzip -q pybmc.zip
echo Setting up pyBMC user...
# Need to add new user to the video group so that vcgencmd will work
sudo useradd -d ${install_path} -m -r -s /bin/false -c "pyBMC" -G video ${user} 2>/dev/null
sudo mkdir -p `dirname ${install_path}`
echo Installing pyBMC...
sudo mv pyBMC-${branch} ${install_path}
sudo chown -R ${user}.${user} ${install_path}
cd ${install_path}
echo Installing pyBMC dependencies...
sudo apt-get -y install python3-venv pigpiod
echo Configuring pigpiod...
sudo systemctl enable pigpiod
sudo systemctl start pigpiod
sudo -u ${user} bash<<_
echo Creating Python virtual environment and activating it...
python -m venv venv
source venv/bin/activate
echo Installing pyBMC Python dependencies...
pip install --upgrade pip
pip install -r requirements.txt
_
echo Installing systemd files...
sudo cp extra/pybmc.service /etc/systemd/system
sudo cp extra/pybmc /etc/default
sudo systemctl daemon-reload
sudo systemctl enable pybmc
echo Starting pyBMC...
sudo systemctl start pybmc
source /etc/default/pybmc
echo Done.
echo PyBMC running on ${BIND_HOST}:${BIND_PORT}