From 5b54c3a0287a92008f1a795af45c43445a4daac9 Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@frugalware.org>
Date: Mon, 27 Dec 2010 17:14:27 +0100
Subject: [PATCH] systemd: install systemd unit files
bitlbee.service provides ForkDaemon mode,
bitlbee.socket/bitlbee@.service is available as well for the depreceated
inetd mode.
---
Makefile | 20 +++++++++++++++++---
configure | 19 +++++++++++++++++++
init/bitlbee.service.in | 9 +++++++++
init/bitlbee.socket | 9 +++++++++
init/bitlbee@.service.in | 8 ++++++++
5 files changed, 62 insertions(+), 3 deletions(-)
create mode 100644 init/bitlbee.service.in
create mode 100644 init/bitlbee.socket
create mode 100644 init/bitlbee@.service.in
diff --git a/Makefile b/Makefile
index 24ef216..9afd4e0 100644
a
|
b
|
endif |
26 | 26 | # Expansion of variables |
27 | 27 | subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o) |
28 | 28 | |
29 | | all: $(OUTFILE) $(OTR_PI) |
| 29 | all: $(OUTFILE) $(OTR_PI) systemd |
30 | 30 | $(MAKE) -C doc |
31 | 31 | |
32 | 32 | uninstall: uninstall-bin uninstall-doc |
33 | 33 | @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n' |
34 | 34 | |
35 | | install: install-bin install-doc install-plugins |
| 35 | install: install-bin install-doc install-plugins install-systemd |
36 | 36 | @if ! [ -d $(DESTDIR)$(CONFIG) ]; then echo -e '\nThe configuration directory $(DESTDIR)$(CONFIG) does not exist yet, don'\''t forget to create it!'; fi |
37 | 37 | @if ! [ -e $(DESTDIR)$(ETCDIR)/bitlbee.conf ]; then echo -e '\nNo files are installed in '$(DESTDIR)$(ETCDIR)' by make install. Run make install-etc to do that.'; fi |
38 | 38 | @echo |
39 | 39 | |
40 | | .PHONY: install install-bin install-etc install-doc install-plugins \ |
| 40 | .PHONY: install install-bin install-etc install-doc install-plugins install-systemd \ |
41 | 41 | uninstall uninstall-bin uninstall-etc uninstall-doc \ |
42 | 42 | all clean distclean tar $(subdirs) |
43 | 43 | |
… |
… |
ifdef OTR_PI |
109 | 109 | install -m 0755 otr.so $(DESTDIR)$(PLUGINDIR) |
110 | 110 | endif |
111 | 111 | |
| 112 | systemd: |
| 113 | ifdef SYSTEMDSYSTEMUNITDIR |
| 114 | sed 's|@sbindir@|$(BINDIR)|' init/bitlbee.service.in > init/bitlbee.service |
| 115 | sed 's|@sbindir@|$(BINDIR)|' init/bitlbee@.service.in > init/bitlbee@.service |
| 116 | endif |
| 117 | |
| 118 | install-systemd: |
| 119 | ifdef SYSTEMDSYSTEMUNITDIR |
| 120 | mkdir -p $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
| 121 | install -m 0644 init/bitlbee.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
| 122 | install -m 0644 init/bitlbee@.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
| 123 | install -m 0644 init/bitlbee.socket $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR) |
| 124 | endif |
| 125 | |
112 | 126 | tar: |
113 | 127 | fakeroot debian/rules clean || make distclean |
114 | 128 | x=$$(basename $$(pwd)); \ |
diff --git a/configure b/configure
index 3a3796d..8617d60 100755
a
|
b
|
datadir='$prefix/share/bitlbee/' |
15 | 15 | config='/var/lib/bitlbee/' |
16 | 16 | plugindir='$prefix/lib/bitlbee/' |
17 | 17 | includedir='$prefix/include/bitlbee/' |
| 18 | systemdsystemunitdir='' |
18 | 19 | libevent='/usr/' |
19 | 20 | pidfile='/var/run/bitlbee.pid' |
20 | 21 | ipcsocket='/var/run/bitlbee.sock' |
… |
… |
Option Description Default |
62 | 63 | --mandir=... $mandir |
63 | 64 | --datadir=... $datadir |
64 | 65 | --plugindir=... $plugindir |
| 66 | --systemdsystemunitdir=... $systemdsystemunitdir |
65 | 67 | --pidfile=... $pidfile |
66 | 68 | --config=... $config |
67 | 69 | --ipcsocket=... $ipcsocket |
… |
… |
else |
487 | 489 | fi; |
488 | 490 | fi |
489 | 491 | |
| 492 | if [ -z "$systemdsystemunitdir" ]; then |
| 493 | if $PKG_CONFIG --exists systemd; then |
| 494 | systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd` |
| 495 | fi |
| 496 | fi |
| 497 | if [ -n "$systemdsystemunitdir" ]; then |
| 498 | if [ "$systemdsystemunitdir" != "no" ]; then |
| 499 | echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings |
| 500 | fi |
| 501 | fi |
| 502 | |
490 | 503 | if [ "$gcov" = "1" ]; then |
491 | 504 | echo "CFLAGS+=--coverage" >> Makefile.settings |
492 | 505 | echo "EFLAGS+=--coverage" >> Makefile.settings |
… |
… |
else |
740 | 753 | echo ' Off-the-Record (OTR) Messaging disabled.' |
741 | 754 | fi |
742 | 755 | |
| 756 | if [ -n "$systemdsystemunitdir" ]; then |
| 757 | echo ' systemd enabled.' |
| 758 | else |
| 759 | echo ' systemd disabled.' |
| 760 | fi |
| 761 | |
743 | 762 | echo ' Using event handler: '$events |
744 | 763 | echo ' Using SSL library: '$ssl |
745 | 764 | echo ' Building with these storage backends: '$STORAGES |
diff --git a/init/bitlbee.service.in b/init/bitlbee.service.in
new file mode 100644
index 0000000..95cbe25
-
|
+
|
|
| 1 | [Unit] |
| 2 | Description=BitlBee IRC/IM gateway |
| 3 | After=syslog.target |
| 4 | |
| 5 | [Service] |
| 6 | ExecStart=@sbindir@/bitlbee -F -n |
| 7 | |
| 8 | [Install] |
| 9 | WantedBy=multi-user.target |
diff --git a/init/bitlbee.socket b/init/bitlbee.socket
new file mode 100644
index 0000000..e5ceb47
-
|
+
|
|
| 1 | [Unit] |
| 2 | Conflicts=bitlbee.service |
| 3 | |
| 4 | [Socket] |
| 5 | ListenStream=127.0.0.1:6667 |
| 6 | Accept=yes |
| 7 | |
| 8 | [Install] |
| 9 | WantedBy=sockets.target |
diff --git a/init/bitlbee@.service.in b/init/bitlbee@.service.in
new file mode 100644
index 0000000..8b576a4
-
|
+
|
|
| 1 | [Unit] |
| 2 | Description=BitlBee Per-Connection Server |
| 3 | After=syslog.target |
| 4 | |
| 5 | [Service] |
| 6 | ExecStart=@sbindir@/bitlbee |
| 7 | StandardInput=socket |
| 8 | User=bitlbee |