Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PMM-13630]: Fixes service start issue + permissions issue #3415

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions build/packages/rpm/client/pmm-client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ if [ -f /usr/local/percona/pmm2/config/pmm-agent.yaml.bak ]; then
if [ -d /usr/local/percona/pmm2 ] && [ ! "$(ls -A /usr/local/percona/pmm2)" ]; then
rmdir /usr/local/percona/pmm2
fi

if ! getent passwd pmm-agent > /dev/null 2>&1; then
/usr/sbin/groupadd -r pmm-agent
/usr/sbin/useradd -M -r -g pmm-agent -d /usr/local/percona/ -s /bin/false -c "PMM Agent User" pmm-agent
chown -R pmm-agent:pmm-agent /usr/local/percona/
ademidoff marked this conversation as resolved.
Show resolved Hide resolved
fi
/usr/bin/systemctl enable pmm-agent >/dev/null 2>&1 || :
/usr/bin/systemctl daemon-reload
/usr/bin/systemctl start pmm-agent.service
fi

%build
Expand Down Expand Up @@ -122,7 +131,7 @@ install -m 0644 config/pmm-agent.service %{buildroot}/%{_unitdir}/pmm-agent.serv
rm -rf $RPM_BUILD_ROOT

%pre
if [ $1 == 1 ]; then
if [ $1 -eq 1 ]; then
if ! getent passwd pmm-agent > /dev/null 2>&1; then
/usr/sbin/groupadd -r pmm-agent
/usr/sbin/useradd -M -r -g pmm-agent -d /usr/local/percona/ -s /bin/false -c pmm-agent pmm-agent > /dev/null 2>&1
Expand All @@ -132,15 +141,14 @@ if [ $1 -eq 2 ]; then
/usr/bin/systemctl stop pmm-agent.service >/dev/null 2>&1 ||:
fi


%post
for file in pmm-admin pmm-agent
do
%{__ln_s} -f /usr/local/percona/pmm/bin/$file /usr/bin/$file
%{__ln_s} -f /usr/local/percona/pmm/bin/$file /usr/sbin/$file
done
%systemd_post pmm-agent.service
if [ $1 == 1 ]; then
if [ $1 -eq 1 ]; then
if [ ! -f /usr/local/percona/pmm/config/pmm-agent.yaml ]; then
install -d -m 0755 /usr/local/percona/pmm/config
install -m 0660 -o pmm-agent -g pmm-agent /dev/null /usr/local/percona/pmm/config/pmm-agent.yaml
Expand All @@ -164,21 +172,29 @@ fi

%postun
case "$1" in
0) # This is a yum remove.
/usr/sbin/userdel pmm-agent
%systemd_postun_with_restart pmm-agent.service
;;
1) # This is a yum upgrade.
%systemd_postun_with_restart pmm-agent.service
;;
esac
if [ $1 == 0 ]; then
if [ $1 -eq 0 ]; then
%systemd_postun_with_restart pmm-agent.service
if /usr/bin/id -g pmm-agent > /dev/null 2>&1; then
/usr/sbin/userdel pmm-agent > /dev/null 2>&1
/usr/sbin/groupdel pmm-agent > /dev/null 2>&1 || true
if [ -f /usr/local/percona/pmm/config/pmm-agent.yaml ]; then
rm -r /usr/local/percona/pmm/config/pmm-agent.yaml
fi
if [ -f /usr/local/percona/pmm/config/pmm-agent.yaml.bak ]; then
rm -r /usr/local/percona/pmm/config/pmm-agent.yaml.bak
fi
if [ -d /usr/local/percona/pmm/config ] && [ ! "$(ls -A /usr/local/percona/pmm/config)" ]; then
ademidoff marked this conversation as resolved.
Show resolved Hide resolved
rmdir /usr/local/percona/pmm/config
fi

if [ -d /usr/local/percona/pmm ] && [ ! "$(ls -A /usr/local/percona/pmm)" ]; then
rmdir /usr/local/percona/pmm
fi

for file in pmm-admin pmm-agent
do
if [ -L /usr/sbin/$file ]; then
Expand All @@ -191,7 +207,6 @@ if [ $1 == 0 ]; then
fi
fi


%files
%config %{_unitdir}/pmm-agent.service
%attr(0660,pmm-agent,pmm-agent) %ghost /usr/local/percona/pmm/config/pmm-agent.yaml
Expand Down
Loading