#!/bin/sh # Core Developer - Entrypoint Script set -e sync_dir() { src="$1" dst="$2" if [ ! -d "$src" ]; then return 0 fi mkdir -p "$dst" # Copy host state into container state each boot so auth/extensions are portable. cp -a "$src"/. "$dst"/ } # Sync Codex auth/state from host profile if mounted. # Example: -v "$HOME:/host-home:ro" if [ "${CODEX_AUTH_SYNC:-1}" = "1" ]; then HOST_HOME="${CORE_DEV_HOST_HOME:-/host-home}" HOST_CODEX_HOME="${HOST_HOME}/.codex" CONTAINER_CODEX_HOME="${CODEX_HOME:-${HOME}/.codex}" sync_dir "$HOST_CODEX_HOME" "$CONTAINER_CODEX_HOME" fi # Run pre-start hooks if they exist if [ -d "/root/.config/core-dev/hooks/pre-start" ]; then for hook in /root/.config/core-dev/hooks/pre-start/*; do [ -x "$hook" ] && "$hook" done fi # Setup git config if not already set if [ -z "$(git config --global user.name 2>/dev/null)" ]; then if [ -n "$GIT_USER_NAME" ]; then git config --global user.name "$GIT_USER_NAME" fi fi if [ -z "$(git config --global user.email 2>/dev/null)" ]; then if [ -n "$GIT_USER_EMAIL" ]; then git config --global user.email "$GIT_USER_EMAIL" fi fi # Setup SSH agent if keys exist if [ -d "$HOME/.ssh" ] && [ -z "$SSH_AUTH_SOCK" ]; then eval "$(ssh-agent -s)" > /dev/null 2>&1 for key in "$HOME"/.ssh/id_*; do [ -f "$key" ] && [ ! -f "$key.pub" ] && ssh-add "$key" 2>/dev/null || true done fi # Initialize mkcert CA if not already done if [ ! -f "$HOME/.local/share/mkcert/rootCA.pem" ]; then mkcert -install 2>/dev/null || true fi # Run post-start hooks if they exist if [ -d "/root/.config/core-dev/hooks/post-start" ]; then for hook in /root/.config/core-dev/hooks/post-start/*; do [ -x "$hook" ] && "$hook" done fi # Execute command exec "$@"