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
|
#!/bin/sh
#
# Copyright (C) 2014, Jaguar Land Rover
#
# This program is licensed under the terms and conditions of the
# Mozilla Public License, version 2.0. The full text of the
# Mozilla Public License is at https://www.mozilla.org/MPL/2.0/
#
#
# Setup an RVI release with a configuration file.
#
# This script will setup a directory with with the same name
# as the release name. The script uses Ulf Wiger's setup application
# (github.com/Feuerlabs/setup) to generate the release.
#
# With the -d argument, a developer release will be built with
# only
#
# Once setup, the RVI node can be started with ./rvi_node <release_na,e?
#
# Please note that the generated release will depend on the built
#
# In order to create a standalone release, use create_rvi_release.sh
#
SELF_DIR=$(dirname $(readlink -f "$0"))
SETUP_GEN=$SELF_DIR/setup_gen # Ulf's kitchen sink setup utility
usage() {
echo "Usage: $0 [-d] -n node_name -c config_file"
echo " -n node_name Specify the name of the rvi node to setup"
echo
echo " -c config_file Specifies the setup config file to use when setting "
echo " up the node"
echo
echo " -d Create a development release. See below."
echo
echo "The generated node will be created in a subdirectory with the same"
echo "name as the node name."
echo
echo "The created node can be started with: $SELF_DIR/rvi_node -n node_name"
echo
echo "If the node was created with the -d flag, you need to start"
echo "the node with $SELF_DIR/rvi_node -d -n node_name"
echo
echo "Configuration file examples can be found in hvac_demo/vehicle.config"
echo
echo "The -d flag creates a development release that uses the erlang "
echo "binaries found in ebin/ and deps/*/ebin. This means that new builds,"
echo "created by make, can be run directly through "
echo "$SELF_DIR/rvi_node -n node_name without having to run ./setup_rvi_node.sh ."
echo
echo "If the -d flag is omitted, the release will be self-contained in the "
echo "newly created subdirectory rel/[node_name]."
echo "This directory, containing a standard erlang reltool release, "
echo "including the erlang runtime system, can be copied as a stand alone"
echo "system to a destination node."
echo
echo "Configuration file examples can be found in hvac_demo/vehicle.config"
exit 1
}
build_type=rel
while getopts "dn:c:" o; do
case "${o}" in
n)
NODE_NAME=${OPTARG}
;;
c)
CONFIG_NAME=${OPTARG}
;;
d)
build_type=dev
;;
*)
usage
;;
esac
done
if [ -z "${NODE_NAME}" ] ; then
echo "Missing -n flag"
usage
fi
if [ -z "${CONFIG_NAME}" ] ; then
echo "Missing -c flag"
usage
fi
export ERL_LIBS=$PWD/components:$PWD/deps:$ERL_LIBS:$PWD
echo "Setting up node $NODE_NAME."
rm -rf $NODE_NAME
$SETUP_GEN $NODE_NAME $CONFIG_NAME $NODE_NAME
if [ "${build_type}" = "dev" ]
then
echo "RVI Node $NODE_NAME has been setup."
echo "Launch with $SELF_DIR/rvi_node.sh -n $NODE_NAME"
exit
else
echo "Building stand alone release for $NODE_NAME"
# Copy the newly created config file.
rm -rf rel/$NODE_NAME
cp $NODE_NAME/sys.config rel/files/sys.config
./rebar generate
# Rename the release after the node name
if [ ${NODE_NAME} != "rvi" ]
then
mv rel/rvi rel/$NODE_NAME
fi
echo "Stand alone release for $NODE_NAME created under project "
echo "root directory's ./rel/$NODE_NAME."
echo
echo "Start: ./rel/$NODE_NAME/bin/rvi start"
echo "Attach console: ./rel/$NODE_NAME/bin/rvi attach"
echo "Stop: ./rel/$NODE_NAME/bin/rvi stop"
echo "Start console mode: ./rel/$NODE_NAME/bin/rvi console"
echo
echo "Start dev mode: ./rvi_node.sh -n $NODE_NAME"
echo
echo "./rel/$NODE_NAME can be copied and installed on its destination host."
fi
exit 0
|