add more error checking

This commit is contained in:
2026-07-24 14:50:46 -05:00
parent 303608172f
commit 2bf8241293
+22 -7
View File
@@ -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