diff --git a/README.md b/README.md index 56317e0..1044475 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,50 @@ services: then start with `docker-compose up -d` +**Installation with systemd** (on ubuntu 18.04) + +Prerequisites: + +```bash +Add a repository with the latest Version of golang and install the prerequisites: +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 +``` + +Download and compile gonic in the home directory + +```bash +go get go.senan.xyz/gonic/cmd/gonic +``` + +Add a gonic user and create a directory for the server: + +```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/ +``` + +Add your music-path to the config file + +```bash +sudo nano /var/gonic/config +``` + +Setup systemd service: + +```bash +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 +``` + + + ## configuration options |env var|command line arg|description| diff --git a/contrib/config b/contrib/config new file mode 100644 index 0000000..52ec86a --- /dev/null +++ b/contrib/config @@ -0,0 +1,7 @@ +music-path +cache-path /tmp/gonic_cache +db-path /var/gonic/gonic.db +jukebox-enabled false +listen-addr 127.0.0.1:4747 +proxy-prefix /gonic +scan-interval 0 diff --git a/contrib/gonic.service b/contrib/gonic.service new file mode 100644 index 0000000..71508f1 --- /dev/null +++ b/contrib/gonic.service @@ -0,0 +1,28 @@ +[Unit] +Description=Gonic service +ConditionPathExists=/var/gonic/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 + +[Install] +WantedBy=multi-user.target