mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2025-04-01 23:57:05 +00:00
update ssh get config value: tabs instead of spaces, ssh port can return None
This commit is contained in:
parent
4e64518881
commit
bdda55413c
@ -180,28 +180,33 @@ def wait_for_service(port, public, env, timeout):
|
||||
time.sleep(min(timeout/4, 1))
|
||||
|
||||
def get_ssh_port():
|
||||
return int(get_ssh_config_value("port"))
|
||||
port_value = get_ssh_config_value("port")
|
||||
|
||||
if port_value:
|
||||
return int(port_value)
|
||||
|
||||
return None
|
||||
|
||||
def get_ssh_config_value(parameter_name):
|
||||
# Returns ssh port
|
||||
try:
|
||||
output = shell('check_output', ['sshd', '-T'])
|
||||
except FileNotFoundError:
|
||||
# sshd is not installed. That's ok.
|
||||
return None
|
||||
except subprocess.CalledProcessError:
|
||||
# error while calling shell command
|
||||
return None
|
||||
# Returns ssh configuration value for the provided parameter
|
||||
try:
|
||||
output = shell('check_output', ['sshd', '-T'])
|
||||
except FileNotFoundError:
|
||||
# sshd is not installed. That's ok.
|
||||
return None
|
||||
except subprocess.CalledProcessError:
|
||||
# error while calling shell command
|
||||
return None
|
||||
|
||||
returnNext = False
|
||||
for e in output.split():
|
||||
if returnNext:
|
||||
return e
|
||||
if e == parameter_name:
|
||||
returnNext = True
|
||||
returnNext = False
|
||||
for e in output.split():
|
||||
if returnNext:
|
||||
return e
|
||||
if e == parameter_name:
|
||||
returnNext = True
|
||||
|
||||
# Did not find port!
|
||||
return None
|
||||
# Did not find the parameter!
|
||||
return None
|
||||
|
||||
if __name__ == "__main__":
|
||||
from web_update import get_web_domains
|
||||
|
Loading…
Reference in New Issue
Block a user