Skip to content

Commit

Permalink
Add pre and postun to clean the cookbook
Browse files Browse the repository at this point in the history
  • Loading branch information
manegron committed Oct 10, 2024
1 parent ff70ab1 commit b20d17f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packaging/rpm/cookbook-snmp.spec
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ chmod -R 0755 %{buildroot}/var/chef/cookbooks/snmp
install -D -m 0644 README.md %{buildroot}/var/chef/cookbooks/snmp/README.md

%pre
if [ -d /var/chef/cookbooks/snmp ]; then
rm -rf /var/chef/cookbooks/snmp
fi

%post
case "$1" in
Expand All @@ -36,6 +39,12 @@ case "$1" in
;;
esac

%postun
# Deletes directory when uninstall the package
if [ "$1" = 0 ] && [ -d /var/chef/cookbooks/snmp ]; then
rm -rf /var/chef/cookbooks/snmp
fi

%files
%defattr(0755,root,root)
/var/chef/cookbooks/snmp
Expand All @@ -45,5 +54,8 @@ esac
%doc

%changelog
* Wed Dec 14 2016 Alberto Rodríguez <arodriguez@redborder.com> - 1.0.0-1
* Thu Oct 10 2024 Miguel Negrón <manegron@redborder.com>
- Add pre and postun

* Wed Dec 14 2016 Alberto Rodríguez <arodriguez@redborder.com>
- first spec version

0 comments on commit b20d17f

Please sign in to comment.