Skip to content

Commit

Permalink
Add -r|--rpm flags to update_ood_portal (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock authored and ericfranz committed Feb 1, 2019
1 parent 76a0c38 commit 73a5579
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion ood-portal-generator/sbin/update_ood_portal
Original file line number Diff line number Diff line change
Expand Up @@ -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}")"
Expand All @@ -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!"
Expand All @@ -39,3 +67,5 @@ else
echo " sudo service httpd24-htcacheclean condrestart"
echo ""
fi

exit $ret

0 comments on commit 73a5579

Please sign in to comment.