#!/bin/bash # # This is a delta script for DR #21031. It updates the four warngen geospatialConfig # files at the site localization level. # This delta script should be run on dx3 or dx4 (or dx5 or dx6 at National Centers) as user awips or root set -e county_text=' MarineZones MarineZones INTERSECT NAME NAME NAME ID ' zone_text=' MarineZones MarineZones INTERSECT NAME NAME NAME ID ' marine_text=' County States INTERSECT COUNTYNAME NAME STATE FIPS ' alaska_marine_text=' Zone States INTERSECT NAME NAME STATE STATE_ZONE ' echo "Delta script ${0} started" site_dir="/awips2/edex/data/utility/common_static/site" for file in "${site_dir}"/*/warngen/geospatialConfig_COUNTY.xml do backup_file="${file}.backup" tmp_file="${file}.tmp" cp -p "${file}" "${backup_file}" cp -p "${file}" "${tmp_file}" awk -v text="${county_text}" '//,/<\/geospatialConfig>/ {if ($0~//) {next}} /areaSource\s+variable\s*=\s*"areas"/ || /areaSource\s+variable\s*=\s*"affectedZones"/ {print $0; print " States"; next} {if ($0~/^\s*", "\n", i); print $0; print i; next} } {print}' "${file}" > "${tmp_file}" && mv -f "${tmp_file}" "${file}" echo "Updated ${file}, saved a backup at ${backup_file}" done for file in "${site_dir}"/*/warngen/geospatialConfig_ZONE.xml do backup_file="${file}.backup" tmp_file="${file}.tmp" cp -p "${file}" "${backup_file}" cp -p "${file}" "${tmp_file}" awk -v text="${zone_text}" '//,/<\/geospatialConfig>/ {if ($0~//) {next}} /areaSource\s+variable\s*=\s*"areas"/ || /areaSource\s+variable\s*=\s*"affectedCounties"/ {print $0; print " States"; next} {if ($0~/^\s*", "\n", i); print $0; print i; next} } {print}' "${file}" > "${tmp_file}" && mv -f "${tmp_file}" "${file}" echo "Updated ${file}, saved a backup at ${backup_file}" done for file in "${site_dir}"/*/warngen/geospatialConfig_MARINE.xml do backup_file="${file}.backup" tmp_file="${file}.tmp" cp -p "${file}" "${backup_file}" cp -p "${file}" "${tmp_file}" awk -v text="${marine_text}" '//,/<\/geospatialConfig>/ {if ($0~//) {next}} /areaSource\s+variable\s*=\s*"areas"/ {print $0; print " MarineZones"; next} {if ($0~/^\s*", "\n", i); print $0; print i; next} } {print}' "${file}" > "${tmp_file}" && mv -f "${tmp_file}" "${file}" echo "Updated ${file}, saved a backup at ${backup_file}" done for file in "${site_dir}"/*/warngen/geospatialConfig_ALASKA_MARINE.xml do backup_file="${file}.backup" tmp_file="${file}.tmp" cp -p "${file}" "${backup_file}" cp -p "${file}" "${tmp_file}" awk -v text="${alaska_marine_text}" '//,/<\/geospatialConfig>/ {if ($0~//) {next}} /areaSource\s+variable\s*=\s*"areas"/ {print $0; print " alaska_marine"; next} {if ($0~/^\s*", "\n", i); print $0; print i; next} } {print}' "${file}" > "${tmp_file}" && mv -f "${tmp_file}" "${file}" echo "Updated ${file}, saved a backup at ${backup_file}" done echo "Delta script ${0} completed"