-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·154 lines (127 loc) · 3.67 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·154 lines (127 loc) · 3.67 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash -e
###########################################################################
# Functions
#
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
# set to 0 if not found
type $1 >/dev/null 2>&1 || { local return_=0; }
# return value
echo "$return_"
}
# display a message in red with a cross by it
# example
# echo echo_fail "No"
function echo_fail {
# echo first argument in red
printf "\e[31m✘ ${1}"
# reset colours back to normal
printf "\033[0m\n"
}
# display a message in green with a tick by it
# example
# echo echo_fail "Yes"
function echo_pass {
# echo first argument in green
printf "\e[32m✔ ${1}"
# reset colours back to normal
printf "\033[0m\n"
}
# echo pass or fail
# example
# echo echo_if 1 "Passed"
# echo echo_if 0 "Failed"
function echo_if {
if [ $1 == 1 ]; then
echo_pass $2
else
echo_fail $2
fi
}
###########################################################################
# Main
#
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
echo "This script configures current directory as Cascades FBP development environment."
echo -n "Proceed? [y/n] "
while read answer
do
if [ "$answer" = "n" ]; then
echo "Terminated"
exit 0
elif [ "$answer" = "y" ]; then
break
fi
echo -n "Invalid entry. Proceed? [y/n] "
done
if [ "$GOPATH" = "" ]; then
echo "[ERROR] You need to set GOPATH environment variable!"
exit 1
fi
echo "Environment"
echo " -> GOPATH=$GOPATH"
echo " -> VERSION=$(go version)"
echo "Checking required software"
echo " -> Checking git... $(echo_if $(program_is_installed git))"
echo " -> Checking mosquitto... $(echo_if $(program_is_installed mosquitto))"
echo "Cloning/updating related repositories"
echo -n " -> examples repository... "
if [ -d "$PWD/examples" ]; then
pushd $PWD/examples >> /dev/null
git pull >> /dev/null
popd >> /dev/null
else
git clone https://github.com/cascades-fbp/examples.git >> /dev/null
fi
echo_pass
echo -n " -> wiki repository..."
if [ -d "$PWD/wiki" ]; then
pushd $PWD/wiki >> /dev/null
git pull >> /dev/null
popd >> /dev/null
else
git clone https://github.com/cascades-fbp/cascades.wiki.git wiki >> /dev/null
fi
echo_pass
echo -n " -> website repository... "
if [ -d "$PWD/website" ]; then
pushd $PWD/website >> /dev/null
git pull >> /dev/null
popd >> /dev/null
else
git clone https://github.com/cascades-io/cascades-io.github.io.git website >> /dev/null
fi
echo_pass
echo "Generating HTML docs from wiki"
./doc.sh
# echo "Creating configuration from samples"
# echo -n " -> conf/*.json... "
# cp $PWD/conf/dashboard.json.sample $PWD/conf/dashboard.json
# cp $PWD/conf/device-catalog.json.sample $PWD/conf/device-catalog.json
# cp $PWD/conf/device-gateway.json.sample $PWD/conf/device-gateway.json
# cp $PWD/conf/service-catalog.json.sample $PWD/conf/service-catalog.json
# echo_pass
# echo -n " -> conf/devices/*.json... "
# cp $PWD/conf/devices/dummy.json.sample $PWD/conf/devices/dummy.json
# cp $PWD/conf/devices/speakers.json.sample $PWD/conf/devices/speakers.json
# cp $PWD/conf/devices/system.json.sample $PWD/conf/devices/system.json
# echo_pass
# echo -n " -> conf/services/*.json... "
# cp $PWD/conf/services/mqtt-broker.json.sample $PWD/conf/services/mqtt-broker.json
# echo_pass
echo "Building programs"
./build.sh
echo "Reset library file"
rm -rf library.json
cascades library add components/
# echo -n " -> conf/services/*.json... "
# cp $PWD/conf/services/mqtt-broker.json.sample $PWD/conf/services/mqtt-broker.json
# echo_pass
echo ""
echo "Ready!"
exit 0