def samba_config_changed() -> bool:
"""
Checks whether a samba config file has changed or not.
:param volume_name: str.
:return: True or False
"""
volume_name = config("volume_name")
samba_path = os.path.join(os.sep, 'etc', 'samba', 'smb.conf')
if os.path.exists(samba_path):
# Lets check if the smb.conf matches what we're going to write.
# If so then it was already setup and there's nothing to do
with open(samba_path) as existing_config:
old_config = existing_config.readlines()
new_config = io.StringIO()
render_samba_configuration(new_config, volume_name)
if "".join(new_config) == "".join(old_config):
# configs are identical
return False
else:
return True
# Config doesn't exist.
return True
评论列表
文章目录