#! /bin/sh
#
#  Copyright (c) 2015 Qualcomm Technologies, Inc.
#  All Rights Reserved.
#  Confidential and Proprietary - Qualcomm Technologies, Inc.
#
# psm init.d script to start the psm daemon
#
# Configuration path for PSM Daemon can be changed at this script
#
# Usage for psmd: To change config files path to /opt/data
# psmd -c /opt/data

set -e

case "$1" in
  start)
        echo -n "Starting psmd: " > /dev/kmsg
        start-stop-daemon -S -b -a psmd -- -c /data/psm
        if [ -e "/data/psm/enable_auto_test" ]; then
            start-stop-daemon -S -b -a psm_test
        fi
        echo "done" > /dev/kmsg
        ;;
  stop)
        echo -n "Stopping psmd: " > /dev/kmsg
        start-stop-daemon -K -n psmd
        if [ -e "/data/psm/enable_auto_test" ]; then
            start-stop-daemon -K -n psm_test
        fi
        echo "done" > /dev/kmsg
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  *)
        echo "Usage start_psmd { start | stop | restart}" >&2
        exit 1
        ;;
esac

exit 0
