This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
install.sh
executable file
·118 lines (102 loc) · 3.19 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# This file is part of the Soletta Project
#
# Copyright (C) 2015 Intel Corporation. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
print_need_dep () {
echo "Dependency not found: $1"
}
RETVAL=0
SYSTEMD_SERVICE_PATH="/etc/systemd/system"
test_dep () {
SILENT=$2
PKG_NAME=$3
test=$(which $1)
if [ -z "$test" ]; then
if [ $SILENT -eq 0 ]; then
print_need_dep $1
exit 1
fi
RETVAL=1
else
RETVAL=0
fi
}
if [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "--help" ]; then
echo "Usage: install.sh PATH"
echo " PATH: Installation path that soletta dev-app will be installed."
echo " If no path is provided, it will use the current dir of install.sh"
exit 0
fi
test_dep "systemctl" 1
if [ $RETVAL -eq 1 ]; then
print_need_dep "systemd"
exit 1
fi
SYSTEMD_VERSION=$(systemctl show -p Version | cut -f 2 -d '=')
if [ $SYSTEMD_VERSION -lt 216 ]; then
echo "Systemd version 216 or later is required"
exit 1
fi
test_dep "node" 1
if [ $RETVAL -eq 1 ]; then
test_dep "nodejs" 0 "nodejs"
NODE_BIN_NAME="nodejs"
else
NODE_BIN_NAME="node"
fi
FBP_RUNNER_PATH=$(which sol-fbp-runner)
if [ -z "$FBP_RUNNER_PATH" ]; then
print_need_dep "soletta"
echo "To install soletta: https://github.com/solettaproject/soletta/wiki#packages"
exit 1
fi
FBP_DOT=$(which sol-fbp-to-dot)
test_dep "sol-fbp-to-dot" 1
if [ $RETVAL -eq 1 ]; then
echo "Recompile soletta with FBP_TO_DOT support"
exit 1
fi
test_dep "dot" 0 "graphviz"
test_dep "npm" 0 "npm"
test_dep "bower" 1 2>/dev/null
if [ $RETVAL -eq 1 ]; then
print_need_dep "bower"
echo "sudo npm install -g bower"
exit 1
else
BOWER=$(bower -v)
if [ -z "$BOWER" ]; then
echo "If you are running distro debian based machine run:"
echo "sudo apt-get install nodejs-legacy"
exit 1
fi
fi
npm install
bower install
echo "Installing required services..."
SERVER_PATH=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
if [ -n "$1" ]; then
cp -r $SERVER_PATH $1
SERVER_PATH=$1
fi
su -c "cp $SERVER_PATH/scripts/units/[email protected] $SYSTEMD_SERVICE_PATH/ &&
cp $SERVER_PATH/scripts/units/soletta-dev-app-server.service.in $SYSTEMD_SERVICE_PATH/soletta-dev-app-server.service &&
sed -i "s@PATH@"$SERVER_PATH"@" $SYSTEMD_SERVICE_PATH/soletta-dev-app-server.service &&
sed -i "s@"NODE_BIN_NAME"@"$NODE_BIN_NAME"@" $SYSTEMD_SERVICE_PATH/soletta-dev-app-server.service &&
sed -i "s@"/usr/bin/sol-fbp-runner"@"$FBP_RUNNER_PATH"@" $SYSTEMD_SERVICE_PATH/[email protected]"
systemctl daemon-reload
echo "to start server run:"
echo "systemctl start soletta-dev-app-server"
exit 0