#!/usr/bin/env bash # Q003-prep.sh — hermes baseline: logrotate missing, nginx access log ballooning # # Prepares sc-web-server for Q003 "The Log That Ate the Disk". # Assumes Q002 is already resolved (nginx is running, config is clean). # # What this does: # - Removes /etc/logrotate.d/nginx (log rotation not configured) # - Grows /var/log/nginx/access.log to ~80% disk pressure # - Disk usage should read >85% on /var so player sees the pressure # # Idempotent: safe to run multiple times. set -euo pipefail export LIBVIRT_DEFAULT_URI="${LIBVIRT_DEFAULT_URI:-qemu:///system}" DOMAIN="${1:-sc-web-server}" DRY_RUN=false [[ "${2:-}" == "--dry-run" ]] && DRY_RUN=true get_vm_ip() { local domain="$1" local addr="" addr="$(virsh domifaddr "$domain" --source agent 2>/dev/null | awk '/ipv4/ {print $4}' | cut -d/ -f1 | grep -v '^127\.' | head -n1 || true)" if [ -n "$addr" ]; then printf '%s\n' "$addr" return 0 fi local mac="" mac="$(virsh dumpxml "$domain" 2>/dev/null | sed -n "s/.*> /var/log/nginx/access.log" echo "Q003-prep: Done. /var/log/nginx/access.log inflated on $DOMAIN." echo " Check disk pressure with: df -h (on the VM)"