summaryrefslogtreecommitdiff
path: root/recipes-connectivity/bluez/bluez5/bt-pan/init
blob: f8ac23f892b8b3433011d58f75ca8fa7a433611a (plain)
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
#!/bin/bash

NAME=bt-pan
SERVER=/usr/libexec/bluetooth/${NAME}
PYTHON=$(readlink -f /usr/bin/python)
BRIDGE=pan0
DNAME="${NAME}.${BRIDGE}"
PIDFILE="/run/${DNAME}.pid"

ENABLED=yes
[ -f /etc/default/$NAME ] && . /etc/default/$NAME

if [ "$ENABLED" != "yes" ]; then
  echo "$NAME: disabled in /etc/default"
  exit
fi

case $1 in
  start)
    ifup $BRIDGE
    echo "Starting ${DNAME}"
    /usr/sbin/start-stop-daemon -S -p ${PIDFILE} -x ${PYTHON} -b -- ${SERVER} ${PANOPTS} server $BRIDGE
    ;;

  stop)
    /usr/sbin/start-stop-daemon -K -p ${PIDFILE} -x ${PYTHON}
    echo "Stopping ${DNAME}"
    ;;

  restart)
    $0 stop
    $0 start
    ;;

  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 2
    ;;
esac