···77REPO_URL="https://tangled.sh/dynamicalsystem.com/tinsnip"
88BRANCH="main"
99INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/opt/dynamicalsystem.tinsnip}"
1010-INSTALLER_VERSION="abdaf40" # Updated automatically on commit
1010+INSTALLER_VERSION="7d4e872" # Updated automatically on commit
11111212# Service repository options
1313SERVICE_REPO_URL="${SERVICE_REPO_URL:-}"
+32-5
machine/scripts/lib.sh
···3939 }
4040}
41414242+# Find the next available service number from a registry file
4343+find_next_service_number() {
4444+ local registry_path="$1"
4545+4646+ if [[ ! -f "$registry_path" ]]; then
4747+ echo "1"
4848+ return
4949+ fi
5050+5151+ # Extract all service numbers from registry, find the highest
5252+ local max_num=0
5353+ while IFS='=' read -r service_name service_num; do
5454+ # Skip comments and empty lines
5555+ [[ "$service_name" =~ ^#.*$ ]] || [[ -z "$service_name" ]] && continue
5656+5757+ if [[ "$service_num" =~ ^[0-9]+$ ]] && [[ "$service_num" -gt "$max_num" ]]; then
5858+ max_num="$service_num"
5959+ fi
6060+ done < "$registry_path"
6161+6262+ # Return next available number (max + 1)
6363+ echo $((max_num + 1))
6464+}
6565+4266# Calculate service UID using TNSEP convention
4367# T=1 (Docker), N=namespace number, S=service, E=environment, P=0
4468calculate_service_uid() {
···6791 if [[ -f "$registry_path" ]]; then
6892 service_num=$(grep "^${service_name}=" "$registry_path" | cut -d= -f2)
6993 if [[ -z "$service_num" ]]; then
7070- echo "ERROR: Service '$service_name' not found in registry at $registry_path" >&2
7171- return 1
9494+ # Service not in registry - auto-assign next available number
9595+ service_num=$(find_next_service_number "$registry_path")
9696+ warn_with_prefix "UID Calculation" "Service '$service_name' not in registry, auto-assigning service number $service_num"
7297 fi
7398 else
7474- # Fallback to hardcoded values if registry doesn't exist
9999+ # Registry doesn't exist - use fallback mapping or auto-assign
75100 case "$service_name" in
76101 gazette) service_num=1 ;;
77102 lldap) service_num=2 ;;
103103+ gateway) service_num=3 ;;
78104 *)
7979- echo "ERROR: Unknown service: $service_name (no registry found at $registry_path)" >&2
8080- return 1
105105+ # Auto-assign starting from service number 4
106106+ service_num=4
107107+ warn_with_prefix "UID Calculation" "No registry found, auto-assigning service number $service_num for '$service_name'"
81108 ;;
82109 esac
83110 fi