mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[mod] imports at the beginning of the file
This commit is contained in:
parent
69f2705b13
commit
fc5e37edc8
1 changed files with 5 additions and 4 deletions
|
@ -36,7 +36,9 @@ except ImportError:
|
||||||
from moulinette.core import MoulinetteError
|
from moulinette.core import MoulinetteError
|
||||||
from moulinette.utils import process
|
from moulinette.utils import process
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
from moulinette.utils.text import prependlines
|
from moulinette.utils.text import prependlines, searchf
|
||||||
|
|
||||||
|
from yunohost.hook import hook_callback
|
||||||
|
|
||||||
firewall_file = '/etc/yunohost/firewall.yml'
|
firewall_file = '/etc/yunohost/firewall.yml'
|
||||||
upnp_cron_job = '/etc/cron.d/yunohost-firewall-upnp'
|
upnp_cron_job = '/etc/cron.d/yunohost-firewall-upnp'
|
||||||
|
@ -194,8 +196,6 @@ def firewall_reload(skip_upnp=False):
|
||||||
skip_upnp -- Do not refresh port forwarding using UPnP
|
skip_upnp -- Do not refresh port forwarding using UPnP
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from yunohost.hook import hook_callback
|
|
||||||
|
|
||||||
reloaded = False
|
reloaded = False
|
||||||
errors = False
|
errors = False
|
||||||
|
|
||||||
|
@ -434,7 +434,6 @@ def _get_ssh_port(default=22):
|
||||||
Retrieve the SSH port from the sshd_config file or used the default
|
Retrieve the SSH port from the sshd_config file or used the default
|
||||||
one if it's not defined.
|
one if it's not defined.
|
||||||
"""
|
"""
|
||||||
from moulinette.utils.text import searchf
|
|
||||||
try:
|
try:
|
||||||
m = searchf(r'^Port[ \t]+([0-9]+)$',
|
m = searchf(r'^Port[ \t]+([0-9]+)$',
|
||||||
'/etc/ssh/sshd_config', count=-1)
|
'/etc/ssh/sshd_config', count=-1)
|
||||||
|
@ -444,12 +443,14 @@ def _get_ssh_port(default=22):
|
||||||
pass
|
pass
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
|
||||||
def _update_firewall_file(rules):
|
def _update_firewall_file(rules):
|
||||||
"""Make a backup and write new rules to firewall file"""
|
"""Make a backup and write new rules to firewall file"""
|
||||||
os.system("cp {0} {0}.old".format(firewall_file))
|
os.system("cp {0} {0}.old".format(firewall_file))
|
||||||
with open(firewall_file, 'w') as f:
|
with open(firewall_file, 'w') as f:
|
||||||
yaml.safe_dump(rules, f, default_flow_style=False)
|
yaml.safe_dump(rules, f, default_flow_style=False)
|
||||||
|
|
||||||
|
|
||||||
def _on_rule_command_error(returncode, cmd, output):
|
def _on_rule_command_error(returncode, cmd, output):
|
||||||
"""Callback for rules commands error"""
|
"""Callback for rules commands error"""
|
||||||
# Log error and continue commands execution
|
# Log error and continue commands execution
|
||||||
|
|
Loading…
Add table
Reference in a new issue