kuksa-dbc-feeder: add recipe and dependencies
[AGL/meta-agl-demo.git] / recipes-connectivity / kuksa-val / can-dev-helper / can-dev-helper.sh
1 #!/bin/bash
2
3 #
4 # Script to bring up CAN interface configured for the kuksa.val
5 # CAN feeder in /etc/kuksa-dbc-feeder/dbc_feeder.ini as vcan
6 # interfaces if no physical interface is present.
7 #
8
9 vcan_up() {
10     if [ -n "$1" ]; then
11         echo "Bringing up $1 as virtual CAN device"
12         ip link add dev $1 type vcan
13         ip link set up $1
14     fi
15 }
16
17 CONF=/etc/kuksa-dbc-feeder/config.ini
18
19 if [ ! -f $CONF ]; then
20     exit 0
21 fi
22
23 # Ideally the parsing would take the "[can]" section into
24 # account, but this should work for now.
25 interface=$(grep ^port= $CONF |cut -d= -f2 |tr -d '"')
26 if [ -n "$interface" ]; then
27     echo "Checking $interface"
28     if ! ifconfig $interface >/dev/null 2>&1; then
29         vcan_up $interface
30     fi
31 fi
32
33 exit 0