diff --git a/Dockerfile b/Dockerfile index 89e045b..d28d192 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM golang:1 AS build-env +FROM arm32v7/golang:1.12 AS build-env -WORKDIR /go/src/github.com/uxbh/ztdns +WORKDIR /go/src/github.com/davidwatkins/ztdns # Add source COPY . . diff --git a/README.md b/README.md index db1131a..d6d77eb 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ If you prefer the traditional installation route: If you do not want to store your API access token in the configuration file you can also run the server with the `env` command: `env 'ZTDNS_ZT.API=<>' ./ztdns server` 4. Run `ztdns mkconfig` to generate a sample configuration file. -5. Add your API access token, Network names and IDs, and interface name to the configuration. +5. Add your API access token, Network names and IDs, and interface name to the configuration. Make sure you call ifconfig to determine your zerotier interface name. It won't always be zt0. 6. Start the server using `ztdns server`. 7. Add a DNS entry in your ZeroTier members pointing to the member running ztdns. @@ -41,6 +41,51 @@ dig @serveraddress member.domain.zt AAAA ping member.domain.zt ``` +### Service + +If you want to create a service so this starts on boot for Ubuntu, first add a bash script which spins up the server. I called mine `start-ztdns-server`: + +```bash +#!/bin/sh +/path/to/ztdns server +``` + +Then add `ztdns.service` to `/etc/systemd/system/`. Make sure whatever you set `WorkingDirectory` to contains the .ztdns.toml configuration file. + +```bash +[Unit] +Description=Zerotier DNS Server +[Service] +User= +# The configuration file application.properties should be here: +#change this to your workspace +WorkingDirectory=/path/containing/ztdns_config/ +#path to executable. +#executable is a bash script which calls jar file +ExecStart=/path/to/start-ztdns-server +SuccessExitStatus=143 +TimeoutStopSec=10 +Restart=on-failure +RestartSec=5 +[Install] +WantedBy=multi-user.target +``` + +Then run systemctl enable and start: + +```bash +sudo systemctl daemon-reload +sudo systemctl enable ztdns.service +sudo systemctl start ztdns.service +``` + +If you want to stop the service + +```bash +sudo systemctl stop ztdns.service +sudo systemctl disable ztdns.service +``` + ### Docker If you prefer to run the server with Docker: diff --git a/cmd/mkconfig.go b/cmd/mkconfig.go index 61a0df6..3c8f39b 100644 --- a/cmd/mkconfig.go +++ b/cmd/mkconfig.go @@ -6,7 +6,7 @@ package cmd import ( "os" - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) diff --git a/cmd/server.go b/cmd/server.go index f8eb536..a9cb1e7 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -8,11 +8,11 @@ import ( "net" "time" - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/uxbh/ztdns/dnssrv" - "github.com/uxbh/ztdns/ztapi" + "github.com/davidwatkins/ztdns/dnssrv" + "github.com/davidwatkins/ztdns/ztapi" ) // serverCmd represents the server command diff --git a/dnssrv/dnssrv.go b/dnssrv/dnssrv.go index 20c8070..953b6c9 100644 --- a/dnssrv/dnssrv.go +++ b/dnssrv/dnssrv.go @@ -9,7 +9,7 @@ import ( "net" "time" - log "github.com/Sirupsen/logrus" + log "github.com/sirupsen/logrus" "github.com/miekg/dns" ) diff --git a/docker-compose.yml b/docker-compose.yml index 5464abf..907be48 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,8 @@ -version: '3' +version: '2' services: ztdns: build: . + restart: always ports: - "5356:53/udp" volumes: diff --git a/main.go b/main.go index db3b1cc..27eb61e 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,7 @@ package main -import "github.com/uxbh/ztdns/cmd" +import "github.com/davidwatkins/ztdns/cmd" func main() { cmd.Execute()