Ticket #738: 0002-systemd-install-systemd-unit-files.patch

File 0002-systemd-install-systemd-unit-files.patch, 4.9 KB (added by anonymous, at 2010-12-27T19:12:30Z)
  • Makefile

    From 3d64e35c906224ac76b85546a0fa1ed99770e9bd 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 
    2626# Expansion of variables
    2727subdirobjs = $(foreach dir,$(subdirs),$(dir)/$(dir).o)
    2828
    29 all: $(OUTFILE) $(OTR_PI)
     29all: $(OUTFILE) $(OTR_PI) systemd
    3030        $(MAKE) -C doc
    3131
    3232uninstall: uninstall-bin uninstall-doc
    3333        @echo -e '\nmake uninstall does not remove files in '$(DESTDIR)$(ETCDIR)', you can use make uninstall-etc to do that.\n'
    3434
    35 install: install-bin install-doc install-plugins
     35install: install-bin install-doc install-plugins install-systemd
    3636        @if ! [ -d $(DESTDIR)$(CONFIG) ]; then echo -e '\nThe configuration directory $(DESTDIR)$(CONFIG) does not exist yet, don'\''t forget to create it!'; fi
    3737        @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
    3838        @echo
    3939
    40 .PHONY:   install   install-bin   install-etc   install-doc install-plugins \
     40.PHONY:   install   install-bin   install-etc   install-doc install-plugins install-systemd \
    4141        uninstall uninstall-bin uninstall-etc uninstall-doc \
    4242        all clean distclean tar $(subdirs)
    4343
    ifdef OTR_PI 
    109109        install -m 0755 otr.so $(DESTDIR)$(PLUGINDIR)
    110110endif
    111111
     112systemd:
     113ifdef 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
     116endif
     117
     118install-systemd:
     119ifdef 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)
     124endif
     125
    112126tar:
    113127        fakeroot debian/rules clean || make distclean
    114128        x=$$(basename $$(pwd)); \
  • configure

    diff --git a/configure b/configure
    index 3a3796d..8617d60 100755
    a b datadir='$prefix/share/bitlbee/' 
    1515config='/var/lib/bitlbee/'
    1616plugindir='$prefix/lib/bitlbee/'
    1717includedir='$prefix/include/bitlbee/'
     18systemdsystemunitdir=''
    1819libevent='/usr/'
    1920pidfile='/var/run/bitlbee.pid'
    2021ipcsocket='/var/run/bitlbee.sock'
    Option Description Default 
    6263--mandir=...                                            $mandir
    6364--datadir=...                                           $datadir
    6465--plugindir=...                                         $plugindir
     66--systemdsystemunitdir=...                              $systemdsystemunitdir
    6567--pidfile=...                                           $pidfile
    6668--config=...                                            $config
    6769--ipcsocket=...                                         $ipcsocket
    else 
    487489        fi;
    488490fi
    489491
     492if [ -z "$systemdsystemunitdir" ]; then
     493        if $PKG_CONFIG --exists systemd; then
     494                systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
     495        fi
     496fi
     497if [ -n "$systemdsystemunitdir" ]; then
     498        if [ "$systemdsystemunitdir" != "no" ]; then
     499                echo "SYSTEMDSYSTEMUNITDIR=$systemdsystemunitdir" >> Makefile.settings
     500        fi
     501fi
     502
    490503if [ "$gcov" = "1" ]; then
    491504        echo "CFLAGS+=--coverage" >> Makefile.settings
    492505        echo "EFLAGS+=--coverage" >> Makefile.settings
    else 
    740753        echo '  Off-the-Record (OTR) Messaging disabled.'
    741754fi
    742755
     756if [ -n "$systemdsystemunitdir" ]; then
     757        echo '  systemd enabled.'
     758else
     759        echo '  systemd disabled.'
     760fi
     761
    743762echo '  Using event handler: '$events
    744763echo '  Using SSL library: '$ssl
    745764echo '  Building with these storage backends: '$STORAGES
  • new file init/bitlbee.service.in

    diff --git a/init/bitlbee.service.in b/init/bitlbee.service.in
    new file mode 100644
    index 0000000..5f771d9
    - +  
     1[Unit]
     2Description=BitlBee IRC/IM gateway
     3After=syslog.target
     4
     5[Service]
     6ExecStart=@sbindir@/bitlbee -F -n -i 127.0.0.1
     7
     8[Install]
     9WantedBy=multi-user.target
  • new file init/bitlbee.socket

    diff --git a/init/bitlbee.socket b/init/bitlbee.socket
    new file mode 100644
    index 0000000..e5ceb47
    - +  
     1[Unit]
     2Conflicts=bitlbee.service
     3
     4[Socket]
     5ListenStream=127.0.0.1:6667
     6Accept=yes
     7
     8[Install]
     9WantedBy=sockets.target
  • new file init/bitlbee@.service.in

    diff --git a/init/bitlbee@.service.in b/init/bitlbee@.service.in
    new file mode 100644
    index 0000000..8b576a4
    - +  
     1[Unit]
     2Description=BitlBee Per-Connection Server
     3After=syslog.target
     4
     5[Service]
     6ExecStart=@sbindir@/bitlbee
     7StandardInput=socket
     8User=bitlbee