Skip to content

Commit

Permalink
add conffiles + logrotate + move config file to /etc/opt/adguardhome.…
Browse files Browse the repository at this point in the history
…yaml
  • Loading branch information
adelolmo committed Mar 20, 2021
1 parent 04616be commit 1cee747
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 82 deletions.
61 changes: 61 additions & 0 deletions Makefile
@@ -0,0 +1,61 @@
MAKEFLAGS += --silent

APP_HOME=opt/adguardhome
TAR_FILE = adguardhome-linux-$(VERSION)-$(ARCH).tar.bz2
TAR_URL = https://github.com/AdguardTeam/AdGuardHome/releases/download/v$(VERSION)/AdGuardHome_linux_$(TAR_ARCH).tar.gz

VERSION = 0.105.2

BUILD_DIR = build
RELEASE_DIR = $(BUILD_DIR)/release
TMP_DIR = $(BUILD_DIR)/tmp
TAR_CACHE = $(BUILD_DIR)/$(TAR_FILE)
PLATFORM := $(shell uname -m)

ARCH :=
ifeq ($(PLATFORM),x86_64)
ARCH = amd64
endif
ifeq ($(PLATFORM),aarch64)
ARCH = arm64
endif
ifeq ($(PLATFORM),armv7l)
ARCH = armhf
endif
TAR_ARCH :=
ifeq ($(ARCH),amd64)
TAR_ARCH = amd64
endif
ifeq ($(ARCH),i386)
TAR_ARCH = 386
endif
ifeq ($(ARCH),armhf)
TAR_ARCH = armv7
endif
ifeq ($(ARCH),arm64)
TAR_ARCH = arm64
endif

package: clean prepare $(TAR_CACHE) cp control
@echo Building package $(VERSION) $(ARCH)...
fakeroot dpkg-deb -b -z9 $(TMP_DIR) $(RELEASE_DIR)

clean:
rm -rf $(TMP_DIR) $(RELEASE_DIR)

prepare:
mkdir -p $(RELEASE_DIR) $(TMP_DIR)/$(APP_HOME)

$(TAR_CACHE):
@echo Downloading tar ball $(VERSION) $(TAR_ARCH)...
wget --quiet -O $(TAR_CACHE) $(TAR_URL)

