Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test tarballs for rstprod before calling chgrp #1967

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions scripts/exgdas_enkf_earc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,26 @@ 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"

# Check if the newly created tarball has rstprod data in it
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"
DavidHuber-NOAA marked this conversation as resolved.
Show resolved Hide resolved

# 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"
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"
exit "${status}"
Expand Down
23 changes: 21 additions & 2 deletions scripts/exglobal_archive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,32 @@ if [[ ${HPSSARCH} = "YES" || ${LOCALARCH} = "YES" ]]; then
set +e
${TARCMD} -P -cvf "${ATARDIR}/${PDY}${cyc}/${targrp}.tar" $(cat "${ARCH_LIST}/${targrp}.txt")
status=$?

# Test gdas.tas and gdas_restarta.tar for rstprod and change group if so
case ${targrp} in
'gdas'|'gdas_restarta')
${HSICMD} chgrp rstprod "${ATARDIR}/${CDATE}/${targrp}.tar"
${HSICMD} chmod 640 "${ATARDIR}/${CDATE}/${targrp}.tar"
has_rstprod="NO"
# Test for rstprod in each archived file
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"

# 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"
fi
;;
*) ;;
esac

# For safety, test if the htar/tar command failed after changing groups
DavidHuber-NOAA marked this conversation as resolved.
Show resolved Hide resolved
if [ "${status}" -ne 0 ] && [ "${PDY}${cyc}" -ge "${firstday}" ]; then
echo "FATAL ERROR: ${TARCMD} ${PDY}${cyc} ${targrp}.tar failed"
exit "${status}"
Expand Down