SlackBuildsOrg/network/coturn/rc.turnserver
Dave Woodfall 4bd762f7d0
network/coturn: Added (open source TURN and STUN Server).
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
2020-04-19 10:52:30 +07:00

43 lines
825 B
Bash

#! /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