#!/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 # # # join two path names (avoid things like //foo or /foo/../bar) join() { if [ "$1" = "/" ] then echo "/$2" else if [ "$2" = ".." ] then echo $(fqn $(dirname $1)) else echo "$1/$2" fi fi } # fqn : fully qualified name # (e.g. realpath, but portable & works even if path doesn't exist) fqn() { if [ "$1" = "." ] then echo $(pwd) else if [ "$1" = "/" ] then echo "/" else if [ -e $1 ] then echo $(join $(cd $(dirname $1); pwd) $(basename $1)) else echo $(join $(fqn $(dirname $1)) $(basename $1)) fi fi fi } SELF_DIR=$(dirname $(fqn "$0")) SETUP_GEN=$SELF_DIR/setup_gen # Ulf's kitchen sink setup utility TOP_DIR=$(dirname $SELF_DIR) usage() { cat < /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 (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}" ] then STRIP_TARGET_DIR=$(echo ${TARGET_DIR} | sed "s|^${PREFIX_STRIP}||") STRIP_LOG_DIR=$(echo ${LOG_DIR} | sed "s|^${PREFIX_STRIP}||") else STRIP_TARGET_DIR=${TARGET_DIR} STRIP_LOG_DIR=${LOG_DIR} 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" \ -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 install -m 0755 -d ${TARGET_DIR}/priv/keys install -m 0755 -d ${TARGET_DIR}/priv/credentials install -m 0644 ${ROOT_CERT} ${TARGET_DIR}/priv/certificates/root_cert.crt install -m 0644 ${DEVICE_CERT} ${TARGET_DIR}/priv/certificates/device_cert.crt 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 $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}" echo echo "Start: ${TARGET_DIR}/rvi_ctl -c start" echo "Attach started RVI: ${TARGET_DIR}/rvi_ctl attach" echo "Stop: ${TARGET_DIR}/rvi_ctl stop" echo "Start console mode: ${TARGET_DIR}/rvi_ctl -c console" echo exit 0