mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-06-03 10:50:20 +00:00
samba: Improve actions script startup time
Speedup actions script startup time from 3.6s to 0.45s on A20-OLinuXino-LIME2 hardware, improve top three slowest imports: - don't import constant from manifest (saves 2.7s) - defer importing actions_utils and augeas (saves 0.3s + 0.15s) Signed-off-by: Veiko Aasa <veiko17@disroot.org> Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
parent
92d8d4fb3a
commit
66b57d48cf
@ -27,10 +27,7 @@ import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
|
||||
import augeas
|
||||
from plinth import action_utils
|
||||
from plinth.modules.samba.manifest import SHARES_CONF_BACKUP_FILE
|
||||
|
||||
SHARES_CONF_BACKUP_FILE = '/var/lib/plinth/backups-data/samba-shares-dump.conf'
|
||||
DEFAULT_FILE = '/etc/default/samba'
|
||||
|
||||
CONF_PATH = '/etc/samba/smb-freedombox.conf'
|
||||
@ -264,6 +261,7 @@ def _set_open_share_permissions(directory):
|
||||
|
||||
def _use_config_file(conf_file):
|
||||
"""Set samba configuration file location."""
|
||||
import augeas
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
@ -327,6 +325,7 @@ def subcommand_get_users(_):
|
||||
|
||||
def subcommand_setup(_):
|
||||
"""Configure samba, use custom samba config file."""
|
||||
from plinth import action_utils
|
||||
with open(CONF_PATH, 'w') as file_handle:
|
||||
file_handle.write(CONF)
|
||||
_use_config_file(CONF_PATH)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user