forked from WebThingsIO/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·58 lines (47 loc) · 1.6 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
#!/bin/bash -e
NVM_VERSION="v0.33.8"
NODE_VERSION="--lts"
cd /home/pi
# Update the base packages that come with the system. This is required
# so that we can install git
sudo apt update
sudo apt upgrade -y
sudo apt install git -y
mkdir -p mozilla-iot
cd mozilla-iot
# Install and configure nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/${NVM_VERSION}/install.sh | bash
# The following 2 lines are installed into ~/.bashrc by the above,
# but on the RPi, sourcing ~/.bashrc winds up being a no-op (when sourced
# from a script), so we just run it here.
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" # This loads nvm
nvm install ${NODE_VERSION}
nvm use ${NODE_VERSION}
# Allow node to use the Bluetooth adapter
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)
# Download, build, and install OpenZWave
sudo apt install libusb-1.0-0-dev libudev-dev -y
if [ ! -d "open-zwave" ]; then
git clone https://github.com/OpenZWave/open-zwave.git --depth 1
fi
cd open-zwave
make
sudo make install
sudo ldconfig /usr/local/lib
# Download and install the required node modules
cd ..
if [ ! -d "gateway" ]; then
git clone https://github.com/moziot/gateway.git
fi
cd gateway
npm install .
# Create a self-signed cert. This is temporary (for development).
#if [ ! -f "certificate.pem" ]; then
# ./tools/make-self-signed-cert.sh
#fi
echo "###################################################################"
echo "#"
echo "# Please reboot to properly activate NVM and the iptables rules."
echo "#"
echo "###################################################################"