#! /bin/sh

# Copyright (c) 2021-2023 Qualcomm Technologies, Inc.
# All Rights Reserved.
# Confidential and Proprietary - Qualcomm Technologies, Inc.
# ETHAGENT systemd start script to start the Data Software's ethagent daemon
#! /bin/sh

sdx75=556
if [ -f /sys/devices/soc0/soc_id ]; then
  soc_id=`cat /sys/devices/soc0/soc_id`
else
  soc_id=`cat /sys/devices/system/soc/soc0/id`
fi

tlpd_cli_supported_targets () {

#for external AP uncomment below line of code
#current_target=EAP
#echo $current_target
#return 1

echo -n "Starting/Loading tlpd Client:entry " > /dev/kmsg
case "$soc_id" in
  "$sdx75")
    echo -n "support for tlpd Client Enabled" > /dev/kmsg
    current_target=NAD
    echo $current_target
    return 1
;;
esac

return 0
}

current_target=$(tlpd_cli_supported_targets)
is_target_supported=$?

if [[ $is_target_supported -eq 1 ]]
then
case "$1" in
  start)
        echo -n "Starting ethagent: " > /dev/kmsg
        /usr/bin/ethagent
        echo "done" > /dev/kmsg
        ;;
  stop)
        echo -n "Stopping ethagent: " > /dev/kmsg
    kill -9 $(pidof ethagent)
        echo "done" > /dev/kmsg
        ;;
  restart)
        $0 stop
    sleep 1
        $0 start
        ;;
    *)
        echo "Usage ethagent { start | stop | restart}" >&2
        exit 1
        ;;
esac
else
echo -n "No support for tlpd Client daemon enabled" > /dev/kmsg
fi
exit 0
