From bcf2ad16fbb0e03c22ca02d06cbf29aa61d735fb Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Mon, 1 Jul 2013 23:11:37 +0300 Subject: [PATCH] install a systemd service * Install a systemd service file on any Linux distribution. * Harmless if not used. * Does not yet enable it. --- Makefile | 2 ++ contrib/asterisk.service | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 contrib/asterisk.service diff --git a/Makefile b/Makefile index 41b337c..ddd249f 100644 --- a/Makefile +++ b/Makefile @@ -772,6 +772,8 @@ install-logrotate: config: @if [ "${OSARCH}" = "linux-gnu" ]; then \ + $(INSTALL) -d $(DESTDIR)/lib/systemd/system; \ + $(INSTALL) -m 644 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/contrib/asterisk.service b/contrib/asterisk.service new file mode 100644 index 0000000..c62b719 --- /dev/null +++ b/contrib/asterisk.service @@ -0,0 +1,19 @@ +[unit] +Description=Asterisk PBX +Documentation=man:asterisk(8) +Wants=network.target +After=network.target +# FIXME: After and whatever +# Consider socket activation? + +[Service] +# FIXME: maybe replace it with a wrapper script to handle failures +# (but not restart) +ExecStart=/usr/sbin/asterisk -f -U asterisk +# FIXME: are the signal handlers good enough? +#ExecStop=/usr/bin/asterisk -rx 'core stop now' +#ExecReload=/usr/bin/asterisk -rx 'core reload' +Restart=always + +[Install] +WantedBy=multi-user.target -- 1.7.10.4