summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorUlf Wiger <ulf@feuerlabs.com>2016-02-12 11:15:59 -0800
committerUlf Wiger <ulf@feuerlabs.com>2016-02-12 11:15:59 -0800
commit030a31cd8717e8fc3376c42dd4bd088b4a117797 (patch)
tree0ef4ab150a50438023f97ed96d17260dbd6b5aca /scripts
parent3b8f8579451a37e2c45fc4d2adfb439d72942a13 (diff)
downloadrvi_core-030a31cd8717e8fc3376c42dd4bd088b4a117797.tar.gz
Adapt test suite to new scripts, scripts more flexible, bt not default
- rvi_install & rvi_ctl adapted so they can be run from different directories - ensure that RVI_LOGDIR is respected consistently - RVI_RUNDIR allows for specifying where the boot scripts are stored - bt apps excluded by default, can be put back in through config if needed
Diffstat (limited to 'scripts')
-rw-r--r--scripts/rvi_ctl.template25
-rwxr-xr-xscripts/rvi_install79
2 files changed, 62 insertions, 42 deletions
diff --git a/scripts/rvi_ctl.template b/scripts/rvi_ctl.template
index dc8dd9e..c6c8875 100644
--- a/scripts/rvi_ctl.template
+++ b/scripts/rvi_ctl.template
@@ -2,7 +2,7 @@
#
#
-# Mozilla Public License, version 2.0. The full text 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/
#
#
@@ -20,7 +20,7 @@ echo ${ERL:=erl} > /dev/null
usage() {
- echo "Usage: $0 -d config_dir [-c config_file] -l log_dir \\"
+ echo "Usage: $0 -d config_dir [-c config_file] -l log_dir \\"
echo " start|stop|console|attach|ping"
echo
echo " -c config_file Configuration file to launch rvi node with."
@@ -32,7 +32,7 @@ usage() {
echo " stop Stop an rvi node previously started with 'start'."
echo
echo " console Start an rvi in foreground mode."
- echo
+ echo
echo " attach Attach to an rvi node previously started with 'start'."
echo
echo "Environennt variables. Default value in paranthesis::"
@@ -42,7 +42,7 @@ usage() {
}
CONFIG_FILE=""
-SNAME=rvi
+SNAME="__RVI_NAME__"
COOKIE=rvi_cookie
while getopts "c:" o; do
case "${o}" in
@@ -93,15 +93,21 @@ then
echo "${CONFIG_FILE} cannot be opened for reading."
usage
fi
- #
+ #
# Generate a config file that will end up as
# /tmp/rvi/[cfg]/sys.config
#
(
- rm -rf ${RUNDIR}
+ if [ -z "${RVI_RUNDIR}" ]
+ then
+ RUNDIR="/tmp/rvi_${$}"
+ rm -rf ${RUNDIR}
+ else
+ RUNDIR=${RVI_RUNDIR}
+ fi
install -d --mode=0755 ${RUNDIR}
cd ${RUNDIR}
- ${RVI_BINDIR}/setup_gen rvi ${CONFIG_FILE} rvi
+ RVI_LOGDIR="${RVI_LOGDIR}" ${RVI_BINDIR}/setup_gen rvi ${CONFIG_FILE} rvi
)
# Did we succeed with config generation?
@@ -133,9 +139,8 @@ case "${CMD}" in
exec ${RBI_BINDIR}/nodetool -sname ${SNAME} -setcookie ${COOKIE} ping
;;
- attach)
+ attach)
exec to_erl ${RUNDIR}
;;
-esac
-
+esac
diff --git a/scripts/rvi_install b/scripts/rvi_install
index ac128e5..0bcb045 100755
--- a/scripts/rvi_install
+++ b/scripts/rvi_install
@@ -3,7 +3,7 @@
# 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, version 2.0. The full text of the
# Mozilla Public License is at https://www.mozilla.org/MPL/2.0/
#
@@ -12,36 +12,45 @@
#
#
-SELF_DIR=$(dirname $(readlink -f "$0"))
+# fqn : fully qualified name (e.g. realpath, but portable)
+fqn()
+{
+ echo $(cd $(dirname $1); pwd)/$(basename $1)
+}
+
+SELF_DIR=$(dirname $(fqn "$0"))
SETUP_GEN=$SELF_DIR/setup_gen # Ulf's kitchen sink setup utility
+TOP_DIR=$(dirname $SELF_DIR)
usage() {
cat <<EOF
Usage:
$0 -r root_cert -d device_cert -c credentials \\
[-l log_dir ] [-s prefix_strip] target_dir
-
+
Install a built RVI system into a target directory
-
+
NOTE: The last component of 'taget_dir' must be named 'rvi_core'
Example: /opt/rvi_core
-
+
-l log_dir - Log directory. Default: ${target_dir}/log.
-s prefix_strip - See below. Default: nil.
-r root_cert - The certificate to validate received X509 device
certificates and credentials.
-
+
-k device_key - The PEM file containing the device key pair used
to sign traff
--d device_cert - Certificate to use when authenticating self toward
+-d device_cert - Certificate to use when authenticating self toward
remote nodes.
-c credentials - Credentials to present to remote nodes. Can be specified
multiple times
-
+
+-n node_name - Erlang node name. Default: rvi
+
The created node can be started with: 'target'/rvi_ctl
The RVI installation will rely on a separate erlang install
to run.
@@ -54,7 +63,7 @@ PREFIX STRIPPING
If, for example, 'target_dir' is './build/root/usr/bin', and
'prefix_strip' is './build/root', all internal paths will
reference '/usr/bin'.
-
+
ROOT CERTIFICATE
The root certificate is used to validate remote TLS connections and
device certificates. It is normally generated once and shared across
@@ -142,14 +151,14 @@ EXAMPLE INSTALLATION
WARNING: This example installation will provide no protection
against unauthenticated nodes, unauthorized calls, or
- eavesdropping. Do not use in any externally facing
+ eavesdropping. Do not use in any externally facing
environment.
EOF
- exit 1
+ exit 1
}
-if [ "${#}" = "0" ]
+if [ "${#}" = "0" ]
then
usage
fi
@@ -160,23 +169,24 @@ ROOT_CERT=""
DEVICE_CERT=""
DEVICE_KEY=""
DEVICE_CRED=""
+NAME="rvi"
-while getopts "r:d:c:k:s:l:" o; do
+while getopts "r:d:c:k:s:l:n:" o; do
case "${o}" in
r)
- ROOT_CERT=${OPTARG}
+ ROOT_CERT=$(fqn ${OPTARG})
;;
d)
- DEVICE_CERT=${OPTARG}
+ DEVICE_CERT=$(fqn ${OPTARG})
;;
c)
- DEVICE_CRED="${DEVICE_CRED} ${OPTARG}"
+ DEVICE_CRED="${DEVICE_CRED} $(fqn ${OPTARG})"
;;
k)
- DEVICE_KEY=${OPTARG}
+ DEVICE_KEY=$(fqn ${OPTARG})
;;
l)
@@ -186,7 +196,9 @@ while getopts "r:d:c:k:s:l:" o; do
s)
PREFIX_STRIP=${OPTARG}
;;
-
+ n)
+ NAME=${OPTARG}
+ ;;
*)
usage
;;
@@ -213,7 +225,7 @@ then
echo " Example: $(dirname ${TARGET_DIR})/rvi_core"
echo " Run ${0} with no arguments for usage."
exit 255
-fi
+fi
# Check that we can read the root cert
if [ -z "${ROOT_CERT}" -o ! -r "${ROOT_CERT}" ]
@@ -267,19 +279,22 @@ then
fi
# Wipe old target dir.
-rm -rf ${TARGET_DIR} > /dev/null 2>&1
+rm -rf ${TARGET_DIR} > /dev/null 2>&1
# Create log dirs
install -m 0755 -d ${TARGET_DIR}
install -m 0755 -d ${LOG_DIR}
+TARGET_DIR=$(fqn $TARGET_DIR)
+LOG_DIR=$(fqn $LOG_DIR)
+
# Copy over the relevant files to the target
-FILE_SET=$(find ebin components deps -name ebin -o -name priv)
-tar cf - ${FILE_SET} | (cd ${TARGET_DIR} ; tar xf - )
+(cd $TOP_DIR; FILE_SET=$(find priv ebin components deps -name ebin -o -name priv);
+tar cf - ${FILE_SET} | (cd ${TARGET_DIR} ; tar xf - ))
# If we have a prefix strip (for build systems not using
# chroot), apply it to paths.
-if [ -s "${PREFIX_STRIP}" ]
+if [ -s "${PREFIX_STRIP}" ]
then
STRIP_TARGET_DIR=$(echo ${TARGET_DIR} | sed "s|^${PREFIX_STRIP}||")
STRIP_LOG_DIR=$(echo ${LOG_DIR} | sed "s|^${PREFIX_STRIP}||")
@@ -290,7 +305,8 @@ fi
# Patch rvi_ctl.template to set its ERL_LIBS path correctly.
sed -e "s|__RVI_BINDIR__|${STRIP_TARGET_DIR}|g" \
- -e "s|__RVI_LOGDIR__|${STRIP_LOG_DIR}|g" < scripts/rvi_ctl.template > /tmp/rvi_ctl
+ -e "s|__RVI_LOGDIR__|${STRIP_LOG_DIR}|g" \
+ -e "s|__RVI_NAME__|${NAME}|g" < $TOP_DIR/scripts/rvi_ctl.template > /tmp/rvi_ctl
# Install all relevant scripts.
install -m 0755 -d ${TARGET_DIR}/priv/certificates
@@ -302,13 +318,13 @@ install -m 0644 ${DEVICE_KEY} ${TARGET_DIR}/priv/keys/device_key.pem
install -m 0644 ${DEVICE_CRED} ${TARGET_DIR}/priv/credentials
install -m 0755 /tmp/rvi_ctl ${TARGET_DIR}
rm /tmp/rvi_ctl
-install -m 0755 scripts/setup_gen ${TARGET_DIR}
-install -m 0755 rel/files/nodetool ${TARGET_DIR}
-install -m 0755 python/rvi_service.py ${TARGET_DIR}/rvi_service
-install -m 0755 python/rvi_call.py ${TARGET_DIR}/rvi_call
-install -m 0644 python/rvilib.py ${TARGET_DIR}
-install -m 0755 python/rvi_get_services.py ${TARGET_DIR}/rvi_get_services
-install -m 0755 -D priv/config/rvi_common.config ${TARGET_DIR}/priv/config/rvi_common.config
+install -m 0755 $TOP_DIR/scripts/setup_gen ${TARGET_DIR}
+install -m 0755 $TOP_DIR/rel/files/nodetool ${TARGET_DIR}
+install -m 0755 $TOP_DIR/python/rvi_service.py ${TARGET_DIR}/rvi_service
+install -m 0755 $TOP_DIR/python/rvi_call.py ${TARGET_DIR}/rvi_call
+install -m 0644 $TOP_DIR/python/rvilib.py ${TARGET_DIR}
+install -m 0755 $TOP_DIR/python/rvi_get_services.py ${TARGET_DIR}/rvi_get_services
+install -m 0755 -D $TOP_DIR/priv/config/rvi_common.config ${TARGET_DIR}/priv/config/rvi_common.config
echo "RVI binary files installed under ${TARGET_DIR}"
echo "RVI will log to ${LOG_DIR}"
@@ -319,4 +335,3 @@ echo "Stop: ${TARGET_DIR}/rvi_ctl stop"
echo "Start console mode: ${TARGET_DIR}/rvi_ctl -c <config_file> console"
echo
exit 0
-