mirror of
https://github.com/owntone/owntone-server.git
synced 2025-03-13 21:12:56 -04: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:
parent
3f13ab1026
commit
8c9a164c4a
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)
|
||||
|
||||
|
40
configure.ac
40
configure.ac
@ -350,26 +350,54 @@ OWNTONE_ARG_DISABLE([MPD client protocol support], [mpd], [MPD])
|
||||
AM_CONDITIONAL([COND_MPD], [[test "x$enable_mpd" = "xyes"]])
|
||||
|
||||
dnl Include default webinterface
|
||||
OWNTONE_ARG_DISABLE([Include default web interface], [webinterface], [WEBINTERFACE],
|
||||
OWNTONE_ARG_DISABLE([include default web interface], [webinterface], [WEBINTERFACE],
|
||||
[AS_IF([[test "x$with_libwebsockets" = "xno"]],
|
||||
[AC_MSG_ERROR([[Web interface requires libwebsockets >= 2.0.2 (or use --disable-webinterface)]])])
|
||||
])
|
||||
AM_CONDITIONAL([COND_WEBINTERFACE], [[test "x$enable_webinterface" = "xyes"]])
|
||||
|
||||
dnl Defining users and groups
|
||||
dnl Creating and defining users and groups
|
||||
OWNTONE_ARG_ENABLE([having 'make install' add user/group and 'make uninstall' delete], [install_user], [INSTALL_USER],
|
||||
[AC_PATH_PROG([GETENT], [[getent]], [], [$PATH$PATH_SEPARATOR/usr/sbin])
|
||||
AC_PATH_PROG([USERADD], [[useradd]], [], [$PATH$PATH_SEPARATOR/usr/sbin])
|
||||
AC_PATH_PROG([USERDEL], [[userdel]], [], [$PATH$PATH_SEPARATOR/usr/sbin])
|
||||
AC_PATH_PROG([USERMOD], [[usermod]], [], [$PATH$PATH_SEPARATOR/usr/sbin])
|
||||
AC_PATH_PROG([GROUPADD], [[groupadd]], [], [$PATH$PATH_SEPARATOR/usr/sbin])
|
||||
AC_PATH_PROG([CHOWN], [[chown]], [], [$PATH$PATH_SEPARATOR/usr/sbin])
|
||||
AS_IF([[test -z "$GETENT" -o -z "$USERADD" -o -z "$USERDEL" -o -z "$USERMOD" -o -z "$GROUPADD" -o -z "$CHOWN"]],
|
||||
[AC_MSG_ERROR([[Required program for --enable-install-user not found]])])
|
||||
])
|
||||
AM_CONDITIONAL([COND_INSTALL_USER], [[test "x$enable_install_user" = "xyes"]])
|
||||
|
||||
AC_ARG_WITH([owntone_user],
|
||||
[AS_HELP_STRING([--with-user=USER],
|
||||
[User for running OwnTone (default=owntone)])],
|
||||
[AS_HELP_STRING([--with-user=USER], [User for running OwnTone (default=owntone)])],
|
||||
[[test x"$withval" = xyes && withval=]], [[withval=]])
|
||||
OWNTONE_USER=${withval:-owntone}
|
||||
AC_SUBST([OWNTONE_USER])
|
||||
|
||||
AC_ARG_WITH([owntone_group],
|
||||
[AS_HELP_STRING([--with-group=GROUP],
|
||||
[Group for owntone user (default=USER)])],
|
||||
[AS_HELP_STRING([--with-group=GROUP], [Group for owntone user (default=USER)])],
|
||||
[[test x"$withval" = xyes && withval=]], [[withval=]])
|
||||
OWNTONE_GROUP=${withval:-$OWNTONE_USER}
|
||||
AC_SUBST([OWNTONE_GROUP])
|
||||
|
||||
dnl Install config file
|
||||
OWNTONE_ARG_DISABLE([install configuration file], [install_conf_file], [INSTALL_CONF_FILE])
|
||||
AM_CONDITIONAL([COND_INSTALL_CONF_FILE], [[test "x$enable_install_conf_file" = "xyes"]])
|
||||
|
||||
# Service files are not installed like https://www.freedesktop.org/software/systemd/man/daemon.html
|
||||
# instructs, because that means they go to /lib/systemd/system (the destination
|
||||
# for package service files!) instead of /usr/local/etc/systemd/system with a
|
||||
# default ./configure, and I don't want that on my machine. Also, the suggested
|
||||
# approach is incredibly ugly.
|
||||
OWNTONE_ARG_DISABLE([install systemd service file], [install_systemd], [INSTALL_SYSTEMD])
|
||||
AM_CONDITIONAL([COND_INSTALL_SYSTEMD], [[test "x$enable_install_systemd" = "xyes"]])
|
||||
AC_ARG_WITH([systemddir],
|
||||
[AS_HELP_STRING([--with-systemddir=DIR], [Directory for systemd service files (default=SYSCONFDIR/systemd/system)])],
|
||||
[[test x"$withval" = xyes && withval=]], [[withval=]])
|
||||
SYSTEMD_DIR=${withval:-$sysconfdir/systemd/system}
|
||||
AC_SUBST([SYSTEMD_DIR])
|
||||
|
||||
dnl --- End options ---
|
||||
|
||||
dnl Unconditional since we always want to produce Makefiles for dist targets
|
||||
|
Loading…
x
Reference in New Issue
Block a user