Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
#866: Updates info/error output for consistency.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeathe committed Sep 18, 2019
1 parent f1667c1 commit ab55b2a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Summary of release changes.
- Updates `system-timezone-wrapper` to improve timer accuracy.
- Updates scripts to explicitly check for a file when handling lock/state files.
- Updates method used for returning current script.
- Updates info/error output for consistency.
- Adds improved test workflow; added `test-setup` target to Makefile.
- Adds Makefile target `logsdef` to handle deferred logs output within a target chain.
- Adds exec proxy function to `sshd-wrapper` used to pass through nice.
Expand Down
12 changes: 6 additions & 6 deletions src/usr/sbin/scmi
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function scmi ()
export SCMI_CHROOT_PATH="${SCMI_CHROOT_PATH}"
else
scmi_print_message "error" \
"Invalid chroot path."
"Invalid chroot path"
exit 1
fi

Expand Down Expand Up @@ -566,7 +566,7 @@ function scmi_docker_require_container ()
if [[ -z $(${docker} ps -aq --filter "name=${DOCKER_NAME}") ]]
then
scmi_print_message "step_error" \
"This operation requires the ${DOCKER_NAME} docker container."
"This operation requires the ${DOCKER_NAME} docker container"
exit 1
fi
}
Expand All @@ -576,7 +576,7 @@ function scmi_docker_require_container_not ()
if [[ -n $(${docker} ps -aq --filter "name=${DOCKER_NAME}") ]]
then
scmi_print_message "step_error" \
"This operation requires the ${DOCKER_NAME} docker container be removed (or renamed)."
"This operation requires the ${DOCKER_NAME} docker container be removed (or renamed)"
scmi_print_message "sub_step_info" \
"Try removing it with: docker rm -f ${DOCKER_NAME}"
exit 1
Expand All @@ -592,7 +592,7 @@ function scmi_docker_require_container_not_status_paused ()
) ]]
then
scmi_print_message "step_error" \
"This operation requires the ${DOCKER_NAME} docker container to be unpaused."
"This operation requires the ${DOCKER_NAME} docker container to be unpaused"
scmi_print_message "sub_step_info" \
"Try unpausing it with: docker ${DOCKER_NAME} unpause"
exit 1
Expand Down Expand Up @@ -1058,7 +1058,7 @@ function scmi_manager_type_command_prerequisites ()
if [[ -z $(${docker} info) ]]
then
scmi_print_message "error" \
"docker failed to connect to host."
"docker failed to connect to host"
exit 1
fi
}
Expand Down Expand Up @@ -1400,7 +1400,7 @@ function scmi_systemd_get_unit_file_path ()
if [[ -z ${UNIT_FILE} ]]
then
scmi_print_message "error" \
"Missing unit file name."
"Missing unit file name"
exit 1
fi

Expand Down
50 changes: 32 additions & 18 deletions src/usr/sbin/sshd-bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ function __generate_ssh_host_key ()

;;
*)
printf -- \
'Unknown key type %s - skipping.\n' \
>&2 printf -- \
'ERROR: %s unknown key type %s\n' \
"${0##*/}" \
"${type}"
return 1
;;
esac
}
Expand All @@ -103,7 +105,8 @@ function __generate_ssh_host_keys ()
)"
else
>&2 printf -- \
'ERROR: Unknown EL release.\n'
'ERROR: %s unknown EL release\n' \
"${0##*/}"
return 1
fi

