refs #503 adds function to add commands to sudoers

ogboot_debian_installer
Luis Gerardo Romero Garcia 2024-08-20 13:46:06 +00:00
parent fcbc625545
commit 7148199f68
1 changed files with 17 additions and 0 deletions

View File

@ -214,6 +214,22 @@ def autoConfigure():
logger.info(f"OSVERSION: {OSVERSION}")
# Configuración según la distribución OSDISTRIB
def add_sudoers_permissions():
sudoers_entry = """
ogboot ALL=(ALL) NOPASSWD: /opt/bin/oglivecli
ogboot ALL=(root) NOPASSWD: /usr/bin/mount, /usr/bin/umount, /usr/bin/cp, /usr/bin/chmod, /usr/bin/chown, /usr/bin/md5sum, /usr/bin/smbpasswd, /usr/bin/cat, /usr/bin/tee, /usr/bin/sed, /usr/bin/gzip, /usr/bin/lz4, /usr/bin/cpio, /usr/bin/find, /bin/tee, /usr/bin/dd, /usr/bin/mkfs.ext4, /usr/bin/rsync
ogboot ALL=(root) NOPASSWD: /opt/ogboot/lib/*.iso /mnt
"""
sudoers_file = '/etc/sudoers.d/ogboot'
try:
with open(sudoers_file, 'w') as file:
file.write(sudoers_entry)
print("Sudoers permissions for 'ogboot' added successfully.")
except IOError as e:
print(f"Failed to write to {sudoers_file}: {e}")
def downloadComposer():
global WORKDIR, INSTALL_OGBOOT_TARGET
logger.info("Downloading composer.phar...")
@ -981,6 +997,7 @@ else:
logger.info(f"ogBoot directory not found, create a symbolic link to the directory where the code is located {WORKDIR} To {os.path.dirname(PROGRAM_DIR)}")
os.symlink(os.path.dirname(PROGRAM_DIR), f"{WORKDIR}/ogboot")
add_sudoers_permissions()
logger.info("Creating ogBoot project.")
og_core_create_user("ogboot")