mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-07-13 00:22:53 +02:00
This commit is contained in:
+11
-14
@@ -39,23 +39,20 @@ _mktemp() {
|
|||||||
|
|
||||||
# Check for script dependencies
|
# Check for script dependencies
|
||||||
check_dependencies() {
|
check_dependencies() {
|
||||||
# just execute some dummy and/or version commands to see if required tools exist and are actually usable
|
# look for required binaries
|
||||||
|
for binary in grep mktemp diff sed awk curl cut; do
|
||||||
|
bin_path="$(command -v "${binary}" 2>/dev/null)" || _exiterr "This script requires ${binary}."
|
||||||
|
[[ -x "${bin_path}" ]] || _exiterr "${binary} found in PATH but it's not executable"
|
||||||
|
done
|
||||||
|
|
||||||
|
# just execute some dummy and/or version commands to see if required tools are actually usable
|
||||||
"${OPENSSL}" version > /dev/null 2>&1 || _exiterr "This script requires an openssl binary."
|
"${OPENSSL}" version > /dev/null 2>&1 || _exiterr "This script requires an openssl binary."
|
||||||
_sed "" < /dev/null > /dev/null 2>&1 || _exiterr "This script requires sed with support for extended (modern) regular expressions."
|
_sed "" < /dev/null > /dev/null 2>&1 || _exiterr "This script requires sed with support for extended (modern) regular expressions."
|
||||||
command -v grep > /dev/null 2>&1 || _exiterr "This script requires grep."
|
|
||||||
command -v mktemp > /dev/null 2>&1 || _exiterr "This script requires mktemp."
|
|
||||||
command -v diff > /dev/null 2>&1 || _exiterr "This script requires diff."
|
|
||||||
|
|
||||||
# curl returns with an error code in some ancient versions so we have to catch that
|
# curl returns with an error code in some ancient versions so we have to catch that
|
||||||
# storing raw version output temporarily to catch curl error instead of head/awk exit codes
|
|
||||||
set +e
|
set +e
|
||||||
raw_curl_version="$(curl -V 2>&1)"
|
CURL_VERSION="$(curl -V 2>&1 | head -n1 | awk '{print $2}')"
|
||||||
retcode="$?"
|
|
||||||
set -e
|
set -e
|
||||||
if [[ ! "${retcode}" = "0" ]] && [[ ! "${retcode}" = "2" ]]; then
|
|
||||||
_exiterr "This script requires curl."
|
|
||||||
fi
|
|
||||||
CURL_VERSION="$(head -n1 <<< "${raw_curl_version}" | awk '{print $2}')"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
store_configvars() {
|
store_configvars() {
|
||||||
@@ -192,6 +189,9 @@ load_config() {
|
|||||||
[[ -n "${ZSH_VERSION:-}" ]] && set -o noglob || set -f
|
[[ -n "${ZSH_VERSION:-}" ]] && set -o noglob || set -f
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Check for missing dependencies
|
||||||
|
check_dependencies
|
||||||
|
|
||||||
# Check if we are running & are allowed to run as root
|
# Check if we are running & are allowed to run as root
|
||||||
if [[ -n "$DEHYDRATED_USER" ]]; then
|
if [[ -n "$DEHYDRATED_USER" ]]; then
|
||||||
command -v sudo > /dev/null 2>&1 || _exiterr "DEHYDRATED_USER set but sudo not available. Please install sudo."
|
command -v sudo > /dev/null 2>&1 || _exiterr "DEHYDRATED_USER set but sudo not available. Please install sudo."
|
||||||
@@ -218,9 +218,6 @@ load_config() {
|
|||||||
_exiterr "DEHYDRATED_GROUP can only be used in combination with DEHYDRATED_USER."
|
_exiterr "DEHYDRATED_GROUP can only be used in combination with DEHYDRATED_USER."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for missing dependencies
|
|
||||||
check_dependencies
|
|
||||||
|
|
||||||
# Remove slash from end of BASEDIR. Mostly for cleaner outputs, doesn't change functionality.
|
# Remove slash from end of BASEDIR. Mostly for cleaner outputs, doesn't change functionality.
|
||||||
[[ "$BASEDIR" != "/" ]] && BASEDIR="${BASEDIR%%/}"
|
[[ "$BASEDIR" != "/" ]] && BASEDIR="${BASEDIR%%/}"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user