fix execute argument in unix_cmd
This commit is contained in:
12
utils.py
12
utils.py
@ -231,14 +231,14 @@ def check_service(service, set_on=None, execute=None):
|
||||
active = True
|
||||
if set_on:
|
||||
if not active:
|
||||
unix_cmd(f'systemctl start {service}', execute)
|
||||
unix_cmd(f'systemctl start {service}', execute=execute)
|
||||
if not enabled:
|
||||
unix_cmd(f'systemctl enable {service}', execute)
|
||||
unix_cmd(f'systemctl enable {service}', execute=execute)
|
||||
elif set_on is not None:
|
||||
if active:
|
||||
unix_cmd(f'systemctl stop {service}', execute)
|
||||
unix_cmd(f'systemctl stop {service}', execute=execute)
|
||||
if enabled:
|
||||
unix_cmd(f'systemctl disable {service}', execute)
|
||||
unix_cmd(f'systemctl disable {service}', execute=execute)
|
||||
return active, enabled
|
||||
|
||||
|
||||
@ -279,8 +279,8 @@ def change_firewall(set_on, ports, execute=None):
|
||||
with open('f{FIREWALL_CONF}.tmp', 'w') as f:
|
||||
f.write(content.replace(prevline, line))
|
||||
os.rename('f{FIREWALL_CONF}.tmp', FIREWALL_CONF)
|
||||
unix_cmd('systemctl restart nftables', execute)
|
||||
unix_cmd('systemctl enable nftables', execute)
|
||||
unix_cmd('systemctl restart nftables', execute=execute)
|
||||
unix_cmd('systemctl enable nftables', execute=execute)
|
||||
elif ports - prevportset:
|
||||
print('need sudo rights to modify firewall')
|
||||
return True
|
||||
|
Reference in New Issue
Block a user