Merge: + install.sh
Merge in DNS/adguard-home from install.sh to master
Fix #995
Squashed commit of the following:
commit 81a5b6385574fa5bc14f7e9cc8cd707fcdc491c3
Merge: 825062a9 fb7ca942
Author: Andrey Meshkov <am@adguard.com>
Date: Wed Oct 7 20:40:30 2020 +0300
Merge branch 'master' into install.sh
commit 825062a9cb77447bec0967635bde334218437e1f
Author: Andrey Meshkov <am@adguard.com>
Date: Wed Oct 7 20:04:04 2020 +0300
minor fixes
commit 22205d80479a1f894fe6c72afe22ba555a9e611e
Author: Andrey Meshkov <am@adguard.com>
Date: Wed Oct 7 20:01:56 2020 +0300
* (home): fix install script
commit 073b5fb8e27351094b95d85335dd3d08f65f9ee8
Author: Andrey Meshkov <am@adguard.com>
Date: Wed Oct 7 19:59:07 2020 +0300
* (home): update readme and install script
commit d4d2e4c35ca1ea1f365e40081098ee9398196ef3
Author: Andrey Meshkov <am@adguard.com>
Date: Wed Oct 7 14:43:49 2020 +0300
disable parallel build
commit a639b9ae44c534c7fdecd34894f5ad4ae6217472
Author: Andrey Meshkov <am@adguard.com>
Date: Wed Oct 7 02:48:52 2020 +0300
* (home): improve install.sh
commit 4c564da714850002d1810d4d10dce859f340e3ab
Author: Simon Zolin <s.zolin@adguard.com>
Date: Thu Oct 1 15:32:53 2020 +0300
minor
commit 0ecc1a03a41201a632f650ba995f3b07a6539889
Author: Simon Zolin <s.zolin@adguard.com>
Date: Thu Oct 1 15:08:07 2020 +0300
* install.sh: use /opt/AdGuardHome output directory
commit fd3ad73606c69e8ede086e67bc557772f9e34406
Author: Simon Zolin <s.zolin@adguard.com>
Date: Wed Sep 30 12:13:56 2020 +0300
* install.sh: prompt for an output directory
commit 8917e8cb3d794cfa1fd7b358c89695ff719e7e4d
Author: Simon Zolin <s.zolin@adguard.com>
Date: Tue Sep 29 18:56:54 2020 +0300
+ install.sh
This commit is contained in:
parent
fb7ca94243
commit
65acfb75dd
4
Makefile
4
Makefile
|
@ -56,10 +56,10 @@ ifeq ($(CHANNEL),edge)
|
|||
endif
|
||||
|
||||
# goreleaser command depends on the $CHANNEL
|
||||
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot
|
||||
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --snapshot --parallelism 1
|
||||
ifneq ($(CHANNEL),edge)
|
||||
# If this is not an "edge" build, use normal release command
|
||||
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish
|
||||
GORELEASER_COMMAND=goreleaser release --rm-dist --skip-publish --parallelism 1
|
||||
endif
|
||||
|
||||
# Version properties
|
||||
|
|
35
README.md
35
README.md
|
@ -64,14 +64,29 @@ It operates as a DNS server that re-routes tracking domains to a "black hole," t
|
|||
<a id="getting-started"></a>
|
||||
## Getting Started
|
||||
|
||||
Please read the **[Getting Started](https://github.com/AdguardTeam/AdGuardHome/wiki/Getting-Started)** article on our Wiki to learn how to install AdGuard Home, and how to configure your devices to use it.
|
||||
### Automated install (Linux and Mac)
|
||||
Run the following command in your terminal:
|
||||
```
|
||||
curl -sSL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh
|
||||
```
|
||||
|
||||
### Alternative methods
|
||||
|
||||
#### Manual installation
|
||||
|
||||
Please read the **[Getting Started](https://github.com/AdguardTeam/AdGuardHome/wiki/Getting-Started)** article on our Wiki to learn how to install AdGuard Home manually, and how to configure your devices to use it.
|
||||
|
||||
#### Docker
|
||||
|
||||
You can use our [official Docker image](https://hub.docker.com/r/adguard/adguardhome).
|
||||
|
||||
#### Snap Store
|
||||
|
||||
If you're running **Linux**, there's a secure and easy way to install AdGuard Home - you can get it from the [Snap Store](https://snapcraft.io/adguard-home).
|
||||
|
||||
Alternatively, you can use our [official Docker image](https://hub.docker.com/r/adguard/adguardhome).
|
||||
|
||||
### Guides
|
||||
|
||||
* [FAQ](https://github.com/AdguardTeam/AdGuardHome/wiki/FAQ)
|
||||
* [Configuration](https://github.com/AdguardTeam/AdGuardHome/wiki/Configuration)
|
||||
* [AdGuard Home as a DNS-over-HTTPS or DNS-over-TLS server](https://github.com/AdguardTeam/AdGuardHome/wiki/Encryption)
|
||||
* [How to install and run AdGuard Home on Raspberry Pi](https://github.com/AdguardTeam/AdGuardHome/wiki/Raspberry-Pi)
|
||||
|
@ -228,13 +243,17 @@ There are three options how you can install an unstable version:
|
|||
|
||||
1. [Snap Store](https://snapcraft.io/adguard-home) -- look for "beta" and "edge" channels there.
|
||||
2. [Docker Hub](https://hub.docker.com/r/adguard/adguardhome) -- look for "beta" and "edge" tags there.
|
||||
3. Standalone builds. Look for the available builds below.
|
||||
3. Standalone builds. Use the automated installation script or look for the available builds below.
|
||||
|
||||
There are three options how you can install an unstable version.
|
||||
Beta:
|
||||
```
|
||||
curl -sSL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s beta
|
||||
```
|
||||
|
||||
1. You can either install AdGuard Home from "beta" or "edge" distribution channel which we update periodically. If you're already using stable version of AdGuard Home, just replace the executable file with a new one.
|
||||
2. You can use the Docker image from the `edge` tag, which is synced with the repo master branch.
|
||||
3. You can install AdGuard Home from `beta` or `edge` channels on the Snap Store.
|
||||
Edge:
|
||||
```
|
||||
curl -sSL https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s edge
|
||||
```
|
||||
|
||||
* Beta channel builds
|
||||
* Linux: [64-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_amd64.tar.gz), [32-bit](https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_386.tar.gz)
|
||||
|
|
|
@ -0,0 +1,229 @@
|
|||
#!/bin/sh
|
||||
|
||||
# AdGuardHome installation script
|
||||
#
|
||||
# 1. Download the package
|
||||
# 2. Unpack it
|
||||
# 3. Install as a service
|
||||
#
|
||||
# Requirements:
|
||||
# . bash
|
||||
# . which
|
||||
# . printf
|
||||
# . uname
|
||||
# . id
|
||||
# . head, tail
|
||||
# . curl
|
||||
# . tar or unzip
|
||||
# . rm
|
||||
|
||||
set -e
|
||||
|
||||
log_info()
|
||||
{
|
||||
printf "[info] %s\\n" "$1"
|
||||
}
|
||||
|
||||
log_error()
|
||||
{
|
||||
printf "[error] %s\\n" "$1"
|
||||
}
|
||||
|
||||
# Get OS
|
||||
# Return: darwin, linux, freebsd
|
||||
detect_os()
|
||||
{
|
||||
UNAME_S="$(uname -s)"
|
||||
OS=
|
||||
case "$UNAME_S" in
|
||||
Linux)
|
||||
OS=linux
|
||||
;;
|
||||
|
||||
FreeBSD)
|
||||
OS=freebsd
|
||||
;;
|
||||
|
||||
Darwin)
|
||||
OS=darwin
|
||||
;;
|
||||
|
||||
*)
|
||||
return 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
echo $OS
|
||||
}
|
||||
|
||||
# Get CPU endianness
|
||||
# Return: le, ""
|
||||
cpu_little_endian()
|
||||
{
|
||||
ENDIAN_FLAG="$(head -c 6 /bin/bash | tail -c 1)"
|
||||
if [ "$ENDIAN_FLAG" = "$(printf '\001')" ]; then
|
||||
echo 'le'
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Get CPU
|
||||
# Return: amd64, 386, armv5, armv6, armv7, arm64, mips_softfloat, mipsle_softfloat, mips64_softfloat, mips64le_softfloat
|
||||
detect_cpu()
|
||||
{
|
||||
UNAME_M="$(uname -m)"
|
||||
CPU=
|
||||
|
||||
case "$UNAME_M" in
|
||||
|
||||
x86_64 | x86-64 | x64 | amd64)
|
||||
CPU=amd64
|
||||
;;
|
||||
|
||||
i386 | i486 | i686 | i786 | x86)
|
||||
CPU=386
|
||||
;;
|
||||
|
||||
armv5l)
|
||||
CPU=armv5
|
||||
;;
|
||||
|
||||
armv6l)
|
||||
CPU=armv6
|
||||
;;
|
||||
|
||||
armv7l | armv8l)
|
||||
CPU=armv7
|
||||
;;
|
||||
|
||||
aarch64)
|
||||
CPU=arm64
|
||||
;;
|
||||
|
||||
mips)
|
||||
LE=$(cpu_little_endian)
|
||||
CPU=mips${LE}_softfloat
|
||||
;;
|
||||
|
||||
mips64)
|
||||
LE=$(cpu_little_endian)
|
||||
CPU=mips64${LE}_softfloat
|
||||
;;
|
||||
|
||||
*)
|
||||
return 1
|
||||
|
||||
esac
|
||||
|
||||
echo "${CPU}"
|
||||
}
|
||||
|
||||
# Get package file name extension
|
||||
# Return: tar.gz, zip
|
||||
package_extension()
|
||||
{
|
||||
if [ "$OS" = "darwin" ]; then
|
||||
echo "zip"
|
||||
return 0
|
||||
fi
|
||||
echo "tar.gz"
|
||||
}
|
||||
|
||||
# Download data to a file
|
||||
# Use: download URL OUTPUT
|
||||
download()
|
||||
{
|
||||
log_info "Downloading package from $1 -> $2"
|
||||
if is_command curl ; then
|
||||
curl -s "$1" --output "$2" || error_exit "Failed to download $1"
|
||||
else
|
||||
error_exit "curl is necessary to install AdGuard Home"
|
||||
fi
|
||||
}
|
||||
|
||||
# Unpack package to a directory
|
||||
# Use: unpack INPUT OUTPUT_DIR PKG_EXT
|
||||
unpack()
|
||||
{
|
||||
log_info "Unpacking package from $1 -> $2"
|
||||
mkdir -p "$2"
|
||||
if [ "$3" = "zip" ]; then
|
||||
unzip -qq "$1" -d "$2" || return 1
|
||||
elif [ "$3" = "tar.gz" ]; then
|
||||
tar xzf "$1" -C "$2" || return 1
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Print error message and exit
|
||||
# Use: error_exit MESSAGE
|
||||
error_exit()
|
||||
{
|
||||
log_error "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check if command exists
|
||||
# Use: is_command COMMAND
|
||||
is_command() {
|
||||
check_command="$1"
|
||||
command -v "${check_command}" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Entry point
|
||||
main() {
|
||||
log_info "Starting AdGuard Home installation script"
|
||||
|
||||
CHANNEL=${1}
|
||||
if [ "${CHANNEL}" != "beta" ] && [ "${CHANNEL}" != "edge" ]; then
|
||||
CHANNEL=release
|
||||
fi
|
||||
log_info "Channel ${CHANNEL}"
|
||||
|
||||
OS=$(detect_os) || error_exit "Cannot detect your OS"
|
||||
CPU=$(detect_cpu) || error_exit "Cannot detect your CPU"
|
||||
PKG_EXT=$(package_extension)
|
||||
PKG_NAME=AdGuardHome_${OS}_${CPU}.${PKG_EXT}
|
||||
|
||||
SCRIPT_URL="https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh"
|
||||
URL="https://static.adguard.com/adguardhome/${CHANNEL}/${PKG_NAME}"
|
||||
OUT_DIR=/opt
|
||||
|
||||
# Root check
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
log_info "Script called with root privileges"
|
||||
else
|
||||
if is_command sudo ; then
|
||||
log_info "Please note, that AdGuard Home requires root privileges to install using this script."
|
||||
log_info "Restarting with root privileges"
|
||||
|
||||
exec curl -sSL ${SCRIPT_URL} | sudo sh -s "$@"
|
||||
exit $?
|
||||
else
|
||||
log_info "Root privileges are required to install AdGuard Home using this installer."
|
||||
log_info "Please, re-run this script as root."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
log_info "AdGuard Home will be installed to ${OUT_DIR}/AdGuardHome"
|
||||
|
||||
[ -d "${OUT_DIR}/AdGuardHome" ] && error_exit "Directory ${OUT_DIR}/AdGuardHome already exists, abort installation"
|
||||
|
||||
download "${URL}" "${PKG_NAME}" || error_exit "Cannot download the package"
|
||||
|
||||
unpack "${PKG_NAME}" "${OUT_DIR}" "${PKG_EXT}" || error_exit "Cannot unpack the package"
|
||||
|
||||
# Install AdGuard Home service and run it
|
||||
${OUT_DIR}/AdGuardHome/AdGuardHome -s install || error_exit "Cannot install AdGuardHome as a service"
|
||||
|
||||
rm "${PKG_NAME}"
|
||||
|
||||
log_info "AdGuard Home is now installed and running."
|
||||
log_info "You can control the service status with the following commands:"
|
||||
log_info " sudo ${OUT_DIR}/AdGuardHome/AdGuardHome -s start|stop|restart|status|install|uninstall"
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Reference in New Issue