From ac74b354653b7353466eda3d81ca519bfa9f816e Mon Sep 17 00:00:00 2001 From: Zoltan Puskas Date: Sun, 12 Feb 2023 17:22:50 -0800 Subject: [PATCH] feat(contrib): improve system related contrib files Make example configuration self documenting Most services on *nix type systems have configuration files that are self documenting. This usually entails: - listing all configuration options with some sane default values - commenting out options that do not need to be set or match the binary default value - some explanatory comments where needed This simplifies management of the service as configuration can be understood and modified in place without having to open up the internet. This diff also groups settings into logical blocks: - basic server settings - directory settings - behavioural settings Improve contrib system file behaviour This diff improves gonic serive files in the following way: - Define a sane default for gonig cache, which will map well to established cache paths on most Linux systems - Update service file to use StateDirectory=, CacheDirectory= directives to create /var/lib/gonic and /var/cache/gonic directories respectively - Add a tmpfilesd sample configuration that will automatically clean cache files if they are older than 7 days - Add sysysers configuration file that can be used in sysusers.d to create relevant gonic user and group during installation. --- contrib/config | 59 +++++++++++++++++++++++++++++++++++++----- contrib/gonic.service | 4 ++- contrib/gonic.sysusers | 1 + contrib/gonic.tmpfiles | 1 + 4 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 contrib/gonic.sysusers create mode 100644 contrib/gonic.tmpfiles diff --git a/contrib/config b/contrib/config index 3f689a2..f5f448b 100644 --- a/contrib/config +++ b/contrib/config @@ -1,7 +1,52 @@ -music-path -podcast-path -cache-path -db-path /var/lib/gonic/gonic.db -jukebox-enabled false -listen-addr 127.0.0.1:4747 -scan-interval 0 +# This is the gonic server system-wide configuration file. For other +# administrative and per user settings go th the web UI. +# +# The strategy used for options in the default config shipped with gonic is to +# specify options with their default value where possible, and leave optional +# ones commented. Uncommented options override the default value. Options that +# are mandatory and need setting before first run have a placeholder for their +# values in . + +# Interface and port to listen on. Defaults to 0.0.0.0:4747 +listen-addr 127.0.0.1:4747 + +# HTTP(S) request logging +#http-log true +# URL path prefix to use if behind reverse proxy +#proxy-prefix + +# Secure connection settings. Recommended to set up unless gonic sits behing an +# SSL enabled reverse proxy server. Disabled by default. +#tls-cert +#tls-key + +# gonic's internal state database location +db-path /var/lib/gonic/gonic.db + +# Path to music files. Must be specified at least once, but can be specified +# multiple times if the collection is split into different +# directories. E.g.: +# music-path /srv/audio/music +music-path + +# Path to downloaded podcast files. Must be specified. E.g.: +# podcast-path /var/cache/podcast +podcast-path + +# Age (in days) to purge podcast episodes if not accessed. Disabled by default. +#podcast-purge-age 0 + +# Directory where transcoded audio files and covers are stored. It's safe to +# delete contents periodically (see tmpfilesd configuration), as it will be +# regenerated. +cache-path /var/cache/gonic + +# Interval (in minutes) to check for new music. Default: don't scan +#scan-interval 0 +#scan-at-start-enabled false +#scan-watcher-enabled false +#jukebox-enabled false +#jukebox-mpv-extra-args + +# A string or character to split genre tags on for multi-genre support (e.g. ;) +#genre-split ; diff --git a/contrib/gonic.service b/contrib/gonic.service index 4a2128f..7a4e432 100644 --- a/contrib/gonic.service +++ b/contrib/gonic.service @@ -1,6 +1,5 @@ [Unit] Description=gonic service -ConditionPathExists=/var/lib/gonic/ After=network.target [Service] @@ -8,6 +7,9 @@ Type=simple User=gonic Group=gonic +StateDirectory=gonic +CacheDirectory=gonic + Restart=on-failure RestartSec=10 diff --git a/contrib/gonic.sysusers b/contrib/gonic.sysusers new file mode 100644 index 0000000..1fef6ba --- /dev/null +++ b/contrib/gonic.sysusers @@ -0,0 +1 @@ +u gonic - "user for gonic daemon" diff --git a/contrib/gonic.tmpfiles b/contrib/gonic.tmpfiles new file mode 100644 index 0000000..2dd59cb --- /dev/null +++ b/contrib/gonic.tmpfiles @@ -0,0 +1 @@ +d /var/cache/gonic 0775 gonic gonic 7d