cp:
cp -R deb/* $(TMP_DIR)
cp $(TAR_CACHE) $(TMP_DIR)/$(APP_HOME)
tar xf $(TAR_CACHE) --strip-components 2 --directory=$(TMP_DIR)/$(APP_HOME)
rm -rf $(TMP_DIR)/$(APP_HOME)/$(TAR_FILE)

control:
$(eval SIZE=$(shell du -sbk $(TMP_DIR)/ | grep -o '[0-9]*'))
sed -i "s/{{version}}/$(VERSION)/;s/{{size}}/$(SIZE)/;s/{{architecture}}/$(ARCH)/" $(TMP_DIR)/DEBIAN/control
47 changes: 21 additions & 26 deletions README.md
@@ -1,55 +1,50 @@
# AdGuardHome package for Debian and Ubuntu
Creates a Debian/Ubuntu package for `AdGuardHome`.
# AdGuardHome package for Debian
Creates a Debian package for `AdGuardHome`.

`AdGuardHome` is a network-wide ads & trackers blocking DNS server.

For more information about `AdGuardHome`, please visit https://adguard.com/en/adguard-home/overview.html and https://github.com/AdguardTeam/AdGuardHome
For more information about `AdGuardHome`, please visit https://adguard.com/en/adguard-home/overview.html
and https://github.com/AdguardTeam/AdGuardHome

## How to install
Select the package for your architecture (amd64, i386, armhf, arm64).
```
wget -O adguardhome.deb https://github.com/adelolmo/adguardhome-debian/releases/download/v0.98.1/adguardhome_0.98.1_armhf.deb
sudo dpkg -i adguardhome.deb
```

wget -O adguardhome.deb https://github.com/adelolmo/adguardhome-debian/releases/download/v0.102.0/adguardhome_0.102.0_armhf.deb
sudo dpkg -i adguardhome.deb

### How to use

Use `systemd` to manage the service `adguardhome`.

```
sudo systemctl start adguardhome
sudo systemctl stop adguardhome
sudo systemctl restart adguardhome
```
sudo systemctl start adguardhome
sudo systemctl stop adguardhome
sudo systemctl restart adguardhome

By default the dashboard is accessible under the port `http://localhost:3000`.
By default, the dashboard is accessible under the port `http://localhost:3000`.

### How to configure

The configuration file is located in `/etc/opt/adguardhome/AdGuardHome.yaml`.
The configuration file is located in `/etc/opt/adguardhome.yaml`.

The log output is created in `/var/log/adguardhome/adguardhome.log`.

AdGuardHome creates application files under `/var/opt/adguardhome` directory.
AdGuardHome creates runtime application files under `/var/opt/adguardhome` directory.

Instructions of how to configure `AdGuardHome` are out of the scope of this readme.
Refer to https://github.com/AdguardTeam/AdGuardHome/wiki for details about configuration.

## How to build

Clone the project.
git clone https://github.com/adelolmo/adguardhome-debian.git
make VERSION=0.105.2

```
git clone https://github.com/adelolmo/adguardhome-debian.git
```
The parameter `VERSION` is the version of `AdGuardHome`.
You can find all the releases of `AdGuardHome` [here](https://github.com/AdguardTeam/AdGuardHome/releases).

Then run the `package` script to download the create the package.
The debian package will be created under `build/releases`.

```
./package armhf 0.97.1
```
The first parameter is the system architecture, it must be one of: amd64, i386, armhf, arm64.
### Cross platform build

The second parameter is the version of `AdGuardHome`. You can find all the releases of `AdGuardHome` [here](https://github.com/AdguardTeam/AdGuardHome/releases).
Use the parameter `ARCH` with one of the following supported architectures: amd64, i386, armhf or arm64.

The debian package will be created under `build/releases`.
make VERSION=0.105.2 ARCH=armhf
1 change: 1 addition & 0 deletions deb/DEBIAN/conffiles
@@ -0,0 +1 @@
/etc/opt/adguardhome.yaml
9 changes: 9 additions & 0 deletions deb/DEBIAN/control
Expand Up @@ -5,4 +5,13 @@ Section: misc
Architecture: {{architecture}}
Maintainer: Andoni del Olmo <andoni.delolmo@gmail.com>
Installed-Size: {{size}}
Homepage: https://github.com/AdguardTeam/AdGuardHome
Description: Network-wide ads & trackers blocking DNS server
AdGuard Home is a network-wide software for blocking ads & tracking.
After you set it up, it'll cover ALL your home devices, and you don't need
any client-side software for that.
.
It operates as a DNS server that re-routes tracking domains to a
"black hole", thus preventing your devices from connecting to those servers.
It's based on software we use for our public AdGuard DNS servers -- both
share a lot of common code.
9 changes: 4 additions & 5 deletions deb/DEBIAN/postinst
Expand Up @@ -2,15 +2,14 @@

case "$1" in
configure|reconfigure)
mkdir -p /etc/opt/adguardhome
mkdir -p /var/opt/adguardhome
mkdir -p /var/log/adguardhome

ucf /usr/share/adguardhome/configuration /etc/opt/adguardhome/AdGuardHome.yaml
ucfr adguardhome /etc/opt/adguardhome/AdGuardHome.yaml
[ -f /etc/opt/adguardhome/AdGuardHome.yaml ] && \
mv /etc/opt/adguardhome/AdGuardHome.yaml /etc/opt/adguardhome.yaml
rm -rf /etc/opt/adguardhome

systemctl daemon-reload
systemctl enable adguardhome
systemctl enable --now adguardhome
systemctl restart adguardhome
;;

Expand Down
7 changes: 2 additions & 5 deletions deb/DEBIAN/postrm
Expand Up @@ -2,16 +2,13 @@

case "$1" in
remove)
systemctl daemon-reload
systemctl disable --now adguardhome
;;

purge)
rm -rf /var/opt/adguardhome
rm -rf /var/log/adguardhome
rm -rf /etc/opt/adguardhome/AdGuardHome.yaml
if which ucf >/dev/null; then
ucf --purge /etc/opt/adguardhome/AdGuardHome.yaml
fi
rm -f /etc/opt/adguardhome.yaml
;;

disappear|upgrade|failed-upgrade|abort-install|abort-upgrade)
Expand Down
6 changes: 6 additions & 0 deletions deb/etc/logrotate.d/adguardhome
@@ -0,0 +1,6 @@
/var/log/adguardhome/adguardhome.log {
missingok
notifempty
compress
delaycompress
}
Expand Up @@ -3,4 +3,4 @@ dns:
port: 53
bootstrap_dns:
- 1.1.1.1:53
safebrowsing_enabled: true
safebrowsing_enabled: true
2 changes: 1 addition & 1 deletion deb/lib/systemd/system/adguardhome.service
Expand Up @@ -8,7 +8,7 @@ Type=simple
UMask=022
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/opt/adguardhome/AdGuardHome --config /etc/opt/adguardhome/AdGuardHome.yaml --work-dir /var/opt/adguardhome --logfile /var/log/adguardhome/adguardhome.log --no-check-update
ExecStart=/opt/adguardhome/AdGuardHome --config /etc/opt/adguardhome.yaml --work-dir /var/opt/adguardhome --logfile /var/log/adguardhome/adguardhome.log --no-check-update
Restart=on-failure
RestartSec=10
StandardOutput=syslog+console
Expand Down
44 changes: 0 additions & 44 deletions package

This file was deleted.

0 comments on commit 1cee747

Please sign in to comment.