Module: sip-router
Branch: master
Commit: 627a9e402c8e9d1a1251ff7d40043f4f6c8fc2bf
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=627a9e4…
Author: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley(a)crocodile-rcs.com>
Date: Tue May 8 00:00:48 2012 +0100
pkg/kamailio/fedora: Updated Fedora pkg files to use systemd instead of SysV init
---
pkg/kamailio/fedora/kamailio.default | 25 ------
pkg/kamailio/fedora/kamailio.init | 127 --------------------------------
pkg/kamailio/fedora/kamailio.service | 12 +++
pkg/kamailio/fedora/kamailio.spec | 24 +++---
pkg/kamailio/fedora/kamailio.sysconfig | 17 ++++
5 files changed, 42 insertions(+), 163 deletions(-)
diff --git a/pkg/kamailio/fedora/kamailio.default b/pkg/kamailio/fedora/kamailio.default
deleted file mode 100644
index d962311..0000000
--- a/pkg/kamailio/fedora/kamailio.default
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# 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 memory to allocate for the running Kamailio server (in Mb)
-MEMORY=64
-
-# 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
-
diff --git a/pkg/kamailio/fedora/kamailio.init b/pkg/kamailio/fedora/kamailio.init
deleted file mode 100644
index 8d8d4b7..0000000
--- a/pkg/kamailio/fedora/kamailio.init
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/bin/bash
-#
-# Startup script for Kamailio
-#
-# chkconfig: 345 85 15
-# description: Kamailio (OpenSER) - the Open Source 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
-
-
-# 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.*"
/etc/kamailio/kamailio.cfg; 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
- 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
-
-
-MEMORY=$((`echo $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
-[ $MEMORY -le 0 ] && MEMORY=32
-[ $PKG_MEMORY -le 0 ] && PKG_MEMORY=4
-
-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 $MEMORY -M $PKG_MEMORY -u $USER -g $GROUP"
-
-
-# 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
diff --git a/pkg/kamailio/fedora/kamailio.service b/pkg/kamailio/fedora/kamailio.service
new file mode 100644
index 0000000..c811475
--- /dev/null
+++ b/pkg/kamailio/fedora/kamailio.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Kamailio (OpenSER) - the Open Source SIP Server
+After=syslog.target network.target
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/kamailio
+PIDFile=/var/run/kamailio.pid
+ExecStart=/usr/sbin/kamailio $OPTIONS
+
+[Install]
+WantedBy=multi-user.target
diff --git a/pkg/kamailio/fedora/kamailio.spec b/pkg/kamailio/fedora/kamailio.spec
index c09bdcc..3f42f2b 100644
--- a/pkg/kamailio/fedora/kamailio.spec
+++ b/pkg/kamailio/fedora/kamailio.spec
@@ -346,13 +346,13 @@ make install-modules-all skip_modules="auth_identity
db_cassandra iptrtpproxy\
klcr ksqlite kredis kjson kmono kberkeley" include_modules="xmlrpc\
xmlops"
-mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d
-install -m755 pkg/kamailio/fedora/kamailio.init \
- $RPM_BUILD_ROOT/%{_sysconfdir}/rc.d/init.d/kamailio
+mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
+install -m644 pkg/kamailio/fedora/kamailio.service \
+ $RPM_BUILD_ROOT/%{_unitdir}/kamailio.service
-mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/default
-install -m755 pkg/kamailio/fedora/kamailio.default \
- $RPM_BUILD_ROOT/%{_sysconfdir}/default/kamailio
+mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig
+install -m644 pkg/kamailio/fedora/kamailio.sysconfig \
+ $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/kamailio
@@ -369,14 +369,14 @@ rm -rf "$RPM_BUILD_ROOT"
%post
-/sbin/chkconfig --add kamailio
+/bin/systemctl --system daemon-reload
%preun
if [ $1 = 0 ]; then
- /sbin/service kamailio stop > /dev/null 2>&1
- /sbin/chkconfig --del kamailio
+ /bin/systemctl stop kamailio.service
+ /bin/systemctl disable kamailio.service 2> /dev/null
fi
@@ -479,8 +479,8 @@ fi
%dir %{_sysconfdir}/kamailio
%config(noreplace) %{_sysconfdir}/kamailio/*
-%config %{_sysconfdir}/rc.d/init.d/*
-%config %{_sysconfdir}/default/*
+%config %{_unitdir}/*
+%config %{_sysconfdir}/sysconfig/*
%dir %{_libdir}/kamailio
%{_libdir}/kamailio/libbinrpc.so
@@ -859,6 +859,8 @@ fi
%changelog
+* Mon May 7 2012 Peter Dunkley <peter(a)dunkley.me.uk>
+ - Changed to use systemd instead of SysV init.
* Sun May 6 2012 Peter Dunkley <peter(a)dunkley.me.uk>
- First version created for Kamailio 3.3.0. Based on spec-file for CentOS
created by Ovidiu Sas.
diff --git a/pkg/kamailio/fedora/kamailio.sysconfig
b/pkg/kamailio/fedora/kamailio.sysconfig
new file mode 100644
index 0000000..08dda22
--- /dev/null
+++ b/pkg/kamailio/fedora/kamailio.sysconfig
@@ -0,0 +1,17 @@
+#
+# Kamailio startup options
+#
+
+# PID file for Kamailio
+PID_FILE=/var/run/kamailio.pid
+
+# Options to pass when starting Kamailio
+# Note: variable interpolation is not supported by systemd so $OPTIONS cannot
+# be constructed from multiple variables.
+# -P - The PID file (this must match the value in
+# /lib/systemd/system/kamailio.service)
+# -m - Kamailio shared (global) memory (default 32 MB)
+# -M - Kamailio package (per-process private) memory (default 4 MB)
+# -u - User to run Kamailio as
+# -g - Group to run Kamailio as
+OPTIONS="-P /var/run/kamailio.pid -m 32 -M 4 -u kamailio -g kamailio"