Expand All @@ -121,9 +124,11 @@ function __generate_ssh_host_keys ()
__generate_ssh_host_key "${replace}" ed25519
;;
*)
printf -- \
'Unknown EL release %s - skipping.\n' \
>&2 printf -- \
'ERROR: %s unknown EL release %s\n' \
"${0##*/}" \
"${version}"
return 1
;;
esac
}
Expand Down Expand Up @@ -279,13 +284,15 @@ function __get_ssh_host_key_fingerprint ()
__get_ssh_key_fingerprint_hash_output "${ssh_key}"
else
>&2 printf -- \
'ERROR: invalid host key\n'
'ERROR: %s invalid host key\n' \
"${0##*/}"
return 1
fi
;;
*)
>&2 printf -- \
'ERROR: invalid key type\n'
'ERROR: %s invalid key type\n' \
"${0##*/}"
return 1
;;
esac
Expand Down Expand Up @@ -580,7 +587,8 @@ function __get_timer_total ()
|| [[ ${timer_start//.} -gt ${timer_end//.} ]]
then
>&2 printf -- \
'ERROR: invalid timer start: %s\n' \
'ERROR: %s invalid timer start: %s\n' \
"${0##*/}" \
"${timer_start}"
printf -- \
'0.000000'
Expand Down Expand Up @@ -882,15 +890,17 @@ function __set_ssh_user_password ()
if ! __is_valid_ssh_user "${user}"
then
>&2 printf -- \
'ERROR: Invalid user\n'
'ERROR: %s invalid user\n' \
"${0##*/}"
return 1
else
if [[ ${password_hashed} == true ]]
then
if ! __is_valid_ssh_user_password_hash "${password}"
then
>&2 printf -- \
'ERROR: Invalid password - requires SHA-512 hash\n'
'ERROR: %s invalid password - requires SHA-512 hash\n' \
"${0##*/}"
return 1
else
printf -- \
Expand All @@ -905,7 +915,8 @@ function __set_ssh_user_password ()
if [[ -z ${password} ]]
then
>&2 printf -- \
'ERROR: Invalid password - empty\n'
'ERROR: %s invalid password - empty\n' \
"${0##*/}"
return 1
else
printf -- \
Expand Down Expand Up @@ -983,7 +994,7 @@ function main ()
if [[ ${verbose} == true ]]
then
printf -- \
'INFO: %s finished - skipping.\n' \
'INFO: %s finished - skipping\n' \
"${0##*/}"
fi
exit 0
Expand All @@ -992,7 +1003,7 @@ function main ()
if [[ -f ${lock_file} ]]
then
>&2 printf -- \
'ERROR: %s lock detected - aborting.\n' \
'ERROR: %s lock detected - aborting\n' \
"${0##*/}"
exit 1
fi
Expand Down Expand Up @@ -1135,7 +1146,8 @@ function main ()
if ! __set_ssh_user_password "${ssh_user_password}"
then
>&2 printf -- \
'ERROR: Could not set password - aborting.\n'
'ERROR: %s could not set password - aborting\n' \
"${0##*/}"
exit 1
fi

Expand Down Expand Up @@ -1247,8 +1259,9 @@ function main ()
then
printf -v ssh_key_fingerprints \
-- \
'%s\nUnable to populate %s/.ssh/authorized_key' \
"ERROR: Public key validation failed." \
'ERROR: %s %s\nUnable to populate %s/.ssh/authorized_key' \
"${0##*/}" \
"public key validation failed" \
"${ssh_user_home}"
fi
else
Expand Down Expand Up @@ -1279,8 +1292,9 @@ function main ()
then
printf -v ssh_user_private_key_fingerprint \
-- \
'%s\nUnable to populate %s/.ssh/id_rsa' \
"ERROR: Private key validation failed." \
'ERROR: %s %s\nUnable to populate %s/.ssh/id_rsa' \
"${0##*/}" \
"private key validation failed" \
"${ssh_user_home}"
fi
else
Expand Down
4 changes: 2 additions & 2 deletions src/usr/sbin/system-timezone
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function main ()
then
__print_message \
"error" \
"${0##*/} must be run as root."
"${0##*/} must be run as root"
exit 1
fi

Expand Down Expand Up @@ -222,7 +222,7 @@ function main ()
then
__print_message \
"error" \
"${0##*/} lock detected - aborting."
"${0##*/} lock detected - aborting"
exit 1
fi

Expand Down
7 changes: 4 additions & 3 deletions src/usr/sbin/system-timezone-wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ function __get_timer_total ()
|| [[ ${timer_start//.} -gt ${timer_end//.} ]]
then
>&2 printf -- \
'ERROR: invalid timer start: %s\n' \
'ERROR: %s invalid timer start: %s\n' \
"${0##*/}" \
"${timer_start}"
printf -- \
'0.000000'
Expand Down Expand Up @@ -135,7 +136,7 @@ function main ()
if [[ ${verbose} == true ]]
then
printf -- \
'INFO: %s finished - skipping.\n' \
'INFO: %s finished - skipping\n' \
"${0##*/}"
fi
exit 0
Expand All @@ -144,7 +145,7 @@ function main ()
if [[ -f ${lock_file} ]]
then
>&2 printf -- \
'ERROR: %s lock detected - aborting.\n' \
'ERROR: %s lock detected - aborting\n' \
"${0##*/}"
exit 1
fi
Expand Down

0 comments on commit ab55b2a

Please sign in to comment.