-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·129 lines (108 loc) · 3.88 KB
/
install.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/bin/bash
SYSTEM_INSTALL_DIR=$(pwd)
set -e
usage() {
echo "install [BACKEND_BRANCH] [FRONTEND_RELEASE]"
echo "install all CoderBot software dependancies and components"
exit 2
}
[[ $1 == "-h" || $1 == "--help" ]] && usage
BACKEND_BRANCH=${1:-'develop'}
FRONTEND_RELEASE=${2:-'v0.4-rc3'}
INSTALL_MODEL_PRETRAINED=${3:-'yes'}
INSTALL_MODEL_4TRAINING=${4:-'no'}
apt-get update -y
apt-get upgrade -y
apt-get install -y hostapd dnsmasq pigpio espeak ffmpeg nginx \
portaudio19-dev git python3-pip python3 python3-venv \
libopenjp2-7-dev libtiff5 libatlas-base-dev libhdf5-dev \
libharfbuzz-bin libwebp6 libjasper1 libilmbase25 \
libgstreamer1.0-0 libavcodec-extra58 libavformat58 \
libopencv-dev zbar-tools libzbar0 sox libsox-fmt-all \
avrdude tesseract-ocr
apt-get clean
mkdir -p /etc/coderbot
cp etc/boot/config.txt /boot/config.txt
cp etc/hostname /etc/.
cp etc/hosts /etc/.
cp etc/init.d/* /etc/init.d/.
cp etc/hostapd/* /etc/hostapd/.
cp etc/dnsmasq.conf /etc/.
cp etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/.
cp etc/avrdude.conf /usr/local/etc/.
cp etc/coderbot/* /etc/coderbot/.
cp etc/modprobe.d/alsa-base.conf /etc/modprobe.d/.
cp etc/alsa.conf /usr/share/alsa/alsa.conf
cp etc/dhcpcd.conf.client /etc/dhcpcd.conf.client
cp etc/dhcpcd.conf.ap /etc/dhcpcd.conf.ap
cp etc/modules /etc/modules
# reset service module
cp etc/scripts/* /usr/local/bin/. #copying user-oriented scripts
cp etc/services/* /etc/systemd/system/. #copying services
cp etc/rsyslog.d/* /etc/rsyslog.d/. #copying log directive
# nginx
cp etc/nginx/nginx.conf /etc/nginx/nginx.conf
cp etc/nginx/default.conf /etc/nginx/conf.d/default.conf
sudo -u pi bash << EOF
cd /home/pi
wget https://github.com/CoderBotOrg/backend/archive/$BACKEND_BRANCH.zip
unzip $BACKEND_BRANCH.zip
rm $BACKEND_BRANCH.zip
mv backend-$BACKEND_BRANCH coderbot
EOF
sudo -u pi bash << EOF
[[ "$INSTALL_MODEL_PRETRAINED" = "yes" ]] && ./install_generic_cnn_models.sh
[[ "$INSTALL_MODEL_4TRAINING" = "yes" ]] && ./download_mobilenet_models.sh
echo done
EOF
cd ../coderbot
pip install --no-cache-dir -r requirements_stub.txt
pip install --no-cache-dir -r requirements.txt
cd ..
sudo -u pi bash << EOF
wget https://github.com/CoderBotOrg/frontend/releases/download/$FRONTEND_RELEASE/frontend.tar.gz
tar xzf frontend.tar.gz -C /usr/share/nginx/html --strip-components=1
rm frontend.tar.gz
wget https://github.com/CoderBotOrg/docs/releases/download/v0.2/docs.tgz
mkdir -p /usr/share/nginx/html/docs
tar xzf docs.tgz -C /usr/share/nginx/html/docs
rm docs.tgz
EOF
sudo -u pi bash << EOF
$SYSTEM_INSTALL_DIR/install_firmware.sh
EOF
wget https://github.com/CoderBotOrg/update-reset/archive/master.zip
unzip master.zip
rm master.zip
cd update-reset-master
make install DESTDIR=/
enable_overlay enable
cd ..
rm -rvf update-reset-master
# amixer sset Headphone,0 100%
# init wifi unique id
coderbot/wifi.py setuniquessid
coderbot/wifi.py updatecfg -m ap
systemctl disable dphys-swapfile
systemctl unmask hostapd
systemctl disable wpa_supplicant
systemctl enable coderbot
systemctl enable pigpiod
systemctl enable wifi
systemctl enable reset_trigger.service #enables reset_trigger service
systemctl start pigpiod
systemctl start wifi
systemctl start coderbot
systemctl start reset_trigger.service #starts service immediately avoiding reboot to enable
systemctl restart rsyslog #restarting syslog to update syslog output directives
rm -rvf $SYSTEM_INSTALL_DIR
# music extension
# amixer -c1 cset 'numid=1' 400
# replace avrdude with custom build - linuxspi support
wget https://github.com/CoderBotOrg/avrdude/releases/download/v7.0/avrdude-v7.tar.gz
tar xf avrdude-v7.tar.gz
mv v7.0/avrdude /usr/local/bin/avrdude
mv v7.0/avrdude.conf /usr/local/etc/avrdude.conf
rm -rf v7.0
rm avrdude-v7.tar.gz
echo "coderbot install complete!"