Skip to content

Commit

Permalink
Test .tar files for rstprod before calling chgrp
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidHuber-NOAA committed Oct 24, 2023
1 parent 08ce4f8 commit c5e771b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
19 changes: 17 additions & 2 deletions scripts/exgdas_enkf_earc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,23 @@ if [ "${ENSGRP}" -eq 0 ]; then
set +e
${TARCMD} -P -cvf "${ATARDIR}/${PDY}${cyc}/${RUN}.tar" $(cat "${ARCH_LIST}/${RUN}.txt")
status=$?
${HSICMD} chgrp rstprod "${ATARDIR}/${PDY}${cyc}/${RUN}.tar"
${HSICMD} chmod 640 "${ATARDIR}/${PDY}${cyc}/${RUN}.tar"

has_rstprod="NO"
while IFS= read -r file; do
if [[ -f ${file} ]]; then
group=$( stat -c "%G" "${file}" )
if [[ "${group}" == "rstprod" ]]; then
has_rstprod="YES"
break
fi
fi
done < "${ARCH_LIST}/${RUN}.txt"

if [[ "${has_rstprod}" == "YES" ]]; then
${HSICMD} chgrp rstprod "${ATARDIR}/${PDY}${cyc}/${RUN}.tar"
${HSICMD} chmod 640 "${ATARDIR}/${PDY}${cyc}/${RUN}.tar"
fi

if (( status != 0 && ${PDY}${cyc} >= firstday )); then
echo "FATAL ERROR: ${TARCMD} ${PDY}${cyc} ${RUN}.tar failed"
exit "${status}"
Expand Down
17 changes: 15 additions & 2 deletions scripts/exglobal_archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,21 @@ if [[ ${HPSSARCH} = "YES" || ${LOCALARCH} = "YES" ]]; then
status=$?
case ${targrp} in
'gdas'|'gdas_restarta')
${HSICMD} chgrp rstprod "${ATARDIR}/${CDATE}/${targrp}.tar"
${HSICMD} chmod 640 "${ATARDIR}/${CDATE}/${targrp}.tar"
has_rstprod="NO"
while IFS= read -r file; do
if [[ -f ${file} ]]; then
group=$( stat -c "%G" "${file}" )
if [[ "${group}" == "rstprod" ]]; then
has_rstprod="YES"
break
fi
fi
done < "${ARCH_LIST}/${targrp}.txt"

if [[ "${has_rstprod}" == "YES" ]]; then
${HSICMD} chgrp rstprod "${ATARDIR}/${CDATE}/${targrp}.tar"
${HSICMD} chmod 640 "${ATARDIR}/${CDATE}/${targrp}.tar"
fi
;;
*) ;;
esac
Expand Down

0 comments on commit c5e771b

Please sign in to comment.