forked from tiny-pilot/tinypilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quick-install
executable file
·73 lines (65 loc) · 2.24 KB
/
quick-install
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
#!/usr/bin/env bash
# Echo commands to stdout.
set -x
if [ -z "$TINYPILOT_INSTALL_VARS" ]
then
TINYPILOT_INSTALL_VARS=""
echo "Using default install vars"
else
echo "User-specified install vars: $TINYPILOT_INSTALL_VARS"
fi
# Check if this system uses the TC358743 HDMI to CSI capture bridge.
USE_TC358743_DEFAULTS=''
if [[ "$TINYPILOT_INSTALL_VARS" =~ 'ustreamer_capture_device=' ]]; then
if [[ "$TINYPILOT_INSTALL_VARS" =~ 'ustreamer_capture_device=tc358743' ]]; then
USE_TC358743_DEFAULTS='y'
fi
# Only check the existing config file if user has not set
# ustreamer_capture_device install variable.
elif [ -f /home/ustreamer/config.yml ] && grep --silent 'capture_device: "tc358743"' /home/ustreamer/config.yml; then
USE_TC358743_DEFAULTS='y'
fi
# If this system does not use a TC358743 capture chip, set defaults for any
# unset install variables.
if [ -z "$USE_TC358743_DEFAULTS" ]; then
if [[ ! "$TINYPILOT_INSTALL_VARS" =~ 'ustreamer_encoder=' ]]; then
TINYPILOT_INSTALL_VARS+=" ustreamer_encoder=hw"
fi
if [[ ! "$TINYPILOT_INSTALL_VARS" =~ 'ustreamer_format=' ]]; then
TINYPILOT_INSTALL_VARS+=" ustreamer_format=jpeg"
fi
if [[ ! "$TINYPILOT_INSTALL_VARS" =~ 'ustreamer_resolution=' ]]; then
TINYPILOT_INSTALL_VARS+=" ustreamer_resolution=1920x1080"
fi
if [[ ! "$TINYPILOT_INSTALL_VARS" =~ 'ustreamer_persistent=' ]]; then
TINYPILOT_INSTALL_VARS+=" ustreamer_persistent=true"
fi
if [[ ! "$TINYPILOT_INSTALL_VARS" =~ 'ustreamer_desired_fps=' ]]; then
TINYPILOT_INSTALL_VARS+=" ustreamer_desired_fps=30"
fi
fi
# Treat undefined environment variables as errors.
set -u
# Exit on first error.
set -e
echo "Final install vars: $TINYPILOT_INSTALL_VARS"
pushd $(mktemp -d)
sudo apt-get update
sudo apt-get install -y libffi-dev libssl-dev python3-dev python3-venv
python3 -m venv venv
. venv/bin/activate
# Ansible depends on wheel.
pip install wheel==0.34.2
pip install ansible==2.9.10
echo "[defaults]
roles_path = $PWD
interpreter_python = /usr/bin/python3
" > ansible.cfg
ansible-galaxy install mtlynch.tinypilot
echo "- hosts: localhost
connection: local
become: true
become_method: sudo
roles:
- role: mtlynch.tinypilot" > install.yml
ansible-playbook -i localhost, install.yml --extra-vars "$TINYPILOT_INSTALL_VARS"