From 2bf8241293036e6dcae13a8dd713166597b2aa5f3d6a9240a4229948d8e83aa5 Mon Sep 17 00:00:00 2001 From: Heath Petersen Date: Fri, 24 Jul 2026 14:50:46 -0500 Subject: [PATCH] add more error checking --- bootstrap.sh | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 3948edd..6775d4b 100644 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -105,12 +105,18 @@ get_file() { if [ -e "${dest_file}" ] ; then mv "${dest_file}" "${dest_file}.${TIMESTAMP}" ; fi if ! curl -f -o "${dest_file}" "${source_file}" ; then - echo "ERROR - Unable to download \"${source_file}\"" >&2 - echo " to \"${dest_file}\"." >&2 + echo "ERROR - Unable to download \"${source_file}\"" >&2 + echo " to \"${dest_file}\"." >&2 + exit 4 + fi + if ! chown "${dest_file_ownership}" "${dest_file}" ; then + echo "ERROR - Unable to change ownership of \"${dest_file}\" to \"${dest_file_ownership}\"" >&2 + exit 4 + fi + if ! chmod "${dest_file_permissions}" "${dest_file}" ; then + echo "ERROR - Unable to change permissions of \"${dest_file}\" to \"${dest_file_permissions}\"" >&2 exit 4 fi - chown "${dest_file_ownership}" "${dest_file}" - chmod "${dest_file_permissions}" "${dest_file}" } # $directory $directory_ownership $directory_permissions @@ -121,9 +127,18 @@ create_directory() { directory_ownership ="${2}" directory_permissions="${3}" - mkdir -p "${directory}" - chown "${directory_ownership}" "${directory}" - chmod "${directory_permissions}" "${directory}" + if ! mkdir -p "${directory}" ; then + echo "ERROR - Unable to create directory \"${directory}\"" >&2 + exit 5 + fi + if ! chown "${directory_ownership}" "${directory}" ; then + echo "ERROR - Unable to change ownership of \"${directory}\" to \"${directory_ownership}\"" >&2 + exit 5 + fi + if ! chmod "${directory_permissions}" "${directory}" ; then + echo "ERROR - Unable to change permissions of \"${directory}\" to \"${directory_permissions}\"" >&2 + exit 5 + fi } # $command_line