summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMagnus Feuer <mfeuer@jaguarlandrover.com>2015-11-18 15:14:10 -0800
committerMagnus Feuer <mfeuer@jaguarlandrover.com>2015-11-18 15:14:10 -0800
commit227e90e0048fcc51517e2d585970f4acf9f3c273 (patch)
tree33772a8f462480873e4c8a832f2e79821843b654 /scripts
parent2443d913fc6c5437120437c8aa1f3009675945cd (diff)
downloadrvi_core-227e90e0048fcc51517e2d585970f4acf9f3c273.tar.gz
Added missing files.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/start_rvi.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/scripts/start_rvi.sh b/scripts/start_rvi.sh
new file mode 100644
index 0000000..6683c52
--- /dev/null
+++ b/scripts/start_rvi.sh
@@ -0,0 +1,71 @@
+#!/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 a correct configuration and launch an RVI release node.
+# If a UUID file has not been created, it will be done at this time.
+#
+
+SELF_DIR=$(dirname $(readlink -f "$0"))
+CONFIG_DIR=/etc/opt/rvi
+BIN_DIR=/opt/rvi
+
+usage() {
+ echo "Usage: $0 -c config_file"
+ echo " -c config_file Specify the configuration "
+ echo "Configuration data is read from the configuration file."
+ exit 1
+}
+
+while getopts "c:" o; do
+ case "${o}" in
+ c)
+ CONFIG_FILE=${OPTARG}
+ ;;
+ *)
+ usage
+ ;;
+ esac
+done
+
+if [ -z "${CONFIG_FILE}" ] ; then
+ echo "Missing -c flag"
+ usage
+fi
+
+# Check if we have a uuid file.
+if [ ! -f ${CONFIG_DIR}/device_id ]
+then
+ echo "Creating device ID in ${CONFIG_DIR}/device_id"
+ cat /proc/sys/kernel/random/uuid > ${CONFIG_DIR}/device_id
+fi
+
+#
+# Generate a config file that will end up as
+# /tmp/rvi/sys.config
+#
+(
+ cd /tmp/
+ rm -rf rvi
+ export ERL_LIBS=${BIN_DIR}/setup:${BIN_DIR}/lib/
+ ${BIN_DIR}/setup_gen rvi $CONFIG_FILE rvi
+)
+
+# Did we succeed with config generation?
+if [ "$?" != "0" ]
+then
+ # Nope
+ exit "$?"
+fi
+
+# Copy created config file to /etc/opt/rvi/sys.config,
+# which is symlinked to by /opt/rvi/sys.config
+cp /tmp/rvi/sys.config /etc/opt/rvi/sys.config
+
+exec /opt/rvi/bin/rvi start