Skip to content

Commit

Permalink
Check that chgrp ran correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidHuber-NOAA committed Oct 24, 2023
1 parent a8dfe18 commit 6b93dbc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
18 changes: 14 additions & 4 deletions scripts/exgdas_enkf_earc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ if [ "${ENSGRP}" -eq 0 ]; then
fi

set +e
${TARCMD} -P -cvf "${ATARDIR}/${PDY}${cyc}/${RUN}.tar" $(cat "${ARCH_LIST}/${RUN}.txt")
tar_fl=${ATARDIR}/${PDY}${cyc}/${RUN}.tar
${TARCMD} -P -cvf "${tar_fl}" $(cat "${ARCH_LIST}/${RUN}.txt")
status=$?

# Check if the newly created tarball has rstprod data in it
Expand All @@ -129,13 +130,22 @@ if [ "${ENSGRP}" -eq 0 ]; then

# If rstprod was found, change the group of the tarball
if [[ "${has_rstprod}" == "YES" ]]; then
${HSICMD} chgrp rstprod "${ATARDIR}/${PDY}${cyc}/${RUN}.tar"
${HSICMD} chmod 640 "${ATARDIR}/${PDY}${cyc}/${RUN}.tar"
${HSICMD} chgrp rstprod "${tar_fl}"
stat_chgrp=$?
${HSICMD} chmod 640 "${tar_fl}"
stat_chgrp=$((stat_chgrp+$?))
if [ "${stat_chgrp}" -gt 0 ]; then
echo "FATAL ERROR: Unable to properly restrict ${tar_fl}!"
echo "Attempting to delete ${tar_fl}"
${HSICMD} rm "${tar_fl}"
echo "Please verify that ${tar_fl} was deleted!"
exit ${stat_chgrp}
fi
fi

# For safety, test if the htar/tar command failed after changing groups
if (( status != 0 && ${PDY}${cyc} >= firstday )); then
echo "FATAL ERROR: ${TARCMD} ${PDY}${cyc} ${RUN}.tar failed"
echo "FATAL ERROR: ${TARCMD} ${tar_fl} failed"
exit "${status}"
fi
set_strict
Expand Down
16 changes: 13 additions & 3 deletions scripts/exglobal_archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ if [[ ${HPSSARCH} = "YES" || ${LOCALARCH} = "YES" ]]; then
shopt -s extglob
for targrp in ${targrp_list}; do
set +e
${TARCMD} -P -cvf "${ATARDIR}/${PDY}${cyc}/${targrp}.tar" $(cat "${ARCH_LIST}/${targrp}.txt")
tar_fl="${ATARDIR}/${PDY}${cyc}/${targrp}.tar"
${TARCMD} -P -cvf "${tar_fl}" $(cat "${ARCH_LIST}/${targrp}.txt")
status=$?

# Test gdas.tas and gdas_restarta.tar for rstprod and change group if so
Expand All @@ -282,8 +283,17 @@ if [[ ${HPSSARCH} = "YES" || ${LOCALARCH} = "YES" ]]; then

# Change group to rstprod if it was found
if [[ "${has_rstprod}" == "YES" ]]; then
${HSICMD} chgrp rstprod "${ATARDIR}/${CDATE}/${targrp}.tar"
${HSICMD} chmod 640 "${ATARDIR}/${CDATE}/${targrp}.tar"
${HSICMD} chgrp rstprod "${tar_fl}"
stat_chgrp=$?
${HSICMD} chmod 640 "${tar_fl}"
stat_chgrp=$((stat_chgrp+$?))
if [ "${stat_chgrp}" -gt 0 ]; then
echo "FATAL ERROR: Unable to properly restrict ${tar_fl}!"
echo "Attempting to delete ${tar_fl}"
${HSICMD} rm "${tar_fl}"
echo "Please verify that ${tar_fl} was deleted!"
exit ${stat_chgrp}
fi
fi
;;
*) ;;
Expand Down

0 comments on commit 6b93dbc

Please sign in to comment.