diff --git a/.gitignore b/.gitignore index cf5868ec..5d7e0a7b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,8 @@ missing stamp-h1 autotools-stamp build-stamp +forked-daapd.conf +forked-daapd.service # ignore debian packaging for convenience debian/ diff --git a/Makefile.am b/Makefile.am index 568ba80a..d9bb8c8f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,11 @@ ACLOCAL_AMFLAGS = -I m4 -sysconf_DATA = forked-daapd.conf +CONF_FILE = forked-daapd.conf +SYSTEMD_SERVICE_FILE = forked-daapd.service + +sysconf_DATA = $(CONF_FILE) + +BUILT_SOURCES = $(CONF_FILE) $(SYSTEMD_SERVICE_FILE) SUBDIRS = sqlext src @@ -17,8 +22,25 @@ nobase_dist_doc_DATA = \ scripts/pairinghelper.sh EXTRA_DIST = \ - forked-daapd.conf + $(CONF_FILE).in \ + $(SYSTEMD_SERVICE_FILE).in install-data-hook: $(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/$(PACKAGE)/libspotify" +CLEANFILES = $(BUILT_SOURCES) + +do_subst = sed -e 's|@sbindir[@]|$(sbindir)|g' \ + -e 's|@localstatedir[@]|$(localstatedir)|g' \ + -e 's|@PACKAGE[@]|$(PACKAGE)|g' \ + -e 's|@DAAPD_USER[@]|$(DAAPD_USER)|g' + +# these files use $prefix, which is determined at build (not configure) time +$(CONF_FILE) $(SYSTEMD_SERVICE_FILE): Makefile + $(AM_V_at)rm -f $@ $@-t + $(AM_V_GEN)$(do_subst) "$(srcdir)/$@.in" > $@-t + $(AM_V_at)mv $@-t $@ + +$(CONF_FILE): $(srcdir)/$(CONF_FILE).in + +$(SYSTEMD_SERVICE_FILE): $(srcdir)/$(SYSTEMD_SERVICE_FILE).in diff --git a/configure.ac b/configure.ac index b7afe10e..f149caf4 100644 --- a/configure.ac +++ b/configure.ac @@ -279,6 +279,23 @@ AS_IF([test "x$enable_mpd" != "xno"], [ AC_DEFINE(MPD, 1, [Define to 1 to enable MPD support]) ]) AM_CONDITIONAL(COND_MPD, [test "x$enable_mpd" != "xno"]) + +# +# Defining users and groups +# +AC_ARG_WITH([daapd_user], + [AS_HELP_STRING([--with-daapd-user=USER], + [User for running forked-daapd (default=daapd)])], + [test x"$withval" = xyes && withval=], [withval=]) +DAAPD_USER=${withval:-daapd} +AC_SUBST(DAAPD_USER) + +AC_ARG_WITH([daapd_group], + [AS_HELP_STRING([--with-daapd-group=GROUP], + [Group for daapd user (default=USER)])], + [test x"$withval" = xyes && withval=], [withval=]) +DAAPD_GROUP=${withval:-$DAAPD_USER} +AC_SUBST(DAAPD_GROUP) dnl --- End options --- dnl Checks for header files. diff --git a/forked-daapd.conf b/forked-daapd.conf.in similarity index 97% rename from forked-daapd.conf rename to forked-daapd.conf.in index 2f23e69f..ca4ee9b3 100644 --- a/forked-daapd.conf +++ b/forked-daapd.conf.in @@ -11,14 +11,14 @@ general { # Username # Make sure the user has read access to the library directories you set # below, and full access to the databases, log and local audio - uid = "daapd" + uid = "@DAAPD_USER@" # Database location -# db_path = "/var/cache/forked-daapd/songs3.db" +# db_path = "@localstatedir@/cache/@PACKAGE@/songs3.db" # Log file and level # Available levels: fatal, log, warning, info, debug, spam - logfile = "/var/log/forked-daapd.log" + logfile = "@localstatedir@/log/@PACKAGE@.log" loglevel = log # Admin password for the non-existent web interface @@ -28,7 +28,7 @@ general { ipv6 = yes # Location of cache database -# cache_path = "/var/cache/forked-daapd/cache.db" +# cache_path = "@localstatedir@/cache/@PACKAGE@/cache.db" # DAAP requests that take longer than this threshold (in msec) get their # replies cached for next time. Set to 0 to disable caching. @@ -203,7 +203,7 @@ audio { # Spotify settings (only have effect if Spotify enabled - see README/INSTALL) spotify { # Directory where user settings should be stored (credentials) -# settings_dir = "/var/cache/forked-daapd/libspotify" +# settings_dir = "@localstatedir@/cache/@PACKAGE@/libspotify" # Cache directory # cache_dir = "/tmp" diff --git a/forked-daapd.service b/forked-daapd.service.in similarity index 80% rename from forked-daapd.service rename to forked-daapd.service.in index d2bccbc2..ff987df8 100755 --- a/forked-daapd.service +++ b/forked-daapd.service.in @@ -1,9 +1,10 @@ [Unit] Description=DAAP/DACP (iTunes), RSP and MPD server, supports AirPlay and Remote +Documentation=man:forked-daapd(8) After=network.target sound.target [Service] -ExecStart=/usr/sbin/forked-daapd -f +ExecStart=@sbindir@/forked-daapd -f # Restart, but not more than once every 10 minutes Restart=on-failure