From 73a5579bd9d389d21111d22169dcabbfd7cf50e4 Mon Sep 17 00:00:00 2001 From: treydock Date: Thu, 31 Jan 2019 21:13:36 -0500 Subject: [PATCH] Add -r|--rpm flags to update_ood_portal (#27) --- ood-portal-generator/sbin/update_ood_portal | 32 ++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/ood-portal-generator/sbin/update_ood_portal b/ood-portal-generator/sbin/update_ood_portal index 90ca2c0d26..3f08db7673 100755 --- a/ood-portal-generator/sbin/update_ood_portal +++ b/ood-portal-generator/sbin/update_ood_portal @@ -2,12 +2,35 @@ ROOT="$(dirname "$(readlink -f "${0}")")" +RPM=0 CONFIG="${CONFIG:-/etc/ood/config/ood_portal.yml}" APACHE="${APACHE:-/opt/rh/httpd24/root/etc/httpd/conf.d/ood-portal.conf}" BIN="${BIN:-${ROOT}/../bin/generate}" set -e +usage () { + echo "Usage: update_ood_portal [-r|--rpm]" + echo "-r|--rpm Execution performed during RPM install" +} + +OPTS=`getopt -o rh --long rpm,help -n 'update_ood_portal' -- "$@"` +if [[ $? -ne 0 ]]; then + echo "Failed parsing options" + usage + exit 1 +fi + +eval set -- "$OPTS" + +while true; do + case "$1" in + -h|--help) usage ; exit 0 ; shift ;; + -r|--rpm) RPM=1 ; shift ;; + *) break ;; + esac +done + echo "Generating Apache config using YAML config: '${CONFIG}'" NEW_APACHE="$("${BIN}" -c "${CONFIG}")" @@ -19,9 +42,14 @@ if ! cmp -s <(echo "${NEW_APACHE}") "${APACHE}"; then fi echo "Generating new Apache config at: '${APACHE}'" echo "${NEW_APACHE}" > "${APACHE}" + ret=0 else echo "No change in Apache config." - exit 1 + ret=1 +fi + +if [ $RPM -eq 1 ]; then + exit $ret fi echo "Completed successfully!" @@ -39,3 +67,5 @@ else echo " sudo service httpd24-htcacheclean condrestart" echo "" fi + +exit $ret