custom_php_pre_deinstall_command, how to prevent package removal?
-
I know it's possible to run an arbitrary php function via custom_php_pre_deinstall_command
Is it possible to actually prevent package removal by causing the deinstall to fail?
-
I don't think so. But why would you want to do that anyway? Are you trying to have your package behave like some kind of malware ... , and refuse to be removed even if the user wants it gone?
-
@bmeeks I need to perform checks , otherwise removing the package can break things. I need to alert the user and block the removal...only if certain checks pass can the deinstall proceed.
You'll find out soon enough the rationale behind this
-
@rcmcdonald91 said in custom_php_pre_deinstall_command, how to prevent package removal?:
@bmeeks I need to perform checks , otherwise removing the package can break things. I need to alert the user and block the removal...only if certain checks pass can the deinstall proceed.
You'll find out soon enough the rationale behind this
I don't think you can do that because the pfSense core code is going to call the
pkg
utility to remove your package when the user kicks that process off. During the removal, the core code calls the de-install hook you mentioned to give you chance to clean up temp directories and files, but I think no matter what you do at that point, thepkg
utility is going to remove all of the PHP, binary and other pieces of your package specified in the package manifest. -
@bmeeks One solution that I have is to run
pkg lock
in my resync routine that will keep the package locked until a condition to unlock is satisfied. Only issue with this is during installation, the custom_php_resync_command is actually executed in a blocking state whilepkg
is still running, so any attempt at runningpkg lock
during install is messy.Is there any internal plumbing available in pfSense that I could use to check if resync command was executed during package install and otherwise?
Because the package that I'm working on creates pseudointerfaces that could be assigned to pfSense interfaces, accidental removal of the package can put the firewall into a non-bootable state due to interface mismatch / reassignment issues.
-
You would need to follow all the logic within the pfSense PHP files to see the course of events for package install, removal and sync. You can find them in
/usr/local/www/
. There are five of them, all beginning withpkg
. They will, in turn, include a file from/etc/inc
with additional subroutines in it. -
Yea I'm not seeing any way to run code after
pkg
has released its lock on the database. Will keep thinking on it. Of course I can lock the package manually at some point later whenpkg
isn't also running an install, which might work.