[Pkg-voip-commits] [asterisk] 02/05: A systemd service

tzafrir at debian.org tzafrir at debian.org
Sun Oct 26 08:15:56 UTC 2014


This is an automated email from the git hooks/post-receive script.

tzafrir pushed a commit to branch master
in repository asterisk.

commit 0fbb12388cef3770183722e4112cca127f4df645
Author: Tzafrir Cohen <tzafrir at debian.org>
Date:   Sun Oct 26 08:53:14 2014 +0200

    A systemd service
---
 debian/control               |   1 +
 debian/patches/series        |   1 +
 debian/patches/systemd.patch | 176 +++++++++++++++++++++++++++++++++++++++++++
 debian/rules                 |   2 +-
 4 files changed, 179 insertions(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index 0756ca3..a7a5c9c 100644
--- a/debian/control
+++ b/debian/control
@@ -4,6 +4,7 @@ Section: comm
 Maintainer: Debian VoIP Team <pkg-voip-maintainers at lists.alioth.debian.org>
 Uploaders: Mark Purcell <msp at debian.org>, Tzafrir Cohen <tzafrir at debian.org>, Jeremy Lainé <jeremy.laine at m4x.org>, Daniel Pocock <daniel at pocock.com.au>
 Build-Depends: debhelper (>= 8),
+ dh-systemd,
  dpkg-dev (>= 1.16.1.1),
  lsb-base (>= 3.2-14),
  libreadline-dev | libreadline5-dev,
diff --git a/debian/patches/series b/debian/patches/series
index 286b680..c9b7269 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -33,3 +33,4 @@ escape_manpage_hyphen.patch
 aelparse_enable.patch
 res_fax_bounds.patch
 neon_version_check.patch
+systemd.patch
diff --git a/debian/patches/systemd.patch b/debian/patches/systemd.patch
new file mode 100644
index 0000000..d11e4b5
--- /dev/null
+++ b/debian/patches/systemd.patch
@@ -0,0 +1,176 @@
+From: Tzafrir Cohen <tzafrir at debian.org>
+Subject: A systemd service
+
+Do away with safe_asterisk. But try very hard to let live_ast work with
+it.
+Index: trunk/contrib/scripts/live_ast
+===================================================================
+--- trunk/contrib/scripts/live_ast	(revision 407855)
++++ trunk/contrib/scripts/live_ast	(working copy)
+@@ -175,6 +175,43 @@
+   | sed  -e '/^#* \(Begin\|End\) Samples/d' >"$LIVE_CONF"
+ }
+ 
++# (re?)generate a unit file that could be installed on the system to use
++# this copy of Asterisk.
++gen_ast_live_service() {
++  local service_file="$BASE_DIR/asterisk-live.service"
++  local included_dir='lib'
++  local included_dir_remmed='etc'
++  if [ -f /etc/systemd/system/asterisk.service ]; then
++    included_dir='etc'
++    included_dir_remmed='lib'
++  fi
++  local varlibdir=`awk '/astvarlibdir/ {print $3}' "$AST_CONF" | head -n1`
++  cat <<EOF >"$service_file"
++# This file is based on your existing asterisk systemd service unit, and
++# overrides some fields. If you have an overriding unit in /etc, you
++# need to include it, rather than the one in /lib:
++.include /$included_dir/systemd/system/asterisk.service
++#.include /$included_dir_remmed/systemd/system/asterisk.service
++
++# This file is not installed. If you want to use it, you need to copy it
++# to /etc/systemd/system and run 'systemctl daemon-reload'. You'll then
++# need to be able to start this manually (note that it will not be
++# enabled and thus the standard bash completion will not complete it).
++# If you have multiple live asterisk instances you want to run on the
++# same system, be sure to give each one a unique name.
++
++[Unit]
++Description = Asterisk PBX (Live Asterisk)
++
++# Note: if you changed the parameters passed in the command-line (ExecStart)
++# be sure to copy them over here as well.
++[Service]
++ExecStart = $BASE_DIR/asterisk g -f -U asterisk
++ExecReload = $BASE_DIR/asterisk -rx 'core reload'
++WorkingDirectory = $varlibdir
++EOF
++}
++
+ # (re?)generate the ./live/asterisk wrapper script
+ gen_live_asterisk() {
+   cat <<EOF >"$BASE_DIR/asterisk"
+@@ -244,6 +281,7 @@
+   chmod +x "$BASE_DIR/asterisk"
+   # Generate a sample config file for live_ast itself:
+   gen_live_conf
++  gen_ast_live_service
+   ;;
+ conf-file)
+   # Just regenerate live.conf from the sample if it does not already exist:
+Index: trunk/contrib/scripts/asterisk_cleanup
+===================================================================
+--- trunk/contrib/scripts/asterisk_cleanup	(revision 0)
++++ trunk/contrib/scripts/asterisk_cleanup	(revision 0)
+@@ -0,0 +1,18 @@
++#!/bin/sh
++
++# asterisk_cleanup: A script intended to optionally be run when Asterisk
++# has exited. This example script is used to move core files.
++
++VARLIBDIR=${VARLIBDIR:/var/lib/asterisk}
++RUNDIR=${VARRUNDIR:/var/run/asterisk}
++DUMPDROP=${DUMPDROP:-/var/spool/asterisk/cores}
++ASTPIDFILE=${ASTVARRUNDIR}/asterisk.pid
++PID=`cat ${ASTPIDFILE}`
++DATE=`date "+%Y-%m-%dT%H:%M:%S%z"`
++if test -f ${RUNDIR}/core.${PID} ; then
++	mkdir -p "${DUMPDROP}"
++	mv ${RUNDIR}/core.${PID} ${DUMPDROP}/core.`hostname`-$DATE &
++elif test -f ${RUNDIR}/core ; then
++	mkdir -p "${DUMPDROP}"
++	mv ${RUNDIR}/core ${DUMPDROP}/core.`hostname`-$DATE &
++fi
+
+Property changes on: contrib/scripts/asterisk_cleanup
+___________________________________________________________________
+Added: svn:executable
+   + *
+Added: svn:mime-type
+   + text/plain
+Added: svn:keywords
+   + Author Date Id Revision
+Added: svn:eol-style
+   + native
+
+svn: warning: cannot set LC_CTYPE locale
+svn: warning: environment variable LC_ALL is en_US.UTF-8
+svn: warning: please check that your locale name is correct
+Index: trunk/contrib/asterisk.service
+===================================================================
+--- trunk/contrib/asterisk.service	(revision 0)
++++ trunk/contrib/asterisk.service	(revision 0)
+@@ -0,0 +1,49 @@
++[Unit]
++Description=Asterisk PBX
++Documentation=man:asterisk(8)
++Wants=network-online.target
++After=network-online.target
++
++[Service]
++ExecStart=__ASTERISK_SBIN_DIR__/asterisk -g -f -U asterisk
++ExecReload=__ASTERISK_SBIN_DIR__/asterisk -rx 'core reload'
++Restart=always
++RestartSec=1
++WorkingDirectory=__ASTERISK_VARLIB_DIR__
++
++# Extra settings:
++# If you want to set them, you can generate the file
++# /etc/systemd/system/asterisk.service that has the following lines
++# (without the comments)
++#include /lib/systemd/system/asterisk.service
++#[Service]
++#
++# and following those two lines add directives or override existing
++# directives. Some extra directives that may be useful:
++
++# You can run a script to clean up after asterisk. An example script is
++# included in contrib/scripts/asterisk_cleanup.
++#ExecStopPost=/path/to/script
++
++#Nice=0
++#UMask=0002
++#LimitCORE=infinity
++#LimitNOFILE=
++
++# safe_asterisk runs Asterisk in a virtual console. This allows easy
++# access to the asterisk command-line without logging it. on the other
++# hand, it allows anyone with physical access to the console full access
++# to Asterisk. To enable this console, unrem the following lines and add
++# '-c' to the ExecStart line above:
++#TTYPath=/dev/tty9
++#StandardInput=tty
++#StandardOutput=tty
++#StandardError=tty
++
++# For more information on what these parameters mean see:
++#
++# http://0pointer.de/public/systemd-man/systemd.service.html
++# http://0pointer.de/public/systemd-man/systemd.exec.html
++
++[Install]
++WantedBy=multi-user.target
+
+Property changes on: contrib/asterisk.service
+___________________________________________________________________
+Added: svn:mime-type
+   + text/plain
+Added: svn:keywords
+   + Author Date Id Revision
+Added: svn:eol-style
+   + native
+
+Index: trunk/Makefile
+===================================================================
+--- trunk/Makefile	(revision 407855)
++++ trunk/Makefile	(working copy)
+@@ -783,6 +783,8 @@
+ 
+ config:
+ 	@if [ "${OSARCH}" = "linux-gnu" ]; then \
++		$(INSTALL) -d $(DESTDIR)/lib/systemd/system; \
++		./build_tools/install_subst -d contrib/asterisk.service $(DESTDIR)/lib/systemd/system/;
+ 		if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
+ 			cat contrib/init.d/rc.redhat.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
+ 			$(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/init.d/asterisk" ; \
diff --git a/debian/rules b/debian/rules
index ac0c810..65fe090 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,7 +11,7 @@
 #  The "all" option enables "PIE" and "BINDNOW" and future hardening flags
 
 %:
-	dh "$@" --with autotools_dev,autoreconf
+	dh "$@" --with autotools_dev,autoreconf,systemd
 
 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 DPKG_EXPORT_BUILDFLAGS = 1

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/asterisk.git



More information about the Pkg-voip-commits mailing list