From ef6dd6c82a638dcd8aa3254839e2f53580a4ef46 Mon Sep 17 00:00:00 2001 From: sentriz Date: Tue, 11 May 2021 23:59:14 +0100 Subject: [PATCH] fix(docs): update ubuntu / systemd service instructions fixes #126 --- README.md | 58 +++++++++++++++++++++++++++---------------- contrib/config | 9 +++---- contrib/gonic.service | 17 +++---------- 3 files changed, 43 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index a2d9124b..9f5d42fc 100644 --- a/README.md +++ b/README.md @@ -86,47 +86,61 @@ then start with `docker-compose up -d` ### ...with systemd -example by @IUCCA, tested on Ubuntu 18.04 +tested on Ubuntu 21.04 -1. add a repository with the latest Version of golang and install the prerequisites +1. install **go 1.16 or newer**, check version, and install dependencies -```bash -$ sudo add-apt-repository ppa:longsleep/golang-backports -$ sudo apt update && sudo apt upgrade -$ sudo apt install build-essential git sqlite libtag1-dev ffmpeg libasound-dev golang +```shell +$ sudo apt update +$ sudo apt install golang + +$ go version +go version go1.16.2 linux/amd64 + +$ sudo apt install build-essential git sqlite libtag1-dev ffmpeg libasound-dev ``` -2. download and compile gonic in the home directory +2. install / compile gonic globally, and check version -```bash -$ go get go.senan.xyz/gonic/cmd/gonic +```shell +$ sudo GOBIN=/usr/local/bin go install go.senan.xyz/gonic/cmd/gonic@latest + +$ gonic -version +v0.14.0 ``` -3. add a gonic user and create a directory for the server +3. add a gonic user, create a data directory, and install a config file -```bash -$ sudo mkdir -p /var/gonic/ -$ sudo adduser --disabled-login --gecos "" gonic -$ sudo mv go/bin/gonic /var/gonic/ -$ sudo wget https://raw.githubusercontent.com/sentriz/gonic/master/contrib/config -O /var/gonic/config -$ sudo chmod -R 750 /var/gonic/ -$ sudo chown -R gonic:gonic /var/gonic/ +```shell +$ sudo adduser --system --no-create-home --group gonic +$ sudo mkdir -p /var/lib/gonic/ /etc/gonic/ +$ sudo chown -R gonic:gonic /var/lib/gonic/ +$ sudo wget https://raw.githubusercontent.com/sentriz/gonic/master/contrib/config -O /etc/gonic/config ``` -4. add your `music-path` to the config file +4. update the config with your `music-path`, `podcast-path`, etc -```bash -$ sudo nano /var/gonic/config +```shell +$ sudo nano /etc/gonic/config +music-path +podcast-path +cache-path ``` -5. setup systemd service +5. install the systemd service, check status or logs -```bash +```shell $ sudo wget https://raw.githubusercontent.com/sentriz/gonic/master/contrib/gonic.service -O /etc/systemd/system/gonic.service $ sudo systemctl daemon-reload $ sudo systemctl enable --now gonic + +$ systemctl status gonic # check status, should be active (running) +$ journalctl --follow --unit gonic # check logs ``` +should be installed and running on boot now 👍 +view the admin UI at http://localhost:4747 + ### ...elsewhere [![](https://repology.org/badge/vertical-allrepos/gonic.svg)](https://repology.org/project/gonic/versions) diff --git a/contrib/config b/contrib/config index 621d66c7..3f689a26 100644 --- a/contrib/config +++ b/contrib/config @@ -1,8 +1,7 @@ -music-path -cache-path /tmp/gonic_cache -db-path /var/gonic/gonic.db +music-path +podcast-path +cache-path +db-path /var/lib/gonic/gonic.db jukebox-enabled false listen-addr 127.0.0.1:4747 -proxy-prefix /gonic scan-interval 0 -podcast-path diff --git a/contrib/gonic.service b/contrib/gonic.service index 71508f1a..4a2128ff 100644 --- a/contrib/gonic.service +++ b/contrib/gonic.service @@ -1,28 +1,17 @@ [Unit] -Description=Gonic service -ConditionPathExists=/var/gonic/gonic +Description=gonic service +ConditionPathExists=/var/lib/gonic/ After=network.target [Service] Type=simple User=gonic Group=gonic -LimitNOFILE=1024 Restart=on-failure RestartSec=10 -WorkingDirectory=/var/gonic/ -ExecStart=/var/gonic/gonic -config-path /var/gonic/config - -# make sure log directory exists and owned by syslog -PermissionsStartOnly=true -ExecStartPre=/bin/mkdir -p /var/log/gonic -ExecStartPre=/bin/chown syslog:adm /var/log/gonic -ExecStartPre=/bin/chmod 755 /var/log/gonic -StandardOutput=syslog -StandardError=syslog -SyslogIdentifier=sleepservice +ExecStart=/usr/local/bin/gonic -config-path /etc/gonic/config [Install] WantedBy=multi-user.target