From 5a57c7534341f549014c5f3f782d27acd50322ee Mon Sep 17 00:00:00 2001 From: k anderson Date: Fri, 10 Jun 2016 06:25:23 -0700 Subject: [PATCH] add kamailio init.d script and update dbtext/trusted for 4.4 --- kamailio/dbtext/trusted | 2 +- kamailio/dbtext/version | 2 +- system/init.d/kazoo-kamailio.redhat | 125 ++++++++++++++++++++++++++++ 3 files changed, 127 insertions(+), 2 deletions(-) create mode 100755 system/init.d/kazoo-kamailio.redhat diff --git a/kamailio/dbtext/trusted b/kamailio/dbtext/trusted index 4ff5902..132a345 100644 --- a/kamailio/dbtext/trusted +++ b/kamailio/dbtext/trusted @@ -1 +1 @@ -id(int,auto) src_ip(string) proto(string) from_pattern(string,null) tag(string,null) +id(int,auto) src_ip(string) proto(string) from_pattern(string,null) ruri_pattern(string,null) tag(string,null) priority(int) diff --git a/kamailio/dbtext/version b/kamailio/dbtext/version index 2333e73..945dffb 100644 --- a/kamailio/dbtext/version +++ b/kamailio/dbtext/version @@ -51,7 +51,7 @@ silo:7 sip_trace:3 speed_dial:2 subscriber:6 -trusted:5 +trusted:6 uacreg:1 uid_credentials:7 uid_domain:2 diff --git a/system/init.d/kazoo-kamailio.redhat b/system/init.d/kazoo-kamailio.redhat new file mode 100755 index 0000000..6cf9dfe --- /dev/null +++ b/system/init.d/kazoo-kamailio.redhat @@ -0,0 +1,125 @@ +#!/bin/bash +# +# Startup script for Kamailio +# +# chkconfig: 345 85 15 +# description: Kamailio is a fast, reliable and flexible SIP Server. +# processname: kamailio +# pidfile: /var/run/kamailio.pid +# config: /etc/kamailio/kamailio.cfg +# +# Source function library. +. /etc/rc.d/init.d/functions + +KAM=/usr/sbin/kamailio +PROG=kamailio +PID_FILE=/var/run/kamailio.pid +LOCK_FILE=/var/lock/subsys/kamailio +RETVAL=0 +DEFAULTS=/etc/default/kamailio +RUN_KAMAILIO=no +CFG_FILE=/etc/kazoo/kamailio/kamailio.cfg + +# Do not start kamailio if fork=no is set in the config file +# otherwise the boot process will just stop +check_fork () +{ + if grep -q "^[[:space:]]*fork[[:space:]]*=[[:space:]]*no.*" $CFG_FILE; then + echo "Not starting $DESC: fork=no specified in config file; run /etc/init.d/kamailio debug instead" + exit 1 + fi +} + +check_kamailio_config () +{ + # Check if kamailio configuration is valid before starting the server + out=$($KAM -c 2>&1 > /dev/null) + retcode=$? + if [ "$retcode" != '0' ]; then + echo "Not starting $DESC: invalid configuration file!" + echo -e "\n$out\n" + exit 1 + fi +} + + +start() { + check_kamailio_config + if [ "$1" != "debug" ]; then + check_fork + fi + echo -n $"Starting $PROG: " + daemon $KAM $OPTIONS >/dev/null 2>/dev/null + RETVAL=$? + echo + [ $RETVAL = 0 ] && touch $LOCK_FILE && success + return $RETVAL +} + +stop() { + echo -n $"Stopping $PROG: " + killproc $KAM + RETVAL=$? + echo + [ $RETVAL = 0 ] && rm -f $LOCK_FILE $PID_FILE +} + +# Load startup options if available +if [ -f $DEFAULTS ]; then + . $DEFAULTS || true +fi + +if [ "$RUN_KAMAILIO" != "yes" ]; then + echo "Kamailio not yet configured. Edit /etc/default/kamailio first." + exit 0 +fi + +SHM_MEMORY=$((`echo $SHM_MEMORY | sed -e 's/[^0-9]//g'`)) +PKG_MEMORY=$((`echo $PKG_MEMORY | sed -e 's/[^0-9]//g'`)) +[ -z "$USER" ] && USER=kamailio +[ -z "$GROUP" ] && GROUP=kamailio +[ $SHM_MEMORY -le 0 ] && SHM_MEMORY=64 +[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=8 + +if test "$DUMP_CORE" = "yes" ; then + # set proper ulimit + ulimit -c unlimited + + # directory for the core dump files + # COREDIR=/home/corefiles + # [ -d $COREDIR ] || mkdir $COREDIR + # chmod 777 $COREDIR + # echo "$COREDIR/core.%e.sig%s.%p" > /proc/sys/kernel/core_pattern +fi + +OPTIONS="-P $PID_FILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP $EXTRA_OPTIONS" + + +# See how we were called. +case "$1" in + start|debug) + start + ;; + stop) + stop + ;; + status) + status $KAM + RETVAL=$? + ;; + restart) + stop + start + ;; + condrestart) + if [ -f $PID_FILE ] ; then + stop + start + fi + ;; + *) + echo $"Usage: $PROG {start|stop|restart|condrestart|status|debug|help}" + exit 1 +esac + +exit $RETVAL