-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
64 lines (47 loc) · 1.54 KB
/
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
#!/bin/sh
# get flags
while getopts h:a: flag
do
case "${flag}" in
h) hostname=${OPTARG};;
a) authtoken=${OPTARG};;
esac
done
# disable serial console and enable serial hardware (/dev/serial0)
sudo raspi-config nonint do_serial 2
# add repository for nodejs
curl -sSL https://deb.nodesource.com/setup_16.x | sudo bash -
# install python, git and nodejs
sudo apt install -y python3 python3-pip git nodejs
# install buildhat library
export PATH="$HOME/.local/bin:$PATH"
pip3 install buildhat
# copy hotfix for buildhat library (see https://github.com/RaspberryPiFoundation/python-build-hat/pull/125)
wget https://raw.githubusercontent.com/RaspberryPiFoundation/python-build-hat/a4edde74e051aa03fe4e91122000115cb6b36919/buildhat/motors.py -O ~/.local/lib/python3.9/site-packages/buildhat/motors.py
# install pm2
sudo npm install pm2 -g
# clone repository
cd $HOME
git clone https://github.com/dennisbohn/raspi-robot-2.git
# install packages
cd $HOME/raspi-robot-2
npm update
# run pm2 on startup
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp $HOME
# make update script executable
chmod +x ./update_robot
# allow global execution of update script
sudo cp -f ./update_robot /usr/local/bin/update_robot
# set hostname and authtoken
node config set hostname $hostname
node config set authtoken $authtoken
# start robot
pm2 start robot.js
# save pm2 configuration
pm2 save
# output
clear
echo "Die Installation wurde abgeschlossen."
echo "Das Fenster kann geschlossen werden."
# reboot system
sudo reboot