/
setup.sh
executable file
·77 lines (64 loc) · 2.08 KB
/
setup.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
#!/bin/bash -ex
if ! which sudo; then
echo "run apt-get install sudo"
exit
fi
sudo sed -i~ 's/main$/main contrib non-free/g' /etc/apt/sources.list
sudo apt-get update
sudo apt-get upgrade -yq
sudo apt-get install -yq sudo flashrom mosquitto mosquitto-clients \
fritzing fritzing-parts \
vim git firmware-linux-free python-serial \
firmware-iwlwifi openssh-server \
avrdude binutils-avr extra-xdg-menus gcc-avr libftdi1 \
libjna-java libjna-jni librxtx-java \
export fromdir=$(pwd)
export basedir='/usr/local/'
export ver='arduino-1.8.7'
export arduinodir="${basedir}${ver}"
if [[ ! -d "$arduinodir" ]]; then
#if [[ -d "${fromdir}/${ver}" ]]; then
# sudo cp -r "${fromdir}/$ver" "${arduinodir}"
#else
cd $basedir
sudo tar xvf "${fromdir}/${ver}-linux64.tar.xz"
#fi
sudo chmod 777 $arduinodir
cd $arduinodir
./install.sh
sudo ln -s /usr/local/arduino-1.8.5/arduino /usr/local/bin/
fi
if [[ ! -d "${arduinodir}/hardware/espressif" ]]; then
mkdir -p ${arduinodir}/hardware/espressif
cd ${arduinodir}/hardware/espressif
if [[ -d "${fromdir}/esp32" ]]; then
cp -r "$fromdir/esp32" .
else
git clone https://github.com/espressif/arduino-esp32.git esp32
fi
cd esp32/tools/
sudo python get.py
fi
if [[ ! -d "${arduinodir}/examples/00.Planting" ]]; then
cd "${arduinodir}/examples/"
git clone https://github.com/FollyEngine/esp32village 00.Planting
ln -s ${arduinodir}/examples/00.Planting/mqtt ${arduinodir}/libraries/mqtt
else
cd "${arduinodir}/examples/00.Planting"
git fetch --all
git pull
fi
# install the MQTT lib
arduino --install-library PubSubClient
arduino --install-library 'Adafruit NeoPixel'
arduino --install-library ESP32Servo
cp -r ~/Arduino/libraries/* ${arduinodir}/libraries/ || true
if ! getent passwd planting; then
sudo adduser $USER sudo
sudo adduser $USER dialout
sudo adduser --ingroup dialout --disabled-password planting
fi
sudo cp planting.png /var/lib/AccountsService/icons/planting
if ! grep Icon /var/lib/AccountsService/users/planting; then
sudo sh -c 'echo "Icon=/var/lib/AccountsService/icons/planting" >> /var/lib/AccountsService/users/planting'
fi