prole/prole-app/Sources/ProleEnv.swift
chrisfu 6e2d3e9011 refactor: modernize installer and monitoring setup
- Monitoring: Migrated from manual Grafana/Prometheus manifests to kube-prometheus-stack based setup in etc/init_monitoring.sh. Removed old manifest files from deploy/ and k8s/.
- Installer Core: Refactored installer with new modules for actions, environment handling, and UI screens. Enhanced Milestone logic to support advanced configuration (ArgoCD, Registry namespaces, Kerberos flags, etc.).
- Service & Init Scripts: Updated multiple initialization scripts (init_*.sh) for better integration with OpenBao, Kerberos, and the new monitoring stack. Added new scripts for Nginx Ingress, Ollama parsing, and K3D route fixes.
- Infrastructure: Enhanced Samba AD DC Ansible role with realm derivation, provisioning guidance, and group management. Updated K3s role tasks.
- Configuration: Refined default settings in conf/ to align with the new deployment architecture.
- App & Tools: Updated prole-app Swift code and prole.sh for improved environment variable handling and installation flow.
2026-02-19 21:07:39 -08:00

40 lines
1.5 KiB
Swift

import Foundation
enum ProleEnv {
static func proleHome() -> URL {
let env = ProcessInfo.processInfo.environment
let home = env["HOME"] ?? NSHomeDirectory()
let proleHome = env["PROLE_HOME"] ?? home
return URL(fileURLWithPath: proleHome, isDirectory: true)
}
static func logsDir() -> URL {
return proleHome().appendingPathComponent("logs", isDirectory: true)
}
static func confDir() -> URL {
return proleHome().appendingPathComponent("conf", isDirectory: true)
}
static func bootstrap() {
let fm = FileManager.default
// Ensure base, logs, conf
for dir in [proleHome(), logsDir(), confDir()] {
try? fm.createDirectory(at: dir, withIntermediateDirectories: true)
}
// Ensure conf/port-mapping.cfg exists
let pm = confDir().appendingPathComponent("port-mapping.cfg")
if !fm.fileExists(atPath: pm.path) {
let tpl = """
# Port mappings for Prole Tools (read by scripts).
# Format examples:
# grafana: local=3000 remote=80 ns=monitoring svc=kps-grafana address=0.0.0.0
# db: local=5432 remote=5432 ns=default svc=prole-db-rw address=0.0.0.0
# Add your mappings below. One mapping per line as key=value tokens.
"""
try? tpl.trimmingCharacters(in: .whitespacesAndNewlines).appending("\n").write(to: pm, atomically: true, encoding: .utf8)
}
}
}