-
Notifications
You must be signed in to change notification settings - Fork 17
/
init
executable file
·54 lines (42 loc) · 1.14 KB
/
init
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
#!/bin/bash
git pull
CURL_EXISTS=`which curl`
if [ -d ${CURL_EXISTS} ]; then
echo "[i] Installing curl..."
sudo apt-get --assume-yes install curl
fi
NODE_EXISTS=`which node`
if [ -d ${NODE_EXISTS} ]; then
echo "[i] Installing nodejs..."
# curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash -
sudo apt-get --assume-yes install nodejs
sudo apt-get --assume-yes install npm
fi
if [ ! -d /usr/local/lib/node_modules/n ]; then
echo "[i] Checking node version"
sudo npm cache clean -f
sudo npm install -g n
sudo n 12.16.2
fi
PATH="$PATH"
echo "[i] Check npm version"
sudo npm install npm@latest -g
echo "[i] Installing homebridge and homebridge plugins..."
npm run homebridge-install
if [ ! -d /usr/local/lib/node_modules/pm2 ]; then
echo "[i] Installing node process manager..."
sudo npm install -g pm2
fi
echo "[i] Installing dependancies for freebox home server"
npm install
echo "[i] Starting services"
pm2
# first, start homebridge to setup the .homebridge env
pm2 start /usr/local/bin/homebridge
sleep 10
# then kill it
pm2 stop 0
# then, start the server
pm2 start src/index.js
pm2 start 0
pm2 save