mirror of
https://github.com/AdguardTeam/AdGuardDNS.git
synced 2025-02-20 11:23:36 +08:00
Initial commit
This commit is contained in:
commit
5e30ec5c95
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*.deb
|
||||
/go_*
|
60
Makefile
Normal file
60
Makefile
Normal file
@ -0,0 +1,60 @@
|
||||
NAME=adguard-internal-dns
|
||||
VERSION=$(version)
|
||||
MAINTAINER="AdGuard Web Team"
|
||||
USER="dns"
|
||||
SHELL := /bin/bash
|
||||
|
||||
.PHONY: default
|
||||
default: repo
|
||||
|
||||
GOPATH=$(shell pwd)/go_$(VERSION)
|
||||
|
||||
clean:
|
||||
rm -fv *.deb
|
||||
|
||||
## replace bit.adguard.com with github and remove ln -s once we push adguard-dns to github
|
||||
build: check-vars clean
|
||||
mkdir -p $(GOPATH)
|
||||
GOPATH=$(GOPATH) go get -v -d -insecure bit.adguard.com/dns/adguard-dns
|
||||
GOPATH=$(GOPATH) go get -v -d github.com/coredns/coredns
|
||||
mkdir -p $(GOPATH)/src/github.com/AdguardTeam
|
||||
ln -s $(GOPATH)/src/bit.adguard.com/dns/adguard-dns $(GOPATH)/src/github.com/AdguardTeam/AdguardDNS
|
||||
cp plugin.cfg $(GOPATH)/src/github.com/coredns/coredns
|
||||
cd $(GOPATH)/src/github.com/coredns/coredns; GOPATH=$(GOPATH) go generate
|
||||
cd $(GOPATH)/src/github.com/coredns/coredns; GOPATH=$(GOPATH) go get -v -d -t .
|
||||
cd $(GOPATH)/src/github.com/coredns/coredns; GOPATH=$(GOPATH) PATH=$(GOPATH)/bin:$(PATH) make
|
||||
cd $(GOPATH)/src/github.com/coredns/coredns; GOPATH=$(GOPATH) go build -x -v -ldflags="-X github.com/coredns/coredns/coremain.GitCommit=$(VERSION)" -o $(GOPATH)/bin/coredns
|
||||
|
||||
package: build
|
||||
fpm --prefix /opt/$(NAME) \
|
||||
--deb-user $(USER) \
|
||||
--after-install postinstall.sh \
|
||||
--after-remove postrm.sh \
|
||||
--before-install preinstall.sh \
|
||||
--before-remove prerm.sh \
|
||||
--template-scripts \
|
||||
--template-value user=$(USER) \
|
||||
--template-value project=$(NAME) \
|
||||
--template-value version=1.$(VERSION) \
|
||||
--license proprietary \
|
||||
--url https://adguard.com/adguard-dns/overview.html \
|
||||
--category non-free/web \
|
||||
--description "AdGuard DNS (internal)" \
|
||||
--deb-no-default-config-files \
|
||||
-v 1.$(VERSION) \
|
||||
-s dir \
|
||||
-t deb \
|
||||
-n $(NAME) \
|
||||
-m $(MAINTAINER) \
|
||||
--vendor $(MAINTAINER) \
|
||||
-C go_$(VERSION)/bin \
|
||||
coredns
|
||||
|
||||
repo: package
|
||||
for package in *.deb ; do freight-add $$package apt/jessie/non-free ; done
|
||||
freight-cache
|
||||
|
||||
check-vars:
|
||||
ifndef version
|
||||
$(error VERSION is undefined)
|
||||
endif
|
33
plugin.cfg
Normal file
33
plugin.cfg
Normal file
@ -0,0 +1,33 @@
|
||||
# Directives are registered in the order they should be
|
||||
# executed.
|
||||
#
|
||||
# Ordering is VERY important. Every plugin will
|
||||
# feel the effects of all other plugin below
|
||||
# (after) them during a request, but they must not
|
||||
# care what plugin above them are doing.
|
||||
|
||||
# How to rebuild with updated plugin configurations:
|
||||
# Modify the list below and run `go gen && go build`
|
||||
|
||||
# The parser takes the input format of
|
||||
# <plugin-name>:<package-name>
|
||||
# Or
|
||||
# <plugin-name>:<fully-qualified-package-name>
|
||||
#
|
||||
# External plugin example:
|
||||
# log:github.com/coredns/coredns/plugin/log
|
||||
# Local plugin example:
|
||||
# log:log
|
||||
|
||||
bind:bind
|
||||
debug:debug
|
||||
pprof:pprof
|
||||
prometheus:metrics
|
||||
errors:errors
|
||||
log:log
|
||||
ratelimit:github.com/AdguardTeam/AdguardDNS/coredns_plugin/ratelimit
|
||||
refuseany:github.com/AdguardTeam/AdguardDNS/coredns_plugin/refuseany
|
||||
dnsfilter:github.com/AdguardTeam/AdguardDNS/coredns_plugin
|
||||
cache:cache
|
||||
file:file
|
||||
forward:forward
|
35
postinstall.sh
Normal file
35
postinstall.sh
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
set -e -x -o pipefail
|
||||
echo "executing $0"
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
if ! getent passwd "<%= user %>" > /dev/null ; then
|
||||
echo "Adding user for <%= project %>" >&2
|
||||
|
||||
adduser --system -ingroup nogroup --quiet \
|
||||
--no-create-home \
|
||||
--disabled-login \
|
||||
--gecos "<%= project %> user" \
|
||||
--shell /bin/bash "<%= user %>"
|
||||
fi
|
||||
URL="https://filters.adtidy.org/android/filters/15.txt"
|
||||
OUTFILE="/var/lib/dnsfilter/dns.txt"
|
||||
|
||||
mkdir -p /var/lib/dnsfilter
|
||||
wget -q --timeout=90 "$URL" -O "$OUTFILE"
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Filter rules could not be downloaded."
|
||||
fi
|
||||
|
||||
# Link logs dir (Required for request logs)
|
||||
ln -s /var/log/<%= project %> /opt/<%= project %>/logs
|
||||
|
||||
chown -R <%= user %>: /opt/<%= project %>
|
||||
;;
|
||||
*)
|
||||
echo "postinst called with unknown argument \`$1'" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
6
postrm.sh
Normal file
6
postrm.sh
Normal file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
set -e -x -o pipefail
|
||||
echo "executing $0"
|
||||
|
||||
# Unlink logs dir
|
||||
rm -rf /opt/<%= project %>/logs
|
3
preinstall.sh
Normal file
3
preinstall.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
set -e -x -o pipefail
|
||||
echo "executing $0"
|
Loading…
x
Reference in New Issue
Block a user