FreeSWITCH及VOIP,Openser,电话机器人等产品中文技术资讯、交流、沟通、培训、咨询、服务一体化网络。QQ群:293697898
在这里谢谢QQ 293697898 群里:ivr@qq.com 和蓝猫
这两天遇到一个问题,把freeswitch/build/freeswitc.redhat脚本在centos 6.8 mini 下调用不成功。主要情况为: /etc/init.d/freeswitch start 可以成功,但是service freeswitch start不成功。
在咨询QQ群群友时,以上俩兄弟给了一篇博客,写的比较明白,在调用service freeswitch start时,环境变量和/etc/init.d/freeswitch start时不一样了,感觉很有道理的样子,于是就ldd /usr/local/freeswitch/bin/freeswitch后,把相关的路径径都加进去了,于是乎就成功了,脚本样例:
```
#!/bin/bash
#
# /etc/rc.d/init.d/freeswitch
#
# The FreeSwitch Open Source Voice Platform
#
# chkconfig: 345 89 14
# description: Starts and stops the freeswitch server daemon
# processname: freeswitch
# config: /usr/local/freeswitch/conf/freeswitch.conf
# pidfile: /usr/local/freeswitch/run/freeswitch.pid
#
# Source function library.
. /etc/init.d/functions
PROG_NAME=freeswitch
PID_FILE=${PID_FILE-/var/run/freeswitch/freeswitch.pid}
#FS_USER=${FS_USER-freeswitch}
FS_USER=${FS_USER-root}
FS_FILE=${FS_FILE-/usr/local/freeswitch/bin/freeswitch}
FS_HOME=${FS_HOME-/usr/local/freeswitch}
LOCK_FILE=/var/lock/subsys/freeswitch
FREESWITCH_ARGS="-nc"
RETVAL=0
export PATH=$PATH:$FS_HOME/bin:/usr/sbin:/usr/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$FS_HOME/lib:$FS_HOME/mod:/lib64:/usr/lib64:/usr/local/pgsql/lib
export LD_LIBRARY_PATH
# Source usr/localions file
if [ -f /etc/sysconfig/freeswitch ]; then
. /etc/sysconfig/freeswitch
fi
# <define any local shell functions used by the code that follows>
start() {
echo -n "Starting $PROG_NAME: "
if [ -e $LOCK_FILE ]; then
if [ -e $PID_FILE ] && [ -e /proc/`cat $PID_FILE` ]; then
echo
echo -n $"$PROG_NAME is already running.";
failure $"$PROG_NAME is already running.";
echo
return 1
fi
fi
cd $FS_HOME
echo
daemon --user $FS_USER --pidfile $PID_FILE "$FS_FILE $FREESWITCH_ARGS >/dev/null 2>&1"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE;
echo
return $RETVAL
}
stop() {
echo -n "Shutting down $PROG_NAME: "
if [ ! -e $LOCK_FILE ]; then
echo
echo -n $"cannot stop $PROG_NAME: $PROG_NAME is not running."
failure $"cannot stop $PROG_NAME: $PROG_NAME is not running."
echo
return 1;
fi
cd $FS_HOME
$FS_FILE -stop > /dev/null 2>&1
killproc $PROG_NAME
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE;
return $RETVAL
}
rhstatus() {
status $PROG_NAME;
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $PROG_NAME
RETVAL=$?
;;
restart)
stop
start
;;
reload)
# <cause the service configuration to be reread, either with
# kill -HUP or by restarting the daemons, in a manner similar
# to restart above>
;;
condrestart)
[ -f $PID_FILE ] && restart || :
;;
*)
echo "Usage: $PROG_NAME {start|stop|status|reload|restart}"
exit 1
;;
esac
exit $RETVAL
```