forked from WebThingsIO/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-app.sh
executable file
·52 lines (42 loc) · 1001 Bytes
/
run-app.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
#!/bin/bash
set -e
set -x
MOZIOT_HOME="${MOZIOT_HOME:=${HOME}/.mozilla-iot}"
args=""
start_task="start"
is_docker_container() {
if [ -f /.dockerenv ]; then
return 0
fi
if grep -q ':\/docker\/' /proc/1/cgroup 2>&1; then
return 0
fi
return 1
}
if ! is_docker_container; then
start_task="run-only"
if [ ! -f .post_upgrade_complete ]; then
./tools/post-upgrade.sh
fi
fi
run_app() {
export NVM_DIR="$HOME/.nvm"
[ ! -s "$NVM_DIR/nvm.sh" ] || \. "$NVM_DIR/nvm.sh" # This loads nvm
if [ ! is_docker_container ]; then
sudo /sbin/ldconfig
(sudo timedatectl set-local-rtc 0 && sudo timedatectl set-ntp 1) || true
### removed temporarily to fix docker containers ###
# else
# /sbin/ldconfig
fi
echo "nvm version"
nvm --version || echo "Use system's node insead of nvm"
echo "node version"
node --version
echo "npm version"
npm --version
echo "Starting gateway ..."
npm run $start_task -- $args
}
mkdir -p "${MOZIOT_HOME}/log"
run_app