diff --git a/el/rtpengine.init b/el/rtpengine.init index c60828277..b5b8ca394 100644 --- a/el/rtpengine.init +++ b/el/rtpengine.init @@ -31,24 +31,45 @@ rtpengine=/usr/sbin/rtpengine prog=rtpengine pidfile=${PIDFILE-/var/run/rtpengine.pid} lockfile=${LOCKFILE-/var/lock/subsys/rtpengine} +configfile=${CONFIG_FILE-/etc/rtpengine/rtpengine.conf} cachefile=/var/lib/ngcp-rtpengine/rtpengine.cfg PIDFILE=${pidfile} RETVAL=0 +OPTS="" build_opts() { # kernel table - shopt -s nocasematch - RPMS=$(rpm -qa | grep rtpengine-kernel) - if [[ "$KERNEL" == "yes" && -n "$TABLE" && -n "$RPMS" ]];then - MODULE=1 - OPTS=" --table=$TABLE" + MODULE=0 + # variable from sysconfig is prefer then config + if [[ -n "$TABLE" ]];then + OPTS+=" --table=$TABLE" + if [[ $TABLE -ge 0 ]];then + MODULE=1 + fi else - MODULE=0 - OPTS=" --table=-1" - fi + # configfile exists? + if [ ! -f $configfile ];then + echo "Error: $configfile not present" + exit -1 + fi + + # get table variable from config + table="$(grep -Ei '^table' $configfile|cut -d\ -f3)" + if [ -z $table ];then + table="$(grep -Ei '^table' $configfile|cut -d= -f3)" + fi - [[ "$FALLBACK" != "yes" ]] && OPTS+=" --no-fallback" - shopt -u nocasematch + # error if directive is not presented in config + if [ -z $table ];then + echo "Error: directive table= is not present in $configfile" + exit -1 + fi + + # enable iptables module if derective set and positive + if [[ $table -ge 0 ]];then + MODULE=1 + fi + fi # interfaces if [[ -n "$RTP_IP" ]];then @@ -60,6 +81,7 @@ build_opts() { # options [[ "$FORK" == "no" ]] && OPTS+=" --foreground" [[ "$LOG_STDERR" == "yes" ]] && OPTS+=" --log-stderr" + [[ "$FALLBACK" != "yes" ]] && OPTS+=" --no-fallback" [ -z "$CONFIG_FILE" ] || OPTS+=" --config-file=$CONFIG_FILE" [ -z "$CONFIG_SECTION" ] || OPTS+=" --config-section=$CONFIG_SECTION" [ -z "$ADDRESS" ] || OPTS+=" --interface=$ADDRESS" diff --git a/el/rtpengine.sysconfig b/el/rtpengine.sysconfig index d01092ad2..459a1573c 100644 --- a/el/rtpengine.sysconfig +++ b/el/rtpengine.sysconfig @@ -3,7 +3,6 @@ CONFIG_FILE=/etc/rtpengine/rtpengine.conf # main config file PIDFILE=/var/run/ngcp-rtpengine-daemon.pid # pid -KERNEL=yes # "yes" enable in-kernel forwarding, "no" disables TABLE=0 # iptables table for in-kernel forwarding rules. Ignored if "KERNEL=no" FALLBACK=yes # "yes" enables fallback to userspace forwarding only. RTP_IP[0]=127.0.0.1 # Local IPv4/6 address for RTP. The format of the value is [NAME/]IP[!IP].