码迷,mamicode.com
首页 > 其他好文 > 详细

在centos中添加freeswitch服务开机自动运行

时间:2014-09-10 19:06:40      阅读:476      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   os   io   ar   for   art   

新建 /etc/init.d/freeswitch 脚本,脚本内容如下: 

#! /bin/sh
#
# freeswitch:       Starts the freeswitch Daemon
#
# chkconfig: 345 96 02
# processname: freeswitch
# description: Freeswitch fedora init script # config:
# Author: gled

# Source function library.
. /etc/init.d/functions
. /etc/sysconfig/network

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/freeswitch/bin
DESC="FreeSwitch Voice Switching System"
NAME=freeswitch
DAEMON=/usr/local/freeswitch/bin/$NAME
DAEMON_ARGS="-nc"
PIDFILE=/usr/local/freeswitch/log/$NAME.pid

## SECURITY NOTE: To run as non-root, create a new user for FreeSWITCH and set these variables (FS_GROUP is optional).
##
#FS_USER=freeswitch
#FS_GROUP=freeswitch

do_setlimits() {
        ulimit -c unlimited
        ulimit -d unlimited
        ulimit -f unlimited
        ulimit -i unlimited
        ulimit -n 999999
        ulimit -q unlimited
        ulimit -u unlimited
        ulimit -v unlimited
        ulimit -x unlimited
        ulimit -s 244
        ulimit -l unlimited
        return 0
}

base=${0##*/}

do_start() {
        if [ -n "${FS_USER}" ]; then
                DAEMON_ARGS="${DAEMON_ARGS} -u ${FS_USER}"
        fi

        if [ -n "${FS_GROUP}" ]; then
                DAEMON_ARGS="${DAEMON_ARGS} -g ${FS_GROUP}"
        fi

        do_setlimits
        $DAEMON $DAEMON_ARGS
        RETVAL=$?
        if [ $RETVAL = 0 ]; then
                success $"$base startup"
        else
                failure $"$base startup"
        fi
        echo
        return $RETVAL
}

do_stop() {
        $DAEMON -stop
        RETVAL=$?
        [ $RETVAL = 0 ] && success $"$base shutdown" || failure $"$base shutdown"
        rm -f $LOCKFILE
        echo
        return $RETVAL
}

# See how we were called.
case "$1" in
  start)
        do_start
        ;;
  stop)
        do_stop
        ;;
  restart)
        do_stop
        echo "Waiting for daemon to exit..."
        sleep 5
        do_start
        ;;
  *)
        echo $"Usage: $0 {start|stop}"
        exit 2
        ;;
esac

exit $RETVAL

增加脚本可执行权限:

chmod +x /etc/init.d/freeswitch

添加开机启动服务:

chkconfig --add freeswitch 

 

以上,全部。ps,如果发现fs不通,可能是由于防火墙的原因,粗暴的方式请关闭防火墙。

在centos中添加freeswitch服务开机自动运行

标签:des   style   blog   color   os   io   ar   for   art   

原文地址:http://www.cnblogs.com/kennyhr/p/3964854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!