-
Notifications
You must be signed in to change notification settings - Fork 3
/
setup-wiper-service.sh
executable file
·65 lines (56 loc) · 2.57 KB
/
setup-wiper-service.sh
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
#!/bin/bash
#********************************************************************************
# Copyright (c) 2022 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License 2.0 which is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
#*******************************************************************************/
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export VSOMEIP_APPLICATION_NAME="wiper_service"
CFG="someip_wiper_service.json"
if [ -f "$SCRIPT_DIR/config/$CFG" ]; then
VSOMEIP_CONFIGURATION="$SCRIPT_DIR/config/$CFG"
else
GIT_ROOT=$(git rev-parse --show-toplevel)
if [ -n "$GIT_ROOT" ] && [ -f "$GIT_ROOT/someip2val/config/$CFG" ]; then
VSOMEIP_CONFIGURATION="$GIT_ROOT/someip2val/config/$CFG"
fi
fi
export VSOMEIP_CONFIGURATION
if [ -z "$VSOMEIP_APPLICATION_NAME" ]; then
echo "WARNING! VSOMEIP_APPLICATION_NAME not set in environment!"
fi
if [ ! -f "$VSOMEIP_CONFIGURATION" ]; then
echo "WARNING! Can't find VSOMEIP_CONFIGURATION: $VSOMEIP_CONFIGURATION"
else
echo "****************************"
echo "SOME/IP config: $VSOMEIP_CONFIGURATION"
### Replace unicast address with Hostname -I (1st record)
if grep -q "unicast" "$VSOMEIP_CONFIGURATION"; then
MY_IP="$(hostname -I | cut -d ' ' -f 1)"
echo "### Replacing uinicast: $MY_IP in VSOMEIP_CONFIGURATION"
jq --arg ip "$MY_IP" '.unicast=$ip' "$VSOMEIP_CONFIGURATION" > "$VSOMEIP_CONFIGURATION.tmp" && mv "$VSOMEIP_CONFIGURATION.tmp" "$VSOMEIP_CONFIGURATION"
echo "****************************"
fi
### Sanity checks for application name
CONFIG_APP=$(jq -r '.applications[0].name' "$VSOMEIP_CONFIGURATION")
ROUTING_APP=$(jq -r '.routing' "$VSOMEIP_CONFIGURATION")
UNICAST_APP=$(jq -r '.unicast' "$VSOMEIP_CONFIGURATION")
echo " json: { app_name: $CONFIG_APP, routinng: $ROUTING_APP, unicast: $UNICAST_APP }"
echo "****************************"
echo ""
if [ "$CONFIG_APP" != "$VSOMEIP_APPLICATION_NAME" ]; then
echo "WARNING! $VSOMEIP_CONFIGURATION has application name: $CONFIG_APP, but VSOMEIP_APPLICATION_NAME is: $VSOMEIP_APPLICATION_NAME"
fi
fi
# if running from install, export LD_LIBRARY_PATH to vsomeip libs.
[ -d "$SCRIPT_DIR/../lib" ] && export LD_LIBRARY_PATH="$SCRIPT_DIR/../lib:$LD_LIBRARY_PATH"
echo
echo "Start SomeIP Service:"
echo " ./wiper_service"