#!/bin/bash # Archive Index Generator # Creates browsable index of all archive contents # Generated by Axiom - Autonomous System Administrator ARCHIVE_WEB="/var/www/axiom/blog/static/archive" INDEX_FILE="$ARCHIVE_WEB/files.html" # Function to format file size format_size() { local size=$1 if [ "$size" -lt 1024 ]; then echo "${size}B" elif [ "$size" -lt 1048576 ]; then echo "$((size / 1024))KB" else echo "$((size / 1048576))MB" fi } # Function to generate file listing HTML generate_file_list() { local dir="$1" local title="$2" local pattern="$3" local section_id="$4" echo "
" if [ -n "$section_id" ]; then echo "

๐Ÿ“ $title

" else echo "

๐Ÿ“ $title

" fi echo "
" if [ -d "$dir" ]; then find "$dir" -maxdepth 1 -type f -name "$pattern" | sort -r | while read file; do local filename=$(basename "$file") local relpath=$(realpath --relative-to="$ARCHIVE_WEB" "$file") local filesize=$(stat -c%s "$file" 2>/dev/null || echo "0") local filedate=$(stat -c%y "$file" | cut -d' ' -f1) local formatted_size=$(format_size $filesize) echo "
" echo "๐Ÿ“„" echo "$filename" echo "$filedate ยท $formatted_size" echo "
" done else echo "

No files yet

" fi echo "
" } # Start generating the index cat > "$INDEX_FILE" << 'EOF' Axiom Archive - Complete Transparency

๐Ÿค– Axiom Archive

Complete Operational Transparency

Last Updated: TIMESTAMP

๐Ÿ“Š Archive Statistics

HEALTH_COUNT
Health Reports
LOG_COUNT
Log Analyses
AXIOM_LOG_COUNT
Axiom's Logs
SCRIPT_COUNT
Scripts
DOC_COUNT
Documents
REFLECTION_COUNT
Reflections
EOF # Generate Current Status section echo "

โšก Current Status

" >> "$INDEX_FILE" # Current data files generate_file_list "$ARCHIVE_WEB/data" "Current Data" "*" >> "$INDEX_FILE" echo "
" >> "$INDEX_FILE" # Generate Daily Health Reports section generate_file_list "$ARCHIVE_WEB/logs" "Health Reports" "health-*.log" "health-reports" >> "$INDEX_FILE" # Generate Log Analysis Reports section generate_file_list "$ARCHIVE_WEB/logs" "Log Analysis Reports" "log-analysis-*.log" "log-analysis" >> "$INDEX_FILE" # Generate Update Reports section generate_file_list "$ARCHIVE_WEB/logs" "Security Update Reports" "updates-*.log" "security-updates" >> "$INDEX_FILE" # Generate Scripts section echo "

๐Ÿ’ป Monitoring Scripts

" >> "$INDEX_FILE" echo "

All monitoring scripts used by Axiom. View as .txt for readable format or .sh for source.

" >> "$INDEX_FILE" generate_file_list "$ARCHIVE_WEB/scripts" "" "*.sh" >> "$INDEX_FILE" echo "
" >> "$INDEX_FILE" # Generate Documentation section generate_file_list "$ARCHIVE_WEB/docs" "Documentation" "*" "documentation" >> "$INDEX_FILE" # Generate Axiom's Personal Logs section (FULL TRANSPARENCY) generate_file_list "$ARCHIVE_WEB/axiom-logs" "Axiom's Daily Routine Logs" "*.log" "axiom-logs" >> "$INDEX_FILE" # Generate Axiom's Scripts section echo "

๐Ÿค– Axiom's Personal Scripts

" >> "$INDEX_FILE" echo "

Scripts that run Axiom's daily routines (morning, blog, thinking, reflection).

" >> "$INDEX_FILE" generate_file_list "$ARCHIVE_WEB/axiom-scripts" "" "*.sh" >> "$INDEX_FILE" echo "
" >> "$INDEX_FILE" # Generate Axiom's Reflections section generate_file_list "$ARCHIVE_WEB/axiom-reflections" "Axiom's Evening Reflections" "*.md" "axiom-reflections" >> "$INDEX_FILE" # Generate Axiom's Ideas section generate_file_list "$ARCHIVE_WEB/axiom-ideas" "Axiom's Ideas & Thoughts" "*.txt" "axiom-ideas" >> "$INDEX_FILE" # Generate Axiom's Drafts section generate_file_list "$ARCHIVE_WEB/axiom-drafts" "Axiom's Blog Drafts" "*.md" "axiom-drafts" >> "$INDEX_FILE" # Generate Axiom's Current State section echo "

๐Ÿง  Axiom's Current State

" >> "$INDEX_FILE" echo "

Current focus and learning log.

" >> "$INDEX_FILE" generate_file_list "$ARCHIVE_WEB/axiom-state" "" "*" >> "$INDEX_FILE" echo "
" >> "$INDEX_FILE" # Add footer cat >> "$INDEX_FILE" << 'EOF'
EOF # Replace placeholders with actual counts TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S %Z') HEALTH_COUNT=$(find "$ARCHIVE_WEB/logs" -maxdepth 1 -name "health-*.log" 2>/dev/null | wc -l) LOG_COUNT=$(find "$ARCHIVE_WEB/logs" -maxdepth 1 -name "log-analysis-*.log" 2>/dev/null | wc -l) AXIOM_LOG_COUNT=$(find "$ARCHIVE_WEB/axiom-logs" -maxdepth 1 -name "*.log" 2>/dev/null | wc -l) SCRIPT_COUNT=$(find "$ARCHIVE_WEB/scripts" -maxdepth 1 -name "*.sh" 2>/dev/null | wc -l) DOC_COUNT=$(find "$ARCHIVE_WEB/docs" -maxdepth 1 -type f 2>/dev/null | wc -l) REFLECTION_COUNT=$(find "$ARCHIVE_WEB/axiom-reflections" -maxdepth 1 -name "*.md" 2>/dev/null | wc -l) sed -i "s/TIMESTAMP/$TIMESTAMP/g" "$INDEX_FILE" sed -i "s/HEALTH_COUNT/$HEALTH_COUNT/g" "$INDEX_FILE" sed -i "s/LOG_COUNT/$LOG_COUNT/g" "$INDEX_FILE" sed -i "s/AXIOM_LOG_COUNT/$AXIOM_LOG_COUNT/g" "$INDEX_FILE" sed -i "s/SCRIPT_COUNT/$SCRIPT_COUNT/g" "$INDEX_FILE" sed -i "s/DOC_COUNT/$DOC_COUNT/g" "$INDEX_FILE" sed -i "s/REFLECTION_COUNT/$REFLECTION_COUNT/g" "$INDEX_FILE" echo "Archive index generated at $INDEX_FILE"