-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
58 lines (49 loc) · 1.82 KB
/
setup.sh
File metadata and controls
58 lines (49 loc) · 1.82 KB
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
#!/bin/bash
sudo sh -c "echo '127.0.0.1 ubuntu' >> /etc/hosts"
sudo apt install -y fuse libfuse-dev pkg-config python2.7
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt install -y nodejs
mkdir /home/ubuntu/test_gpio_mirroring
cd /home/ubuntu/test_gpio_mirroring
npm config set python `which python2.7`
npm install fuse-bindings fs mknod path minimist
npm install https://github.com/PlayNetwork/node-statvfs/tarball/v3.0.0
wget https://raw.githubusercontent.com/flongo82/node-folder-mirroring/master/node-folder-mirroring.js
sudo add-apt-repository -y ppa:ubuntu-lxc/lxd-stable
sudo apt-get update
sudo apt-get install -y lxd lxd-tools criu cgmanager
lxd --version
sudo addgroup gpio
sudo usermod -a -G gpio ubuntu
cat<<EOF | sudo tee /etc/udev/rules.d/99-gpio.rules
SUBSYSTEM=="input", GROUP="input", MODE="0660"
SUBSYSTEM=="i2c-dev", GROUP="i2c", MODE="0660"
SUBSYSTEM=="spidev", GROUP="spi", MODE="0660"
SUBSYSTEM=="bcm2835-gpiomem", GROUP="gpio", MODE="0660"
SUBSYSTEM=="gpio*", PROGRAM="/bin/sh -c '\\
chown -R root:gpio /sys/class/gpio && chmod -R 770 /sys/class/gpio;\\
chown -R root:gpio /sys/devices/virtual/gpio && chmod -R 770 /sys/devices/virtual/gpio;\\
chown -R root:gpio /sys\$devpath && chmod -R 770 /sys\$devpath\\
'"
KERNEL=="ttyAMA[01]", PROGRAM="/bin/sh -c '\\
ALIASES=/proc/device-tree/aliases; \\
if cmp -s \$ALIASES/uart0 \$ALIASES/serial0; then \\
echo 0;\\
elif cmp -s \$ALIASES/uart0 \$ALIASES/serial1; then \\
echo 1; \\
else \\
exit 1; \\
fi\\
'", SYMLINK+="serial%c"
KERNEL=="ttyS0", PROGRAM="/bin/sh -c '\\
ALIASES=/proc/device-tree/aliases; \\
if cmp -s \$ALIASES/uart1 \$ALIASES/serial0; then \\
echo 0; \\
elif cmp -s \$ALIASES/uart1 \$ALIASES/serial1; then \\
echo 1; \\
else \\
exit 1; \\
fi \\
'", SYMLINK+="serial%c"
EOF
echo "Setup completed. Please, reboot and then launch 'sudo lxd init'."