Skip to content

Commit

Permalink
[PMM-13379]: Updates pmm-agent.yaml file after update from PMM 2 to P…
Browse files Browse the repository at this point in the history
…MM 3.
  • Loading branch information
maqeel75 committed Sep 25, 2024
1 parent bc51e0a commit dc89232
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion build/packages/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ case "$1" in
mv /usr/local/percona/pmm/config/pmm-agent.yaml /usr/local/percona/pmm/config/pmm-agent.yaml.new

echo "Restoring pmm-agent.yaml from backup..."
mv /usr/local/percona/pmm2/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml
mv /usr/local/percona/pmm2/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml.bak
cp /usr/local/percona/pmm/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml
sed '/^paths:/,/^[^[:space:]]/ {
/^paths:/d
/^[^[:space:]]/!d
}' "/usr/local/percona/pmm/config/pmm-agent.yaml" > "/usr/local/percona/pmm/config/pmm-agent.yaml.tmp" && mv "/usr/local/percona/pmm/config/pmm-agent.yaml.tmp" "/usr/local/percona/pmm/config/pmm-agent.yaml"

# Clean up old directories if empty
if [ -d /usr/local/percona/pmm2/config ] && [ -z "$(ls -A /usr/local/percona/pmm2/config)" ]; then
Expand Down
3 changes: 3 additions & 0 deletions build/packages/deb/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ if [ "$1" = "purge" ]; then
if [ -f /usr/local/percona/pmm/config/pmm-agent.yaml.new ]; then
rm -f /usr/local/percona/pmm/config/pmm-agent.yaml.new
fi
if [ -f /usr/local/percona/pmm/config/pmm-agent.yaml.bak ]; then
rm -f /usr/local/percona/pmm/config/pmm-agent.yaml.bak
fi

if [ -d /usr/local/percona/pmm/config ] && [ -z "$(ls -A /usr/local/percona/pmm/config)" ]; then
rmdir /usr/local/percona/pmm/config
Expand Down
7 changes: 6 additions & 1 deletion build/packages/rpm/client/pmm-client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ fi
%posttrans
if [ -f /usr/local/percona/pmm2/config/pmm-agent.yaml.bak ]; then
mv /usr/local/percona/pmm/config/pmm-agent.yaml /usr/local/percona/pmm/config/pmm-agent.yaml.new
mv /usr/local/percona/pmm2/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml
mv /usr/local/percona/pmm2/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml.bak
cp /usr/local/percona/pmm/config/pmm-agent.yaml.bak /usr/local/percona/pmm/config/pmm-agent.yaml
sed '/^paths:/,/^[^[:space:]]/ {
/^paths:/d
/^[^[:space:]]/!d
}' "/usr/local/percona/pmm/config/pmm-agent.yaml" > "/usr/local/percona/pmm/config/pmm-agent.yaml.tmp" && mv "/usr/local/percona/pmm/config/pmm-agent.yaml.tmp" "/usr/local/percona/pmm/config/pmm-agent.yaml"

if [ -d /usr/local/percona/pmm2/config ] && [ ! "$(ls -A /usr/local/percona/pmm2/config)" ]; then
rmdir /usr/local/percona/pmm2/config
Expand Down

0 comments on commit dc89232

Please sign in to comment.