refs #1463 changes home of the opengnsys user

engine-branch 0.5.10
Luis Gerardo Romero Garcia 2025-02-06 12:11:06 +01:00
parent c1b1b75295
commit f181aff783
2 changed files with 24 additions and 4 deletions

View File

@ -1,5 +1,10 @@
# CHANGELOG # CHANGELOG
## [0.5.10] - 06/02/2025
### **Cambios principales**
1. Cambia el home del usuario opengnsys como `/opt/opengnsys`
## [0.5.9] - 03/02/2025 ## [0.5.9] - 03/02/2025
### **Cambios principales** ### **Cambios principales**

View File

@ -207,13 +207,28 @@ opengnsys ALL=(root) NOPASSWD: __OGBOOT_TARGET__/lib/*.iso /mnt
except IOError as e: except IOError as e:
print(f"Failed to write to {sudoers_file}: {e}") print(f"Failed to write to {sudoers_file}: {e}")
def og_core_create_user(u): def og_core_create_user(u):
try: try:
pwd.getpwnam(u) user_info = pwd.getpwnam(u)
logger.warning(f"User {u} already exists") current_home = user_info.pw_dir
logger.info(f"User {u} already exists with home {current_home}")
if u == "opengnsys" and current_home != "/opt/opengnsys":
logger.info(f"Updating home directory for user {u} to /opt/opengnsys")
subprocess.run(["usermod", "-d", "/opt/opengnsys", "-m", u], check=True)
logger.info(f"User {u} home changed successfully to /opt/opengnsys")
else:
logger.info(f"User {u} already has the correct home directory.")
except KeyError: except KeyError:
subprocess.run(["useradd", "--create-home", u, "--shell", "/bin/bash"]) # El usuario no existe, crearlo con el home correcto, si es opengnsys le ponemos su home_dir como opt/opengnsys
logger.info(f"User {u} created successfully.") # Si no es opengnsys le creamos el home en /home/<usuario>
home_dir = "/opt/opengnsys" if u == "opengnsys" else f"/home/{u}"
logger.info(f"Creating user {u} with home {home_dir}")
subprocess.run(["useradd", "--create-home", "-d", home_dir, "--shell", "/bin/bash", u], check=True)
logger.info(f"User {u} created successfully with home {home_dir}")
def og_boot_create_dirs(): def og_boot_create_dirs():
if os.path.exists(INSTALL_OGBOOT_TARGET): if os.path.exists(INSTALL_OGBOOT_TARGET):