Mini Shell
#!/usr/bin/bash
# RPM preun script
# Note: Also called from Debian alt-python27-cllib.prerm scriptlet
# Arguments:
# RPM
# "$1" == 0 -- RPM will uninstall package
# "$1" == 1 -- RPM upgrade/downgrade package
# DEB
# "$1" == "remove" - DEB will uninstall package
# "$1" == "upgrade" -- DEB
# Common
# $2 - python python_sitelib path - /opt/cloudlinux/venv/lib/python3.11/site-packages
# $3 - hook marker file - /usr/share/cloudlinux/hooks/.inuse.tmp
# "python-cllib PRE UNINSTALL STARTED"
# RPM/DEB argument unified interpreter
argument=''
if [[ "$1" == 0 || "$1" == "remove" ]]; then
# "$1" == 0 -- RPM will uninstall package
# "$1" == "remove" - DEB will uninstall package
argument='uninstall'
elif [[ "$1" == 1 || "$1" == "upgrade" ]]; then
# "$1" == 1 -- RPM upgrade/downgrade package
# "$1" == "upgrade" -- DEB
argument='upgrade'
else
# Unknown argument (some special cases only for DEB. See alt-python27-cllib.prerm scriptlet for details),
# skip all actions
exit 0
fi;
# remove hooks in two cases:
# - when we uninstall package
# - when new package does not set marker
# of universal hooks usage (may be too old)
# $1 == 0 means uninstall
if [[ "$argument" == 'uninstall' || ! -f "$3" ]]; then
# during uninstall of package on this step system
# contains uninstalling package files
# during downgrade to old package which does not contain
# hooks this code is running on system with both packages code
# $1 == 1 means downgrade/upgrade
if [[ "$argument" == 'upgrade' ]]; then
# the root reason why we disable sentry here is yum,
# which does not provide ability to call some code
# from spec file of already installed package
# before downgrade and we actually run 'hooks remove'
# on 'dirty' system in the middle of package install transaction
# and we got import errors when downgrading package
# (see PTCLLIB-154 comments for some details)
# as a complete solution we may move hooks to different package
# but it seems that this case is very rare
# and we can ignore possible problems
# (who will downgrage cllib in the future?)
export DISABLE_SENTRY=1
fi;
# /opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/public_hooks/bundle/hooks.py remove
# remove hooks for supported control panels
"$2"/clcommon/public_hooks/bundle/hooks.py remove
rm -f "$3"
fi;
# "python-cllib PRE UNINSTALL FINISHED"
exit 0
Zerion Mini Shell 1.0