dont-run-rpm
authorDebian FreeIPA Team <pkg-freeipa-devel@alioth-lists.debian.net>
Tue, 24 Jan 2023 11:21:19 +0000 (11:21 +0000)
committerTimo Aaltonen <tjaalton@debian.org>
Tue, 24 Jan 2023 11:21:19 +0000 (11:21 +0000)
Gbp-Pq: Name dont-run-rpm.diff

src/lib389/lib389/cli_ctl/cockpit.py

index 3e4ac545436bad39f0b4effa53c06a30fddc6747..ab96cc794f9866fc22308b6e95c3c0814a85272a 100644 (file)
@@ -10,9 +10,13 @@ import os
 import subprocess
 
 def cockpit_present():
-    rpm_handle = os.popen('rpm -qa --qf "%{NAME}\n"')
-    rpm_list = rpm_handle.read().splitlines()
-    if 'cockpit' in rpm_list:
+    if os.popen('dpkg-query -l cockpit'):
+        return True
+    else:
+        return False
+
+def firewalld_present():
+    if os.popen('dpkg-query -l firewalld'):
         return True
     else:
         return False
@@ -36,8 +40,8 @@ def open_firewall(inst, log, args):
     """
     Open the firewall for Cockpit service
     """
-    if not cockpit_present():
-        raise ValueError("The 'cockpit' package is not installed on this system")
+    if not firewalld_present():
+        raise ValueError("The 'firewalld' package is not installed on this system")
 
     OPEN_CMD = ['sudo', 'firewall-cmd', '--add-service=cockpit', '--permanent']
     if args.zone is not None:
@@ -66,8 +70,8 @@ def close_firewall(inst, log, args):
     """
     Close firewall for Cockpit service
     """
-    if not cockpit_present():
-        raise ValueError("The 'cockpit' package is not installed on this system")
+    if not firewalld_present():
+        raise ValueError("The 'firewalld' package is not installed on this system")
 
     CLOSE_CMD = ['sudo', 'firewall-cmd', '--remove-service=cockpit', '--permanent']
     try: