Skip to content

Commit

Permalink
feat(contrib): improve system related contrib files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zpuskas authored and sentriz committed Feb 22, 2023
1 parent 5dcc8c1 commit ac74b35
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 8 deletions.
59 changes: 52 additions & 7 deletions contrib/config
Original file line number Diff line number Diff line change
@@ -1,7 +1,52 @@
music-path <path to your music dir>
podcast-path <path to your podcasts dir>
cache-path <path to cache dir>
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 <angle brackets>.

# 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 <prefix>

# Secure connection settings. Recommended to set up unless gonic sits behing an
# SSL enabled reverse proxy server. Disabled by default.
#tls-cert <path to TLS certificatie>
#tls-key <path to TLS private 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 your music dir>

# Path to downloaded podcast files. Must be specified. E.g.:
# podcast-path /var/cache/podcast
podcast-path <path to your podcasts dir>

# 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 <extra command line arguments to pass to the jukebox mpv daemon>

# A string or character to split genre tags on for multi-genre support (e.g. ;)
#genre-split ;
4 changes: 3 additions & 1 deletion contrib/gonic.service
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[Unit]
Description=gonic service
ConditionPathExists=/var/lib/gonic/
After=network.target

[Service]
Type=simple
User=gonic
Group=gonic

StateDirectory=gonic
CacheDirectory=gonic

Restart=on-failure
RestartSec=10

Expand Down
1 change: 1 addition & 0 deletions contrib/gonic.sysusers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
u gonic - "user for gonic daemon"
1 change: 1 addition & 0 deletions contrib/gonic.tmpfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d /var/cache/gonic 0775 gonic gonic 7d

0 comments on commit ac74b35

Please sign in to comment.