#!/bin/bash

LIBEXEC_DIR=/usr/libexec/foreman-selinux

# Run hooks
if [[ -d $LIBEXEC_DIR ]] ; then
	find ${LIBEXEC_DIR} -name \*-before-relabel.sh -type f -executable -exec /usr/bin/bash '{}' \;
fi

/sbin/restorecon -ri $* \
  /usr/share/foreman-proxy/bin/smart-proxy \
  /etc/foreman-proxy \
  /usr/share/foreman-proxy \
  /var/lib/foreman-proxy \
  /var/log/foreman-proxy \
  /var/run/foreman-proxy

# Run hooks
if [[ -d $LIBEXEC_DIR ]] ; then
	find ${LIBEXEC_DIR} -name \*-after-relabel.sh -type f -executable -exec /usr/bin/bash '{}' \;
fi

exit 0
