mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-07 12:53:00 -05:00
[config] Easier install by letting 'make install' add user and service files
If --enable-install-user set add owntone system user and group (unless other user/group specified with --with-user or --with-group). The user will be added to pulse-access if the group is present. Don't overwrite config, it's a pita. Use same solution as shairport-sync where distros can use --disable-install_conf_file if required. A './configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var' will result in service files in /etc/systemd/system, which seems sensible. Package builds can specify other location, e.g. --with-systemdir=/lib/systemd/system, or ship their own service file and use --disable-install-systemd. Also added more cleanup on uninstall - before we where leaving stuff in /var/cache/owntone + the logs + the pid files.
This commit is contained in:
32
Makefile.am
32
Makefile.am
@@ -8,7 +8,10 @@ RPM_SPEC_FILE = owntone.spec
|
||||
CONF_FILE = owntone.conf
|
||||
SYSTEMD_SERVICE_FILE = owntone.service
|
||||
|
||||
sysconf_DATA = $(CONF_FILE)
|
||||
if COND_INSTALL_SYSTEMD
|
||||
systemddir = $(SYSTEMD_DIR)
|
||||
systemd_DATA = $(SYSTEMD_SERVICE_FILE)
|
||||
endif
|
||||
|
||||
BUILT_SOURCES = $(CONF_FILE) $(SYSTEMD_SERVICE_FILE)
|
||||
|
||||
@@ -33,9 +36,34 @@ EXTRA_DIST = \
|
||||
$(RPM_SPEC_FILE)
|
||||
|
||||
install-data-hook:
|
||||
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/$(PACKAGE)/libspotify"
|
||||
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/log"
|
||||
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run"
|
||||
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/$(PACKAGE)"
|
||||
if COND_INSTALL_USER
|
||||
( $(GETENT) group $(OWNTONE_GROUP) &> /dev/null || $(GROUPADD) --system $(OWNTONE_GROUP) )
|
||||
( $(GETENT) passwd $(OWNTONE_USER) &> /dev/null || $(USERADD) --system --no-create-home --gid $(OWNTONE_GROUP) --groups audio --shell /usr/sbin/nologin $(OWNTONE_USER) )
|
||||
( ! $(GETENT) group pulse-access &> /dev/null || $(USERMOD) --append --groups pulse-access $(OWNTONE_USER) )
|
||||
$(CHOWN) $(OWNTONE_USER).$(OWNTONE_GROUP) "$(DESTDIR)$(localstatedir)/cache/$(PACKAGE)"
|
||||
endif
|
||||
if COND_LIBSPOTIFY
|
||||
$(MKDIR_P) "$(DESTDIR)$(localstatedir)/cache/$(PACKAGE)/libspotify"
|
||||
endif
|
||||
# we do this manually instead of using sysconf_DATA because it overwrites existing config
|
||||
if COND_INSTALL_CONF_FILE
|
||||
$(MKDIR_P) "$(DESTDIR)$(sysconfdir)"
|
||||
[ -f $(DESTDIR)$(sysconfdir)/$(CONF_FILE) ] || $(INSTALL_DATA) $(CONF_FILE) $(DESTDIR)$(sysconfdir)/$(CONF_FILE)
|
||||
endif
|
||||
|
||||
uninstall-hook:
|
||||
( cd "$(DESTDIR)$(localstatedir)/cache" && rm -rf $(PACKAGE) )
|
||||
( cd "$(DESTDIR)$(localstatedir)/log" && rm -f "$(PACKAGE).log*" )
|
||||
( cd "$(DESTDIR)$(localstatedir)/run" && rm -f "$(PACKAGE).pid" )
|
||||
if COND_INSTALL_USER
|
||||
( ! $(GETENT) passwd $(OWNTONE_USER) &> /dev/null || $(USERDEL) $(OWNTONE_USER) )
|
||||
endif
|
||||
if COND_INSTALL_CONF_FILE
|
||||
( cd "$(DESTDIR)$(sysconfdir)" && rm -f $(CONF_FILE) )
|
||||
endif
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user