parent
ab79c9f6eb
commit
9cf9742ec8
|
@ -311,18 +311,6 @@ def og_boot_composer_install():
|
|||
###:::::::::::::::::::::::::::: CONFIGURE ::::::::::::::::::::::::::::::::::###
|
||||
###############################################################################
|
||||
|
||||
def backupFile(file):
|
||||
if not os.path.isfile(file):
|
||||
logger.warning(f"File {file} doesn't exist")
|
||||
return
|
||||
logger.info(f"Making backup of {file}")
|
||||
shutil.copy2(file, f"{file}-LAST")
|
||||
dateymd = datetime.datetime.now().strftime("%Y%m%d")
|
||||
backup_file = f"{file}-{dateymd}"
|
||||
if not os.path.isfile(backup_file):
|
||||
shutil.copy2(file, backup_file)
|
||||
logger.info(f"Backup of {file} successful")
|
||||
|
||||
# Obtener la UID y GID del usuario ogboot
|
||||
def get_ogboot_uid_gid():
|
||||
try:
|
||||
|
@ -453,7 +441,7 @@ def copyClientFiles():
|
|||
logger.info(f"Client copy files success.")
|
||||
else:
|
||||
logger.error(f"Client copy files with errors")
|
||||
return errstatus
|
||||
return not errstatus
|
||||
|
||||
def get_first_network_interface_with_traffic():
|
||||
with open('/proc/net/dev') as f:
|
||||
|
@ -573,7 +561,11 @@ def user_exists(user):
|
|||
return False
|
||||
|
||||
def smbConfigure():
|
||||
backupFile(f"{SAMBACFGDIR}/smb.conf")
|
||||
smb_conf = f"{SAMBACFGDIR}/smb.conf"
|
||||
if os.path.exists (smb_conf):
|
||||
dateymd = datetime.datetime.now().strftime("%Y%m%d")
|
||||
shutil.copy2 (smb_conf, f"{smb_conf}-{dateymd}")
|
||||
|
||||
# Copiar plantilla de recursos para OpenGnsys
|
||||
with open(os.path.join(REPO_DIR, 'etc/smb-ogboot.conf.tmpl'), 'r') as tmpl_file:
|
||||
template = tmpl_file.read()
|
||||
|
@ -581,9 +573,9 @@ def smbConfigure():
|
|||
with open(os.path.join(SAMBACFGDIR, 'smb-ogboot.conf'), 'w') as conf_file:
|
||||
conf_file.write(replaced_template)
|
||||
# Configurar y recargar Samba"
|
||||
subprocess.run(["perl", "-pi", "-e", "s/WORKGROUP/OPENGNSYS/; s/server string \\=.*/server string \\= ogBoot Samba Server/", f"{SAMBACFGDIR}/smb.conf"])
|
||||
if "smb-ogboot" not in open(f"{SAMBACFGDIR}/smb.conf").read():
|
||||
with open(f"{SAMBACFGDIR}/smb.conf", "a") as file:
|
||||
subprocess.run(["perl", "-pi", "-e", "s/WORKGROUP/OPENGNSYS/; s/server string \\=.*/server string \\= ogBoot Samba Server/", smb_conf])
|
||||
if "smb-ogboot" not in open(smb_conf).read():
|
||||
with open(smb_conf, "a") as file:
|
||||
file.write(f"include = {SAMBACFGDIR}/smb-ogboot.conf\n")
|
||||
service = "smbd"
|
||||
logger.info(f"Enabling {service} service.")
|
||||
|
|
Loading…
Reference in New Issue