mirror of
https://github.com/ovh/debian-cis.git
synced 2025-06-21 18:23:42 +02:00
IMP(shellcheck): quote variables
This commit is contained in:
@ -70,7 +70,7 @@ crit() {
|
||||
if [ "${BATCH_MODE:-0}" -eq 1 ]; then
|
||||
BATCH_OUTPUT="$BATCH_OUTPUT KO{$*}"
|
||||
else
|
||||
if [ $MACHINE_LOG_LEVEL -ge 1 ]; then _logger "$BRED" "[ KO ] $*"; fi
|
||||
if [ "$MACHINE_LOG_LEVEL" -ge 1 ]; then _logger "$BRED" "[ KO ] $*"; fi
|
||||
fi
|
||||
# This variable incrementation is used to measure failure or success in tests
|
||||
CRITICAL_ERRORS_NUMBER=$((CRITICAL_ERRORS_NUMBER + 1))
|
||||
@ -80,7 +80,7 @@ warn() {
|
||||
if [ "${BATCH_MODE:-0}" -eq 1 ]; then
|
||||
BATCH_OUTPUT="$BATCH_OUTPUT WARN{$*}"
|
||||
else
|
||||
if [ $MACHINE_LOG_LEVEL -ge 2 ]; then _logger "$BYELLOW" "[WARN] $*"; fi
|
||||
if [ "$MACHINE_LOG_LEVEL" -ge 2 ]; then _logger "$BYELLOW" "[WARN] $*"; fi
|
||||
fi
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ ok() {
|
||||
if [ "${BATCH_MODE:-0}" -eq 1 ]; then
|
||||
BATCH_OUTPUT="$BATCH_OUTPUT OK{$*}"
|
||||
else
|
||||
if [ $MACHINE_LOG_LEVEL -ge 3 ]; then _logger "$BGREEN" "[ OK ] $*"; fi
|
||||
if [ "$MACHINE_LOG_LEVEL" -ge 3 ]; then _logger "$BGREEN" "[ OK ] $*"; fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ disabled | false)
|
||||
esac
|
||||
|
||||
if [ "$CRITICAL_ERRORS_NUMBER" -eq 0 ]; then
|
||||
if [ $BATCH_MODE -eq 1 ]; then
|
||||
if [ "$BATCH_MODE" -eq 1 ]; then
|
||||
BATCH_OUTPUT="OK $SCRIPT_NAME $BATCH_OUTPUT"
|
||||
becho "$BATCH_OUTPUT"
|
||||
else
|
||||
|
10
lib/utils.sh
10
lib/utils.sh
@ -13,7 +13,7 @@ has_sysctl_param_expected_result() {
|
||||
|
||||
if [ "$($SUDO_CMD sysctl "$SYSCTL_PARAM" 2>/dev/null)" = "$SYSCTL_PARAM = $EXP_RESULT" ]; then
|
||||
FNRET=0
|
||||
elif [ $? = 255 ]; then
|
||||
elif [ "$?" = 255 ]; then
|
||||
debug "$SYSCTL_PARAM does not exist"
|
||||
FNRET=255
|
||||
else
|
||||
@ -147,7 +147,7 @@ does_pattern_exist_in_file_multiline() {
|
||||
|
||||
debug "Checking if multiline pattern: $PATTERN is present in $FILE"
|
||||
if $SUDO_CMD [ -r "$FILE" ]; then
|
||||
debug "$SUDO_CMD grep -v '^[[:space:]]*#' $FILE | tr '\n' ' ' | grep -Pq -- "$PATTERN""
|
||||
debug "$SUDO_CMD grep -v '^[[:space:]]*#' $FILE | tr '\n' ' ' | grep -Pq -- $PATTERN"
|
||||
if $SUDO_CMD grep -v '^[[:space:]]*#' "$FILE" | tr '\n' ' ' | grep -Pq -- "$PATTERN"; then
|
||||
debug "Pattern found in $FILE"
|
||||
FNRET=0
|
||||
@ -239,7 +239,7 @@ does_group_exist() {
|
||||
|
||||
is_service_enabled() {
|
||||
local SERVICE=$1
|
||||
if [ $($SUDO_CMD find /etc/rc?.d/ -name "S*$SERVICE" -print | wc -l) -gt 0 ]; then
|
||||
if [ "$($SUDO_CMD find /etc/rc?.d/ -name "S*$SERVICE" -print | wc -l)" -gt 0 ]; then
|
||||
debug "Service $SERVICE is enabled"
|
||||
FNRET=0
|
||||
else
|
||||
@ -385,7 +385,7 @@ apt_update_if_needed() {
|
||||
if [ -e /var/cache/apt/pkgcache.bin ]; then
|
||||
UPDATE_AGE=$(($(date +%s) - $(stat -c '%Y' /var/cache/apt/pkgcache.bin)))
|
||||
|
||||
if [ $UPDATE_AGE -gt 21600 ]; then
|
||||
if [ "$UPDATE_AGE" -gt 21600 ]; then
|
||||
# update too old, refresh database
|
||||
$SUDO_CMD apt-get update -y >/dev/null 2>/dev/null
|
||||
fi
|
||||
@ -438,7 +438,7 @@ is_pkg_installed() {
|
||||
get_debian_major_version() {
|
||||
DEB_MAJ_VER=""
|
||||
does_file_exist /etc/debian_version
|
||||
if [ $FNRET ]; then
|
||||
if [ "$FNRET" = 0 ]; then
|
||||
DEB_MAJ_VER=$(cut -d '.' -f1 /etc/debian_version)
|
||||
else
|
||||
# shellcheck disable=2034
|
||||
|
Reference in New Issue
Block a user