-
Notifications
You must be signed in to change notification settings - Fork 1.8k
cpack: add apt package manager prerm script #8330
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
cpack: add apt package manager prerm script #8330
Conversation
Signed-off-by: ahspw <ahspvirtuallife@gmail.com>
Signed-off-by: ahspw <ahspvirtuallife@gmail.com>
61ef21c
to
6e31d48
Compare
systemctl stop fluent-bit.service || true | ||
systemctl disable fluent-bit.service || true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we check whether service or systemctl command is effective on the Debian box?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I will test it on Debian 11 and 12 and reply back with results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests have been successfully done on debian bullseye and bookworm versions.
After Debian 8 systemd is the default init system for debian (Debian Reference) so systemctl would not make any issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds great. So, we shouldn't consider the outdated Debian system. Let's leave as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be investigated more whether this is the right choice to do or not, take fail2ban.prerm
package which has been downloaded and installed from https://github.com/fail2ban/fail2ban/releases/download/1.0.2/fail2ban_1.0.2-1.upstream1_all.deb on Debian 10 Buster for example:
#!/bin/sh
set -e
# Automatically added by dh_installinit/13.3.4
if [ -x "/etc/init.d/fail2ban" ] && [ "$1" = remove ]; then
invoke-rc.d fail2ban stop || exit 1
fi
# End automatically added section
# Automatically added by dh_python3
if which py3clean >/dev/null 2>&1; then
py3clean -p fail2ban
else
dpkg -L fail2ban | perl -ne 's,/([^/]*)\.py$,/__pycache__/\1.*, or next; unlink $_ or die $! foreach glob($_)'
find /usr/lib/python3/dist-packages/ -type d -name __pycache__ -empty -print0 | xargs --null --no-run-if-empty rmdir
fi
# End automatically added section
First it uses /bin/sh
instead of /bin/bash
and it seems some stuff would be handled by dh_installinit
which will be automatically added to prerm
files of package.
So maybe it's better to rely on debscripts scripts to run these stuff instead of executing systemctl disable
and systemctl stop
manually.
@@ -0,0 +1,12 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#!/bin/bash | |
#!/bin/sh |
Also Debian 10 Buster:
Debian 11 Bullseye:
This is more suggesting that these stuff should be handled using debhelper itself. |
Description
When we install packages with apt, rpm or other package managers, some bash scripts with (prerm, preinst, postrm and postinst) extensions would be execute (if exists) that do some tasks like copy config files, create directories etc before or after unpacking package so the main program can run in the better environment.
Issue
If remove and purge package without stop (and | or) disable it, OS still shows the service is running and can cause issues after rebooting.
Added feature
In this branch, the prerm script is added to prevent those issues. (Built and tested on ubuntu:20.04)