summaryrefslogtreecommitdiffstats
path: root/network/coturn/rc.turnserver
diff options
context:
space:
mode:
Diffstat (limited to 'network/coturn/rc.turnserver')
-rw-r--r--network/coturn/rc.turnserver43
1 files changed, 43 insertions, 0 deletions
diff --git a/network/coturn/rc.turnserver b/network/coturn/rc.turnserver
new file mode 100644
index 0000000000..8e34917c60
--- /dev/null
+++ b/network/coturn/rc.turnserver
@@ -0,0 +1,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