diff --git a/definitions/default/check/all/core_cron_starts_setup_as_fallback.check.sh b/definitions/default/check/all/core_cron_starts_setup_as_fallback.check.sh index 32ef863..bf349ec 100755 --- a/definitions/default/check/all/core_cron_starts_setup_as_fallback.check.sh +++ b/definitions/default/check/all/core_cron_starts_setup_as_fallback.check.sh @@ -1,7 +1,7 @@ #!/bin/bash [ "$(id -u)" != "0" ] \ - && printf "(INSUFFICENT RIGHTS) " \ + && printf -- "(INSUFFICENT RIGHTS) " \ && exit 1 crontab -l | grep -E "[0-9]{1,2}[ \*]{8}[[:blank:]]*\/cis\/setupCoreOntoThisHost.sh" > /dev/null 2>&1 \ diff --git a/definitions/default/check/all/core_ssh_authorized_keys_of_jenkins_points_to_definitions.check.sh b/definitions/default/check/all/core_ssh_authorized_keys_of_jenkins_points_to_definitions.check.sh index bc6618e..f2e26a8 100755 --- a/definitions/default/check/all/core_ssh_authorized_keys_of_jenkins_points_to_definitions.check.sh +++ b/definitions/default/check/all/core_ssh_authorized_keys_of_jenkins_points_to_definitions.check.sh @@ -3,7 +3,7 @@ _CURRENT_FILE='/home/jenkins/.ssh/authorized_keys' [ "$(id -u)" != "0" ] \ - && printf "(INSUFFICENT RIGHTS) " \ + && printf -- "(INSUFFICENT RIGHTS) " \ && exit 1 #File has to be readable, then diff --git a/definitions/default/check/all/core_ssh_authorized_keys_of_root_is_empty_or_points_to_definitions.check.sh b/definitions/default/check/all/core_ssh_authorized_keys_of_root_is_empty_or_points_to_definitions.check.sh index 99dbc59..881ecc4 100755 --- a/definitions/default/check/all/core_ssh_authorized_keys_of_root_is_empty_or_points_to_definitions.check.sh +++ b/definitions/default/check/all/core_ssh_authorized_keys_of_root_is_empty_or_points_to_definitions.check.sh @@ -3,7 +3,7 @@ _CURRENT_FILE='/root/.ssh/authorized_keys' [ "$(id -u)" != "0" ] \ - && printf "(INSUFFICENT RIGHTS) " \ + && printf -- "(INSUFFICENT RIGHTS) " \ && exit 1 #No file is ok diff --git a/definitions/default/check/all/core_ssh_key_of_root_exists_as_expected.check.sh b/definitions/default/check/all/core_ssh_key_of_root_exists_as_expected.check.sh index c42dfd5..d6866b3 100755 --- a/definitions/default/check/all/core_ssh_key_of_root_exists_as_expected.check.sh +++ b/definitions/default/check/all/core_ssh_key_of_root_exists_as_expected.check.sh @@ -3,7 +3,7 @@ _CURRENT_FILE='/root/.ssh/id_ed25519' [ "$(id -u)" != "0" ] \ - && printf "(INSUFFICENT RIGHTS) " \ + && printf -- "(INSUFFICENT RIGHTS) " \ && exit 1 #File has to be readable and no passphrase should be needed. diff --git a/definitions/default/check/all/core_sudoers_file_of_jenkins_points_to_definitions.check.sh b/definitions/default/check/all/core_sudoers_file_of_jenkins_points_to_definitions.check.sh index f9b7cdd..a0b6f83 100755 --- a/definitions/default/check/all/core_sudoers_file_of_jenkins_points_to_definitions.check.sh +++ b/definitions/default/check/all/core_sudoers_file_of_jenkins_points_to_definitions.check.sh @@ -3,7 +3,7 @@ _CURRENT_FILE='/etc/sudoers.d/allow-jenkins-updateRepositories' [ "$(id -u)" != "0" ] \ - && printf "(INSUFFICENT RIGHTS) " \ + && printf -- "(INSUFFICENT RIGHTS) " \ && exit 1 #File has to be readable, then diff --git a/definitions/default/check/all/core_user_jenkins_exists.check.sh b/definitions/default/check/all/core_user_jenkins_exists.check.sh index 38a255d..95a54c1 100755 --- a/definitions/default/check/all/core_user_jenkins_exists.check.sh +++ b/definitions/default/check/all/core_user_jenkins_exists.check.sh @@ -3,7 +3,7 @@ _CURRENT_USER='jenkins' [ "$(id -u)" != "0" ] \ - && printf "(INSUFFICENT RIGHTS) " \ + && printf -- "(INSUFFICENT RIGHTS) " \ && exit 1 id -u "${_CURRENT_USER}" > /dev/null 2>&1 \ diff --git a/script/host/pam/ssh-notify-root-login.sh b/script/host/pam/ssh-notify-root-login.sh index 0cd17b9..4fe0d17 100755 --- a/script/host/pam/ssh-notify-root-login.sh +++ b/script/host/pam/ssh-notify-root-login.sh @@ -81,20 +81,21 @@ function setup() { readonly _COMMAND _PAM_FILE ! [ -f "${_PAM_FILE}" ] \ - && printf "FAILURE: Missing file: %s\n" "${_PAM_FILE:?"Missing PAM_FILE"}" >&2 \ + && printf -- "FAILURE: Missing file: %s\n" "${_PAM_FILE:?"Missing PAM_FILE"}" >&2 \ && exit 1 # Lines are already appended, so nothing is to do, therefore no setup. grep -q -F "/${CIS[SCRIPTNAME]?:"Missing SCRIPTNAME"}" "${_PAM_FILE}" \ + && printf -- "FAILURE: Command have already been appended to the file: '%s'\n" "${_PAM_FILE}" >&2 \ && return 1 # Append command to call this script, which is the setup. - printf "Appending the following command to file '%s':\n - %s\n" "${_PAM_FILE}" "${_COMMAND}" >&2 \ - && printf "\n#Call this script on each ssh-login\n%s\n" "${_COMMAND}" >> "${_PAM_FILE}" \ - && printf "SUCCESS: Setup completed.\n" >&2 \ + printf -- "Appending the following command to file '%s':\n - %s\n" "${_PAM_FILE}" "${_COMMAND}" >&2 \ + && printf -- "\n#Call this script on each ssh-login\n%s\n" "${_COMMAND}" >> "${_PAM_FILE}" \ + && printf -- "SUCCESS: Setup completed.\n" >&2 \ && return 0 - printf "FAILURE: Setup of '%s' failed.\n" "${CIS[SCRIPTNAME]}" >&2 + printf -- "FAILURE: Setup of '%s' failed.\n" "${CIS[SCRIPTNAME]}" >&2 exit 1 } diff --git a/script/host/zfs/snapshot.sh b/script/host/zfs/snapshot.sh index c806994..9c6156d 100755 --- a/script/host/zfs/snapshot.sh +++ b/script/host/zfs/snapshot.sh @@ -27,7 +27,7 @@ function cleanup() { fi [ -n "${_ZFS}" ] \ - && printf %b "Cleaning snapshots of: '${_ZFS}'\n" \ + && printf -- "Cleaning snapshots of: '%b'\n" "${_ZFS}" \ && local _LIST=( $(zfs list -t snap -H -o name -S creation "${_ZFS}" | grep -F '@SNAP' ) ) # Nothing to do @@ -40,40 +40,40 @@ function cleanup() { for _SNAPSHOT in "${_LIST[@]}"; do case "${_SNAPSHOT}" in - *"@SNAPMINUTELY_"*) + *"@SNAPMINUTELY_"*) ((_COUNT_MINUTELY++)) if [ ${_COUNT_MINUTELY} -gt ${_MINUTELY_MIN} ]; then - printf %s " - remove snapshot (${_COUNT_MINUTELY}): '@${_SNAPSHOT#*@}' ... " >&2 + printf -- " - remove snapshot (%s): '@%s' ... " "${_COUNT_MINUTELY}" "${_SNAPSHOT#*@}" >&2 zfs destroy "${_SNAPSHOT}" \ - && printf %b '(done)\n' \ - || printf %b '(FAIL)\n' + && printf -- '(done)\n' \ + || printf -- '(FAIL)\n' fi ;; - *"@SNAPHOURLY_"*) + *"@SNAPHOURLY_"*) ((_COUNT_HOURLY++)) if [ ${_COUNT_HOURLY} -gt ${_HOURLY_MIN} ]; then - printf %s " - remove snapshot (${_COUNT_HOURLY}): '@${_SNAPSHOT#*@}' ... " >&2 + printf -- " - remove snapshot (%s): '@%s' ... " "${_COUNT_HOURLY}" "${_SNAPSHOT#*@}" >&2 zfs destroy "${_SNAPSHOT}" \ - && printf %b '(done)\n' \ - || printf %b '(FAIL)\n' + && printf -- '(done)\n' \ + || printf -- '(FAIL)\n' fi ;; - *"@SNAPDAILY_"*) + *"@SNAPDAILY_"*) ((_COUNT_DAILY++)) if [ ${_COUNT_DAILY} -gt ${_DAILY_MIN} ]; then - printf %s " - remove snapshot (${_COUNT_DAILY}): '@${_SNAPSHOT#*@}' ... " >&2 + printf -- " - remove snapshot (%s): '@%s' ... " "${_COUNT_DAILY}" "${_SNAPSHOT#*@}" >&2 zfs destroy "${_SNAPSHOT}" \ - && printf %b '(done)\n' \ - || printf %b '(FAIL)\n' + && printf -- '(done)\n' \ + || printf -- '(FAIL)\n' fi ;; - *"@SNAPMONTHLY_"*) + *"@SNAPMONTHLY_"*) ((_COUNT_MONTHLY++)) if [ ${_COUNT_MONTHLY} -gt ${_MONTHLY_MIN} ]; then - printf %s " - remove snapshot (${_COUNT_MONTHLY}): '@${_SNAPSHOT#*@}' ... " >&2 + printf -- " - remove snapshot ($s): '@%s' ... " "${_COUNT_MONTHLY}" "${_SNAPSHOT#*@}" >&2 zfs destroy "${_SNAPSHOT}" \ - && printf %b '(done)\n' \ - || printf %b '(FAIL)\n' + && printf -- '(done)\n' \ + || printf -- '(FAIL)\n' fi ;; esac @@ -103,14 +103,14 @@ function snapshot() { _ZFS_BRANCH="${_ZFS_BRANCH%/}" #Remove tailing '/' if exists [ "${_CURRENT_HOST}" != "${CIS[HOST]:?"Missing CIS_HOST"}" ] \ - && printf %b "ZFS will be skipped, because this host '${CIS[HOST]}' is not running the composition:\n" >&2 \ - && printf %b " - Composition : ${_COMPOSITION}\n" >&2 \ - && printf %b " - Current host: ${_CURRENT_HOST}\n" >&2 \ + && printf -- "ZFS will be skipped, because this host '%b' is not running the composition:\n" "${CIS[HOST]}" >&2 \ + && printf -- " - Composition : %b\n" "${_COMPOSITION}" >&2 \ + && printf -- " - Current host: %b\n" "${_CURRENT_HOST}" >&2 \ && continue _ZFS="$(zfs list -H -o name "${_ZFS_BRANCH:-"zpool1/persistent"}/${_COMPOSITION}" 2> /dev/null)" [ -z "${_ZFS}" ] \ - && printf %b "FAILURE - ZFS not found: ${_ZFS_BRANCH:-"zpool1/persistent"}/${_COMPOSITION}\n" >&2 \ + && printf -- "FAILURE - ZFS not found: %b/%b\n" "${_ZFS_BRANCH:-"zpool1/persistent"}" "${_COMPOSITION}" >&2 \ && continue ( diff --git a/script/monitor/check.sh b/script/monitor/check.sh index b910cae..61a3a55 100755 --- a/script/monitor/check.sh +++ b/script/monitor/check.sh @@ -36,8 +36,8 @@ function doChecks(){ } function usage(){ - printf "\nUsage: /monitor/check.sh " echo + echo "Usage: /monitor/check.sh " echo "possible commands:" echo echo "- all" diff --git a/updateRepositories.sh b/updateRepositories.sh index 2f46ca5..d8fdd37 100755 --- a/updateRepositories.sh +++ b/updateRepositories.sh @@ -41,25 +41,25 @@ function update_repositories() { && return 0 [ "${_MODE}" == "--scripts" ] \ - && printf "Host $HOSTNAME updating scripts: ${CIS[ROOT]:?"Missing CISROOT"} ... " \ + && printf -- "Host $HOSTNAME updating scripts: ${CIS[ROOT]:?"Missing CISROOT"} ... " \ && (git -C "${CIS[ROOT]:?"Missing CISROOT"}" pull &> /dev/null) \ && echo "(done)" \ && return 0 [ "${_MODE}" == "--definitions" ] \ - && printf "Host ${HOSTNAME} updating definitions: ${CIS[DOMAINDEFINITIONS]:?"Missing DEFINITIONS"} ... " \ + && printf -- "Host ${HOSTNAME} updating definitions: ${CIS[DOMAINDEFINITIONS]:?"Missing DEFINITIONS"} ... " \ && (git -C "${CIS[DOMAINDEFINITIONS]:?"Missing DEFINITIONS"}" pull &> /dev/null) \ && echo "(done)" \ && return 0 [ "${_MODE}" == "--states" ] \ - && printf "Host ${HOSTNAME} updating states: ${CIS[DOMAINSTATES]:?"Missing STATES"} ... " \ + && printf -- "Host ${HOSTNAME} updating states: ${CIS[DOMAINSTATES]:?"Missing STATES"} ... " \ && (git -C "${CIS[DOMAINSTATES]:?"Missing STATES"}" pull &> /dev/null) \ && echo "(done)" \ && return 0 [ "${_MODE}" == "--core" ] \ - && printf "Host ${HOSTNAME} updating core including scripts, definitions and states ... " \ + && printf -- "Host ${HOSTNAME} updating core including scripts, definitions and states ... " \ && (git -C "${CIS[ROOT]:?"Missing CISROOT"}" pull &> /dev/null) \ && (git -C "${CIS[DOMAINDEFINITIONS]:?"Missing DEFINITIONS"}" pull &> /dev/null) \ && (git -C "${CIS[DOMAINSTATES]:?"Missing STATES"}" pull &> /dev/null) \