From 0badd9e5b40f53c6cad1694d06e36d9c571b62d0 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 31 Jan 2020 10:16:33 -0500 Subject: [PATCH] Migrate confluent installs to non-root This will check for and repair uid 0 owned confluent directories. --- confluent_server/confluent_server.spec.tmpl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent_server.spec.tmpl b/confluent_server/confluent_server.spec.tmpl index 9a631b96..a8fb01b4 100644 --- a/confluent_server/confluent_server.spec.tmpl +++ b/confluent_server/confluent_server.spec.tmpl @@ -48,7 +48,7 @@ rmdir $RPM_BUILD_ROOT/etc/init.d rmdir $RPM_BUILD_ROOT/etc cat INSTALLED_FILES -%triggerin -- python-pyghmi +%triggerin -- python-pyghmi, python3-pyghmi, python2-pyghmi if [ -x /usr/bin/systemctl ]; then /usr/bin/systemctl try-restart confluent >& /dev/null; fi true @@ -63,7 +63,19 @@ chown -R confluent:confluent /etc/confluent /var/lib/confluent /var/run/confluen %post sysctl -p /usr/lib/sysctl.d/confluent.conf >& /dev/null -if [ -x /usr/bin/systemctl ]; then /usr/bin/systemctl try-restart confluent >& /dev/null; fi +NEEDCHOWN=0 +NEEDSTART=0 +find /etc/confluent -uid 0 | egrep '.*' && NEEDCHOWN=1 +find /var/log/confluent -uid 0 | egrep '.*' && NEEDCHOWN=1 +find /var/run/confluent -uid 0 | egrep '.*' && NEEDCHOWN=1 +if [ $NEEDCHOWN = 1 ]; then + if systemctl is-active confluent > /dev/null; + NEEDSTART=1 + systemctl stop confluent + fi + chown -R confluent:confluent /etc/confluent /var/lib/confluent /var/run/confluent /var/log/confluent +fi +if systemctl is-active confluent > /dev/null || [ $NEEDSTART = 1 ]; then /usr/bin/systemctl restart confluent >& /dev/null; fi if [ ! -e /etc/pam.d/confluent ]; then ln -s /etc/pam.d/sshd /etc/pam.d/confluent fi