funk-systemd: fix with-automake install targets

The install targets for the automake makefile differed
from the autoconf, fix this. We want to provide examples
by keeping the binary names different.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: add disable target and make enable use it

This avoids some errors upon install if the service was
already installed. We obviously don't need to be doing
any of this, this is general distribution / maintenance
work but since we want to provide an example for easy
testing and loading/unloading, we want to do all the
work for you.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: fix install-dyn target for automake

The regular funk daemon was being copied over, fix this.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: add verbose exit output describing error

Without at least a description of the return value we have
to hunt down what it means, with the error it should be
easier to debug things.

Systemd will print out messages when fprintf() is used with
SD_ERR, but in order to keep the code simple we just define
SD_ERR to nothing in the case that systemd is not being used.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: fix usage of array on funk_legacy

The wrong array was being used, this would cause
a compilation issue on non-systemd compiles.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: declare dlfcn.h only on its user

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: fix compilation for non-systemd-libs case

If you don't have systemd libraries present compilation was
failing. This was becuase of the silly early pointer assignment
on the header, we can do this on the C file, not the header.
Additionally we actually don't need this pointer floating
around so just nuke it.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: fix Makefile.am for non-systemd-case

There are series of files that should not be compiled in
for the non-systemd case, fix that.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: Makefile.in - fix compilation for non-systemd case

This propagates the last fix for automake case to the non-automake
and regular autoconf use example.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: make error paths chatty

The point of this is a tutorial, so make the exit paths
very chatty, as bringing things up is typically the
biggest pain in the ass and that is where we need as much
verbosity as possible.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: add a fair warning about using the extra socket files

This caused quite a bit of issues when reverting back, so document
the possible issues you can run into.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: fix legacy daemon

The usage of strncpy() should be followed by prefixed
by a memset() in this case otherwise uninitialized
junk can be passed over, creating incorrect and
unexpected socket names.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: simplify service units for multiple daemons

The discussion over options for multiple daemons on
systemd [0] has ended with a recommendation that instead
of writing a launcher once can use sh -c exec "$PATH/$DAEMON"
on ExecStart with an Environment=DAEMON=foo specified. This
seems to work with sd_notify() and simplifies this quite a
bit.

[0] http://lists.freedesktop.org/archives/systemd-devel/2014-May/019427.html

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: split socket service files to change permissions

This splits up the socket required into separate files due
to the different permissions we want on them. We can therefore
avoid the chmod() call as well for the systemd case. Ideally
this should work but this doesn't right now.

The order in which you pass the sockets on the service unit file
will change the order in which systemd assigns a file descriptor
to the socket, keeping the order matters.

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>
funk-systemd: m4/systemd.m4 - fix force disabling systemd

We allow for a permissive case to enable systemd only if
the requirements met are found through AX_AVAILABLE_SYSTEMD()
but that permissive functionality ignores forced disabled
commands at configure time, fix that and respect the passed
forced disable commands.

You should be able to disable systemd support now on a build
system that has systemd libraries if you use AX_AVAILABLE_SYSTEMD()
and use either of these:

./configure --disable-systemd
./configure --enable-systemd=no

Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com>