#!/bin/sh # Pillar Fleet Control - Pre-flight Storage & Telemetry Validator # Safe, read-only system audit. Makes no disk, network, or filesystem changes. set -e GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' CYAN='\033[0;36m' BOLD='\033[1m' NC='\033[0m' printf "\n${BOLD}${CYAN}=== Pillar Fleet Control :: Pre-Flight Readiness Audit ===${NC}\n" printf "Running non-destructive inspection of local storage bus and runtime...\n\n" # 1. Architecture & OS ARCH=$(uname -m) OS=$(uname -s) printf " [•] Host Platform: ${BOLD}%s (%s)${NC}\n" "$OS" "$ARCH" if [ "$OS" != "Linux" ]; then printf " [!] Operating System: ${YELLOW}Non-Linux host (%s). Pillar Agent runs on Linux storage servers (Ubuntu, Debian, TrueNAS SCALE, Proxmox, Unraid).${NC}\n" "$OS" else printf " [✓] Operating System: ${GREEN}Linux kernel supported${NC}\n" fi # 2. Privileges & Container Execution Posture if [ "$(id -u)" -eq 0 ]; then printf " [✓] User Privileges: ${GREEN}Root / Host Administrator (Docker launch permitted)${NC}\n" ROOT_OK=1 else printf " [•] User Privileges: ${YELLOW}Non-root user (Pillar Agent uses unprivileged Docker with --cap-add=SYS_RAWIO)${NC}\n" ROOT_OK=0 fi # 3. Container Engine (Zero docker.sock mount requirement) if command -v docker >/dev/null 2>&1; then if docker info >/dev/null 2>&1; then DOCKER_STATUS="${GREEN}Active (Docker daemon ready)${NC}" DOCKER_OK=1 elif [ "$ROOT_OK" -eq 1 ]; then DOCKER_STATUS="${GREEN}Active (Docker installed; running as root)${NC}" DOCKER_OK=1 else DOCKER_STATUS="${YELLOW}Docker installed, but socket requires sudo or docker group access${NC}" DOCKER_OK=1 fi elif command -v podman >/dev/null 2>&1; then DOCKER_STATUS="${GREEN}Active (Podman engine detected)${NC}" DOCKER_OK=1 else DOCKER_STATUS="${RED}Not detected (Install Docker engine to deploy Pillar Agent)${NC}" DOCKER_OK=0 fi printf " [•] Workload Engine: %b\n" "$DOCKER_STATUS" printf " [✓] Security Posture: ${GREEN}No docker.sock mount required (--cap-drop=ALL --cap-add=SYS_RAWIO)${NC}\n" # 4. Host Kernel Virtual Filesystems if [ -r /proc/diskstats ]; then printf " [✓] Kernel VFS Diskstats: ${GREEN}Available (/proc/diskstats)${NC}\n" else printf " [!] Kernel VFS Diskstats: ${YELLOW}Unreadable or masked (/proc/diskstats)${NC}\n" fi if [ -d /sys/block ]; then printf " [✓] Sysfs Block Tree: ${GREEN}Available (/sys/block)${NC}\n" else printf " [!] Sysfs Block Tree: ${YELLOW}Missing (/sys/block)${NC}\n" fi # 5. Storage Subsystem & Bus Discovery printf "\n${BOLD}Storage Bus Topology & Physical Media:${NC}\n" DRIVE_COUNT=0 VIRTUAL_COUNT=0 if [ "$OS" = "Linux" ]; then if [ -d /sys/class/enclosure ] && [ "$(ls -A /sys/class/enclosure 2>/dev/null)" ]; then printf " [✓] Enclosure Services: ${GREEN}SES Active (/sys/class/enclosure detected for bay mapping)${NC}\n" fi if [ -d /dev/disk/by-path ]; then printf " [✓] Topology Symlinks: ${GREEN}Found (/dev/disk/by-path)${NC}\n" fi # Count and inspect non-virtual block devices for disk in /sys/block/sd* /sys/block/nvme*n1; do [ -e "$disk" ] || continue DEVNAME=$(basename "$disk") # Disambiguate and exclude virtual devices: zd (ZVOLs), dm- (DeviceMapper), md (MDRAID), loop, ram case "$DEVNAME" in zd*|dm-*|md*|loop*|ram*) VIRTUAL_COUNT=$((VIRTUAL_COUNT + 1)) continue ;; esac # Exclude devices under /sys/devices/virtual/ DEVPATH=$(readlink -f "$disk" 2>/dev/null || true) if echo "$DEVPATH" | grep -q "/devices/virtual/"; then VIRTUAL_COUNT=$((VIRTUAL_COUNT + 1)) continue fi if [ -f "$disk/device/model" ]; then MODEL=$(cat "$disk/device/model" 2>/dev/null | tr -s ' ' | sed 's/^[ \t]*//;s/[ \t]*$//') elif [ -f "$disk/device/name" ]; then MODEL=$(cat "$disk/device/name" 2>/dev/null | tr -s ' ' | sed 's/^[ \t]*//;s/[ \t]*$//') else MODEL="NVMe / SAS Physical Drive" fi SIZE_SECTORS=$(cat "$disk/size" 2>/dev/null || echo 0) SIZE_GB=$(( ${SIZE_SECTORS:-0} * 512 / 1024 / 1024 / 1024 )) printf " • /dev/%-8s -> %-32s (~%d GB)\n" "$DEVNAME" "$MODEL" "$SIZE_GB" DRIVE_COUNT=$((DRIVE_COUNT + 1)) done if [ "$DRIVE_COUNT" -eq 0 ]; then printf " ${YELLOW}No physical block devices directly visible in user space.${NC}\n" fi if [ "$VIRTUAL_COUNT" -gt 0 ]; then printf " ${CYAN}Excluded %d virtual device(s) (ZVOLs / DeviceMapper / MDRAID)${NC}\n" "$VIRTUAL_COUNT" fi else printf " ${YELLOW}Non-Linux host detected. Block topology inspection runs on Linux storage servers.${NC}\n" fi # 6. Spindown Safety & Storage Invariant printf "\n${BOLD}Hardware Safety & Spindown Preservation:${NC}\n" printf " [✓] Spindown Policy: ${GREEN}Active (--nocheck=standby prevents waking sleeping platters)${NC}\n" printf " [✓] Storage Invariant: ${GREEN}Strictly read-only (zero writes to media pools or footage datasets)${NC}\n" # 7. Outbound Telemetry Check (Zero Inbound Ports) printf "\n${BOLD}Outbound Network Connectivity:${NC}\n" TARGET_URL="https://www.pillarinteractive.com/api/v1/nodes/health-check" if command -v curl >/dev/null 2>&1; then HTTP_CODE=$(curl -sL -o /dev/null -w "%{http_code}" --connect-timeout 4 "$TARGET_URL" || echo "000") elif command -v wget >/dev/null 2>&1; then HTTP_CODE=$(wget --spider -S --timeout=4 "$TARGET_URL" 2>&1 | awk '/HTTP\// {print $2}' | tail -1 || echo "000") else HTTP_CODE="no_tool" fi if [ "$HTTP_CODE" = "200" ]; then printf " [✓] Outbound Fleet API: ${GREEN}Connected (HTTPS :443 Handshake verified)${NC}\n" printf " [✓] Firewall Policy: ${GREEN}Zero inbound ports or port forwarding required${NC}\n" NET_OK=1 else printf " [✗] Outbound Fleet API: ${RED}Blocked / Unreachable (HTTP status: %s)${NC}\n" "$HTTP_CODE" NET_OK=0 fi # Summary Evaluation if [ "$OS" != "Linux" ]; then STATUS_MSG="${YELLOW}REVIEW (Run on Linux Storage Server)${NC}" elif [ "$DOCKER_OK" -ne 1 ]; then STATUS_MSG="${RED}NOT READY (Docker missing)${NC}" elif [ "$NET_OK" -ne 1 ]; then STATUS_MSG="${RED}NOT READY (Fleet API unreachable)${NC}" elif [ "$DRIVE_COUNT" -eq 0 ]; then STATUS_MSG="${YELLOW}READY (Warning: 0 physical media drives detected)${NC}" else STATUS_MSG="${GREEN}READY${NC}" fi printf "\n${BOLD}${CYAN}Audit Complete:${NC} %d physical drives detected. System is %b to run Pillar Agent.\n\n" \ "$DRIVE_COUNT" \ "$STATUS_MSG"