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
"""
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:
"""
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: