Skip to content

Commit

Permalink
Build deb package
Browse files Browse the repository at this point in the history
  • Loading branch information
arnested committed Jan 6, 2021
1 parent 0c8ce8e commit 203219a
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 135 deletions.
25 changes: 25 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,28 @@ release:
# If set to true, will mark the release as not ready for production.
# Default is false.
prerelease: auto

nfpms:
-
vendor: Arne Jørgensen
maintainer: Arne Jørgensen <arne@arnested.dk>
description: Local Docker Development DNS
license: MIT
formats:
- deb
dependencies:
- docker.io
- libsystemd0
bindir: /usr/libexec
contents:
- src: ldddns.service
dst: /lib/systemd/system/ldddns.service
type: config

- src: ldddns.env
dst: /etc/default/ldddns
type: config
scripts:
postinstall: "scripts/postinstall.sh"
preremove: "scripts/preremove.sh"
postremove: "scripts/postremove.sh"
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ https://my-fancy.local).

## Install

Download the `.deb` file and run:

```console
curl -fsSL https://raw.githubusercontent.com/arnested/ldddns/main/install.sh | bash
sudo dpkg -i ldddns_0.0.16_linux_amd64.deb
```
51 changes: 0 additions & 51 deletions install.sh

This file was deleted.

1 change: 1 addition & 0 deletions ldddns.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DOCKER_API_VERSION=1.40
39 changes: 39 additions & 0 deletions ldddns.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[Unit]
Description=Local Docker Development DNS
BindTo=docker.service
After=docker.service

[Service]
Type=notify
EnvironmentFile=-/etc/default/ldddns
ExecStart=/usr/libexec/ldddns
SuccessExitStatus=15
Restart=on-failure
DynamicUser=yes
SupplementaryGroups=docker
CapabilityBoundingSet=
DevicePolicy=closed
IPAddressDeny=any
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
PrivateDevices=yes
PrivateNetwork=yes
PrivateUsers=yes
ProtectClock=yes
ProtectControlGroups=yes
ProtectHome=yes
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
RestrictAddressFamilies=AF_UNIX
RestrictNamespaces=yes
RestrictRealtime=yes
SystemCallArchitectures=native
SystemCallErrorNumber=EPERM
SystemCallFilter=@system-service
UMask=0777

[Install]
WantedBy=docker.service
11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ import (
"github.com/holoplot/go-avahi"
)

func main() {
if len(os.Args) < 2 || os.Args[1] != "service" {
installService()
os.Exit(0)
}
// Version string to be set at compile time via command line (-ldflags "-X main.version=1.2.3").
var (
version string
)

func main() {
logf(PriNotice, "Starting ldddns %s...", version)
// Setup stuff.
docker, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
Expand Down
17 changes: 17 additions & 0 deletions scripts/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

set -e

docker_version=$(/usr/bin/docker version --format '{{ .Server.APIVersion }}')

/usr/bin/sed -i "s/\(DOCKER_API_VERSION=\).*/\1${docker_version}/" /etc/default/ldddns

/bin/systemctl daemon-reload

if /bin/systemctl is-active --quiet ldddns.service; then
/bin/systemctl restart ldddns.service
fi

if ! /bin/systemctl is-enabled --quiet ldddns.service; then
/bin/systemctl enable --now ldddns.service;
fi
5 changes: 5 additions & 0 deletions scripts/postremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

set -e

/bin/systemctl daemon-reload
11 changes: 11 additions & 0 deletions scripts/preremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -e

if /bin/systemctl is-active --quiet ldddns.service; then
/bin/systemctl stop ldddns.service
fi

if /bin/systemctl is-enabled --quiet ldddns.service; then
/bin/systemctl disable --now ldddns.service;
fi
78 changes: 0 additions & 78 deletions service.go

This file was deleted.

0 comments on commit 203219a

Please sign in to comment.