Skip to content

Commit

Permalink
pkg/rpm: added folders with rpm specs for oracle el6 and el7
Browse files Browse the repository at this point in the history
(cherry picked from commit e72c7e0)
  • Loading branch information
kvishnivetsky authored and miconda committed May 9, 2016
1 parent c29e524 commit 6f60780
Show file tree
Hide file tree
Showing 8 changed files with 1,076 additions and 2 deletions.
30 changes: 30 additions & 0 deletions pkg/kamailio/oracle/el6/kamailio.default
@@ -0,0 +1,30 @@
#
# Kamailio startup options
#

# Set to yes to enable kamailio, once configured properly.
RUN_KAMAILIO=yes

# User to run as
USER=kamailio

# Group to run as
GROUP=kamailio

# Amount of shared memory to allocate for the running Kamailio server (in Mb)
SHM_MEMORY=64

# Amount of private memory to allocate for the running Kamailio server (in Mb)
PKG_MEMORY=8

# Enable the server to leave a core file when it crashes.
# Set this to 'yes' to enable kamailio to leave a core file when it crashes
# or 'no' to disable this feature. This option is case sensitive and only
# accepts 'yes' and 'no' and only in lowercase letters.
# On some systems (e.g. Ubuntu 6.10, Debian 4.0) it is necessary to specify
# a directory for the core files to get a dump. Look into the kamailio
# init file for an example configuration.
DUMP_CORE=no

# Add extra command line parameters in the EXTRA_OPTIONS variable
# EXTRA_OPTIONS="-a no"
128 changes: 128 additions & 0 deletions pkg/kamailio/oracle/el6/kamailio.init
@@ -0,0 +1,128 @@
#!/bin/bash
#
# Startup script for Kamailio
#
# chkconfig: 345 85 15
# description: Kamailio is a fast 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
KAMCFG=/etc/kamailio/kamailio.cfg
PROG=kamailio
PID_FILE=/var/run/kamailio.pid
LOCK_FILE=/var/lock/subsys/kamailio
RETVAL=0
DEFAULTS=/etc/default/kamailio
RUN_KAMAILIO=no


# 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.*" $KAMCFG; 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 -M $PKG_MEMORY -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
Expand Up @@ -319,8 +319,8 @@ install -m755 $RPM_SOURCE_DIR/kamailio.default \


%pre
/sbin/groupadd -r kamailio 2> /dev/null || :
/sbin/useradd -r -g kamailio -s /bin/false -c "Kamailio daemon" -d \
/usr/sbin/groupadd -r kamailio 2> /dev/null || :
/usr/sbin/useradd -r -g kamailio -s /bin/false -c "Kamailio daemon" -d \
%{_libdir}/kamailio kamailio 2> /dev/null || :


Expand Down
17 changes: 17 additions & 0 deletions pkg/kamailio/oracle/el7/kamailio.service
@@ -0,0 +1,17 @@
[Unit]
Description=Kamailio SIP router server daemon
After=syslog.target network.target auditd.service

[Service]
EnvironmentFile=/etc/sysconfig/kamailio
ExecStartPre=/usr/bin/mkdir -m=2770 -p /var/run/kamailio
ExecStartPre=/usr/bin/chown kamailio:kamailio /var/run/kamailio
ExecStart=/usr/sbin/kamailio -f $CFG_FILE -P $PID_FILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP $EXTRA_OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=control-group
Restart=on-failure
RestartSec=42s
Type=forking

[Install]
WantedBy=multi-user.target

0 comments on commit 6f60780

Please sign in to comment.