/
install_deps_pi.sh
48 lines (37 loc) · 1.16 KB
/
install_deps_pi.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
#!/bin/bash
# Check for root
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# Install NodeJS
apt-get update
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
apt-get install -y nodejs
node -v
# Create working directory
mkdir -P /home/pi/electron
chown -R pi:pi /home/pi/electron
# Fill the working directory with our application
# Create launch file
cat <<EOF >/home/pi/Desktop/launch.sh
#!/bin/bash
cd /home/pi/electron
npm install
npm start
EOF
chown pi:pi /home/pi/Desktop/launch.sh
chmod +x /home/pi/Desktop/launch.sh
# Backup autostart file
cp /home/pi/.config/lxsession/LXDE-pi/autostart /home/pi/autostart.backup
# Hide mouse pointer
apt-get install unclutter
echo "@unclutter -idle 0" >> /home/pi/.config/lxsession/LXDE-pi/autostart
# Disable screen sleep
echo "@xset s noblank" >> /home/pi/.config/lxsession/LXDE-pi/autostart
echo "@xset s off" >> /home/pi/.config/lxsession/LXDE-pi/autostart
echo "@xset -dpms" >> /home/pi/.config/lxsession/LXDE-pi/autostart
# Add auto startup to crontab
echo "$(echo '@reboot export DISPLAY=:0 && /home/pi/Desktop/launch.sh' ; crontab -u pi -l)" | crontab -u pi -
# Reboot the pi
reboot