forked from theforeman/foreman-selinux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
foreman-selinux-disable
34 lines (28 loc) · 1.04 KB
/
foreman-selinux-disable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
set +e
LIBEXEC_DIR=/usr/libexec/foreman-selinux
LOG=/var/log/foreman-selinux-install.log
# Run hooks
find ${LIBEXEC_DIR} -name \*-before-disable.sh -type f -executable -exec /usr/bin/bash '{}' \;
# Unload foreman policy and set booleans. Dependant booleans must be managed in
# a separate transaction. Do not forget to edit countepart file
# (enable/disable) when updating this script.
for selinuxvariant in targeted
do
if /usr/sbin/semodule -s $selinuxvariant -l >/dev/null; then
# Create log entry
echo "$(date) $0" >> $LOG
# Remove all user defined ports (including the default one)
# (docker and elastic can be removed in future release)
/usr/sbin/semanage port -E | \
grep -E '(elasticsearch|docker|foreman_.*)_port_t' | \
sed s/-a/-d/g | \
tee -a $LOG | \
/usr/sbin/semanage -S $selinuxvariant -i -
# Unload policy
/usr/sbin/semodule -s $selinuxvariant -r foreman
fi
done
# Run hooks
find ${LIBEXEC_DIR} -name \*-after-disable.sh -type f -executable -exec /usr/bin/bash '{}' \;
exit 0