<p>I've spent some time on a debian jessie host, adapting a systemd script I've been using (please see below).</p>

<p>Some notes:</p>

<ul>
<li>As you probably know, sh_installinit already takes care of installing a .service file found in the debian folder, so it's sufficient to remove the kamailio.init and add the kamailio.service file.</li>
<li>After dh_installinit, you should add dh_systemd_enable and dh_systemd_start (both provided by 'dh-systemd' package)</li>
<li>The script has some default values, but those variables can be overwritten by the variables in /etc/default/kamailio (I made this in order not to deviate too much in respect to the current approach of the init.d script).</li>
</ul>

<p>I hope this helps, and I'm available for any question or to perform specific tests.</p>

<pre><code>[Unit]
Description=Kamailio (OpenSER) - the Open Source SIP Server
After=syslog.target network.target

[Service]
Type=forking
Environment='PIDFILE=/var/run/kamailio/kamailio.pid'
Environment='CFGFILE=/etc/kamailio/kamailio.cfg'
Environment='SHM_MEMORY=64'
Environment='PKG_MEMORY=8'
Environment='USER=kamailio'
Environment='GROUP=kamailio'
Environment='DAEMON=/usr/sbin/kamailio'
EnvironmentFile=/etc/default/kamailio
PIDFile=$PIDFILE
# ExecStart requires a full absolute path
ExecStart=/usr/sbin/kamailio -P $PIDFILE -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY -u $USER -g $GROUP
ExecStopPost=/bin/rm -f $PIDFILE
Restart=on-abort

[Install]
WantedBy=multi-user.target
</code></pre>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/kamailio/kamailio/issues/294#issuecomment-138590939">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/AF36ZbgiPMazI7I-Vjvy3v_VvybVJH28ks5ovu2wgaJpZM4FvH1R.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/kamailio/kamailio/issues/294#issuecomment-138590939"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>