Pull request: install check
Merge in DNS/adguard-home from 2453-install-check to master Closes #2453. Squashed commit of the following: commit b3123d7171ff5d1e00d8bcbb5cbe7fcf7a142a3c Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Dec 18 14:00:26 2020 +0300 all: fix quotes commit 27e17f9543250d912dd559c9ba2e01e35636551f Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Dec 18 13:34:00 2020 +0300 all: improve install script commit e9a927ffabc04dcd223bfc0b3b2541c7d5b96b61 Author: Eugene Burkov <e.burkov@adguard.com> Date: Fri Dec 18 13:22:05 2020 +0300 all: add directory emptiness check
This commit is contained in:
parent
5f84cb1afe
commit
49c55e356f
23
HACKING.md
23
HACKING.md
|
@ -163,12 +163,15 @@ The rules are mostly sorted in the alphabetical order.
|
|||
|
||||
## Shell Scripting
|
||||
|
||||
* Avoid bashisms, prefer *POSIX* features only.
|
||||
* Avoid bashisms and GNUisms, prefer *POSIX* features only.
|
||||
|
||||
* Prefer `'raw strings'` to `"double quoted strings"` whenever possible.
|
||||
|
||||
* Put spaces within `$( cmd )`, `$(( expr ))`, and `{ cmd; }`.
|
||||
|
||||
* Put utility flags in the ASCII order and **don't** group them together. For
|
||||
example, `ls -1 -A -q`.
|
||||
|
||||
* `snake_case`, not `camelCase`.
|
||||
|
||||
* Use `set -e -f -u` and also `set -x` in verbose mode.
|
||||
|
@ -176,6 +179,24 @@ The rules are mostly sorted in the alphabetical order.
|
|||
* Use the `"$var"` form instead of the `$var` form, unless word splitting is
|
||||
required.
|
||||
|
||||
* When concatenating, always use the form with curly braces to prevent
|
||||
accidental bad variable names. That is, `"${var}_tmp.txt"` and **not**
|
||||
`"$var_tmp.txt"`. The latter will try to lookup variable `var_tmp`.
|
||||
|
||||
* When concatenating, surround the whole string with quotes. That is, use
|
||||
this:
|
||||
|
||||
```sh
|
||||
dir="${TOP_DIR}/sub"
|
||||
```
|
||||
|
||||
And **not** this:
|
||||
|
||||
```sh
|
||||
# Bad!
|
||||
dir="${TOP_DIR}"/sub
|
||||
```
|
||||
|
||||
## Text, Including Comments
|
||||
|
||||
* End sentences with appropriate punctuation.
|
||||
|
|
|
@ -190,6 +190,7 @@ main() {
|
|||
SCRIPT_URL="https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh"
|
||||
URL="https://static.adguard.com/adguardhome/${CHANNEL}/${PKG_NAME}"
|
||||
OUT_DIR=/opt
|
||||
AGH_DIR="${OUT_DIR}/AdGuardHome"
|
||||
|
||||
# Root check
|
||||
if [ "$(id -u)" -eq 0 ]; then
|
||||
|
@ -208,22 +209,22 @@ main() {
|
|||
fi
|
||||
fi
|
||||
|
||||
log_info "AdGuard Home will be installed to ${OUT_DIR}/AdGuardHome"
|
||||
log_info "AdGuard Home will be installed to ${AGH_DIR}"
|
||||
|
||||
[ -d "${OUT_DIR}/AdGuardHome" ] && error_exit "Directory ${OUT_DIR}/AdGuardHome already exists, abort installation"
|
||||
[ -d "${AGH_DIR}" ] && [ -n "$(ls -1 -A -q ${AGH_DIR})" ] && error_exit "Directory ${AGH_DIR} is not empty, 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"
|
||||
${AGH_DIR}/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"
|
||||
log_info " sudo ${AGH_DIR}/AdGuardHome -s start|stop|restart|status|install|uninstall"
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Reference in New Issue