Package: asterisk / 1:13.14.1~dfsg-2+deb9u4

systemd.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Description: A systemd service
 Do away with safe_asterisk. But try very hard to let live_ast work with
 it.
Author: Tzafrir Cohen <tzafrir@debian.org>
Last-Update: 2016-04-02

--- a/contrib/scripts/live_ast
+++ b/contrib/scripts/live_ast
@@ -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:
--- /dev/null
+++ b/contrib/scripts/asterisk_cleanup
@@ -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
--- /dev/null
+++ b/contrib/asterisk.service
@@ -0,0 +1,49 @@
+[Unit]
+Description=Asterisk PBX
+Documentation=man:asterisk(8)
+Wants=network-online.target
+After=network-online.target
+
+[Service]
+Type=notify
+ExecStart=__ASTERISK_SBIN_DIR__/asterisk -g -f -U asterisk
+ExecReload=__ASTERISK_SBIN_DIR__/asterisk -rx 'core reload'
+Restart=on-failure
+RestartSec=1
+WorkingDirectory=__ASTERISK_VARLIB_DIR__
+
+# Extra settings:
+# If you want to set them, you can add them to a file in the directory
+# /lib/systemd/system/asterisk.service.d/ with the extension .conf.
+# Example content:
+#[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
--- a/Makefile
+++ b/Makefile
@@ -825,6 +825,8 @@
 	rm -f contrib/scripts/asterisk.logrotate.tmp
 
 config:
+	$(INSTALL) -d $(DESTDIR)/lib/systemd/system
+	./build_tools/install_subst -d contrib/asterisk.service $(DESTDIR)/lib/systemd/system/asterisk.service
 	@if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
 		./build_tools/install_subst contrib/init.d/rc.redhat.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
 		if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \