aboutsummaryrefslogtreecommitdiff
path: root/network/coturn/rc.turnserver
blob: 8e34917c602a3549b34fb09edd33a56a26a4a14f (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
42
43
#! /bin/sh

CONFIG="/etc/turnserver.conf"
. /etc/default/turnserver

coturn_start() {
    if [ ! -d $TURN_PID_PATH ]; then
      mkdir -p $TURN_PID_PATH
      chown $TURN_USER:$TURN_GROUP $TURN_PID_PATH
    fi
    if [ -x /usr/bin/turnserver ]; then
      echo "Starting turnserver daemon:  /usr/bin/turnserver"
      su -l -c "/usr/bin/turnserver -o -c $CONFIG --pidfile $TURN_PID_PATH/turnserver.pid" $TURN_USER
    fi
}

coturn_stop() {
    echo "Stopping turnserver daemon:  /usr/bin/turnserver"
    kill $(cat $TURN_PID_PATH/turnserver.pid)
    rm -f $TURN_PID_PATH/turnserver.pid
}

coturn_restart() {
    coturn_stop
    sleep 1
    coturn_start
}

case "$1" in
'start')
    coturn_start
    ;;
'stop')
    coturn_stop
    ;;
'restart')
    coturn_restart
    ;;
*)
    echo "usage $0 start|stop|restart"
esac

exit 0