#!/opt/imunify360/venv/bin/python3
# Run by the imunify360-firewall removal scriptlets: drops the TuxCare
# php-els repo the agent set up with the Imunify360 license id, which stops
# working once the license is released.

import sys


def main():
    try:
        from im360.subsys.features import hardened_php

        left = hardened_php.remove_els_repo_on_package_removal()
    except Exception as e:
        print("Can't drop the php-els repo: {}".format(e), file=sys.stderr)
        return 1
    for path in left:
        print(
            "Delete {} by hand: it logs in with the Imunify360 license,"
            " so apt/yum fail on it once the license is released".format(path),
            file=sys.stderr,
        )
    return 1 if left else 0


if __name__ == "__main__":
    sys.exit(main())
