From ebd2f77ac15156904eab1da25dc1fca692feeb23 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 1 Jul 2022 09:10:05 +0200 Subject: put tr into TR, use SED, SORT, ... everywhere --- crypt-expiry-check.in | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/crypt-expiry-check.in b/crypt-expiry-check.in index 4cb78c6..2b3576e 100755 --- a/crypt-expiry-check.in +++ b/crypt-expiry-check.in @@ -80,6 +80,7 @@ OPENSSL=$(which openssl) PRINTF=$(which printf) SED=$(which sed) TEE=$(which tee) +TR=$(which tr) SORT=$(which sort) TAIL=$(which tail) MKTEMP=$(which mktemp) @@ -347,14 +348,14 @@ check_nginx_configuration() { read -r _ FILE } < <( printf '%s\n' "${line}" \ - | sed ' + | "${SED}" ' s/[;{}]/\0\n/g ' \ - | sed -n ' + | "${SED}" -n ' /^\(server_name\|ssl_certificate\)\s/p ' \ - | sort \ - | sed ' + | "${SORT}" \ + | "${SED}" ' s/;$// ' ) @@ -362,16 +363,16 @@ check_nginx_configuration() { done < <( find "${CONFIGDIR}" \ \( -type f -o -type l \) \ - -exec sed ' + -exec "${SED}" ' s/#.*$// s/^\s*// s/\s*$// ' {} \; \ - | tr -d '\n' \ - | sed ' + | "${TR}" -d '\n' \ + | "${SED}" ' s/}server\s*{/\n\0/g ' \ - | grep -wF 'ssl_certificate' + | "${GREP}" -wF 'ssl_certificate' ) } @@ -644,10 +645,10 @@ then fi ### Check to make sure the sed and awk binaries are available -if [ ! -f ${SED} ] || [ ! -f ${AWK} ] || [ ! -f ${TEE} ] || [ ! -f ${SORT} ] || [ ! -f ${TAIL} ] +if [ ! -f ${SED} ] || [ ! -f ${AWK} ] || [ ! -f ${TEE} ] || [ ! -f ${SORT} ] || [ ! -f ${TAIL} ] || [ ! -f "${TR}" ] then - >&2 echo "ERROR: Unable to locate the sed, awk, tee, sort or tail binary." - >&2 echo "FIX: Please modify the \${SED}, \${AWK}, \${TEE}, \${SORT}, \${TAIL} variables in the program header." + >&2 echo "ERROR: Unable to locate the sed, awk, tee, sort, tail or tr binary." + >&2 echo "FIX: Please modify the \${SED}, \${AWK}, \${TEE}, \${SORT}, \${TAIL}, \${TR} variables in the program header." exit 1 fi @@ -721,7 +722,7 @@ do check_server_status "${HOST}" "${PORT}" "${FWARNDAYS}" fi done < <( - sed ' + "${SED}" ' /^#\|^$/d s/^\([0-9]\+\) \+\(.*\S\) \+\(\S\+\)$/\1 \3 \2/ t -- cgit v1.2.3-54-g00ecf