#!/usr/bin/env bash
set -e

DEV_USER="devuser"
DEV_HOME="/home/${DEV_USER}"
WORKSPACE="${DEV_HOME}/Workspace"

echo "[workspace] ensuring dev user and workspace"

# Create user if missing
if ! id "${DEV_USER}" &>/dev/null; then
  useradd -m -s /bin/bash "${DEV_USER}"
  echo "[workspace] created user ${DEV_USER}"
fi

# Ensure workspace exists
mkdir -p "${WORKSPACE}"

# Ensure ownership
chown -R "${DEV_USER}:${DEV_USER}" "${DEV_HOME}"

echo "[workspace] ready (${DEV_USER}:${WORKSPACE})"
