Add enterprise appliance experience Phase 1 foundation
This commit is contained in:
1 parent
b3eec34158
commit
ebaa2e7219
69 files changed
+6832
-18
No files matched your search
@@ -12,10 +12,50 @@ LICENSE_CHECK_SCRIPT="$AIPACKAGE_DIR/scripts/cezen-license-check.py"
|
||||
PUBLIC_KEY_PATH="${CEZEN_LICENSE_PUBLIC_KEY:-$AIPACKAGE_DIR/autoinstall/keys/cezen-license-public.pem}"
|
||||
LOG_FILE="/var/log/cezen-setup.log"
|
||||
INSTALL_LOG_FILE="/var/log/cezen-install.log"
|
||||
SETUP_OPERATION_FILE="/opt/cezen/setup-operation.json"
|
||||
export TERM="${TERM:-linux}"
|
||||
touch "$LOG_FILE" "$INSTALL_LOG_FILE"
|
||||
chmod 0644 "$LOG_FILE" "$INSTALL_LOG_FILE"
|
||||
|
||||
write_setup_operation() {
|
||||
local state="$1" progress="$2" label="$3" message="$4"
|
||||
mkdir -p /opt/cezen
|
||||
STATE="$state" PROGRESS="$progress" LABEL="$label" MESSAGE="$message" SETUP_OPERATION_FILE="$SETUP_OPERATION_FILE" python3 - <<'PY'
|
||||
import json, os, time, uuid
|
||||
path = os.environ["SETUP_OPERATION_FILE"]
|
||||
try:
|
||||
with open(path) as fh:
|
||||
payload = json.load(fh)
|
||||
except Exception:
|
||||
payload = {
|
||||
"schema": "cezen.setup_operation.v1",
|
||||
"operation_id": str(uuid.uuid4()),
|
||||
"correlation_id": str(uuid.uuid4()),
|
||||
"idempotency_key": str(uuid.uuid4()),
|
||||
"kind": "install",
|
||||
"acknowledged_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
||||
}
|
||||
payload.update({
|
||||
"state": os.environ["STATE"],
|
||||
"progress_percent": int(os.environ["PROGRESS"]),
|
||||
"progress_label": os.environ["LABEL"],
|
||||
"customer_message": os.environ["MESSAGE"],
|
||||
"updated_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
||||
"recovery_actions": ["retry", "view_log", "escalate"] if os.environ["STATE"] == "recovery_required" else [],
|
||||
})
|
||||
tmp = path + ".tmp"
|
||||
with open(tmp, "w") as fh:
|
||||
json.dump(payload, fh, indent=2)
|
||||
os.replace(tmp, path)
|
||||
os.chmod(path, 0o640)
|
||||
PY
|
||||
}
|
||||
|
||||
if [ -f "$SETUP_OPERATION_FILE" ] && grep -q '"state": "recovery_required"' "$SETUP_OPERATION_FILE"; then
|
||||
whiptail --title "Nexus One AI Setup Recovery" --yesno "A previous setup attempt needs recovery.\n\nChoose Yes to resume setup safely. Choose No to leave the existing state unchanged and inspect $INSTALL_LOG_FILE." 14 72 || exit 1
|
||||
fi
|
||||
write_setup_operation "validating" 0 "Collecting setup choices" "Setup is ready to resume safely if interrupted."
|
||||
|
||||
detect_iface() {
|
||||
ip route show default 2>/dev/null | awk '/default/ {print $5; exit}'
|
||||
}
|
||||
@@ -387,6 +427,7 @@ whiptail --title "$TITLE" \
|
||||
|
||||
clear
|
||||
echo ""
|
||||
write_setup_operation "running" 5 "Starting appliance installation" "Installation has started."
|
||||
echo "╔══════════════════════════════════════════╗"
|
||||
echo "║ Nexus One AI — Installing... ║"
|
||||
echo "║ Check progress: journalctl -f ║"
|
||||
@@ -449,10 +490,12 @@ whiptail --title "$TITLE" \
|
||||
if bash "$AIPACKAGE_DIR/install.sh" --tier="$TIER" >> "$INSTALL_LOG_FILE" 2>&1; then
|
||||
# Mark as configured only after the installer finishes successfully.
|
||||
touch /opt/cezen/.setup-done
|
||||
write_setup_operation "succeeded" 100 "Installation completed" "Installation completed successfully."
|
||||
whiptail --title "$TITLE" \
|
||||
--msgbox "\nInstaller command finished successfully.\n\nPortal -> http://localhost\nOllama API -> http://localhost:11434\nGrafana -> http://localhost:3000\n\nAdmin login -> admin / Cezen@2024!\n(you will be required to change this on first login)\n\nFor detailed logs, run:\n sudo tail -f $INSTALL_LOG_FILE" \
|
||||
$H $W
|
||||
else
|
||||
write_setup_operation "recovery_required" 0 "Installation needs attention" "Installation did not complete. Review the local log, then retry or contact support."
|
||||
whiptail --title "$TITLE" \
|
||||
--msgbox "\nInstaller command failed.\n\nThe setup wizard will run again on next boot.\n\nCheck the log with:\n sudo tail -n 120 $INSTALL_LOG_FILE" \
|
||||
$H $W
|
||||
|
||||
Reference in new issue
Block a user