summaryrefslogtreecommitdiffstats
path: root/seed.sh
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-05-06 19:08:45 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-05-06 19:08:45 +0800
commiteddb76ad8c6e850c7e24f97ff27a185d48b104ee (patch)
tree3ffe8f996aea9cf68f3b5df0c6183cbade2cec74 /seed.sh
parent4623c35ed189c8ed6b9ced043a9df4e7f9558ba0 (diff)
downloadsite-search-bm-eddb76ad8c6e850c7e24f97ff27a185d48b104ee.tar.gz
Ensure 16 KB content in test files.
Diffstat (limited to 'seed.sh')
-rwxr-xr-xseed.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/seed.sh b/seed.sh
new file mode 100755
index 0000000..f6f817d
--- /dev/null
+++ b/seed.sh
@@ -0,0 +1,37 @@
+#!/bin/ksh
+
+# Accept directory count as an argument, default to 500
+TOTAL=${1:-500}
+
+# Define the base path relative to the script location
+SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
+BASE_DIR="$SCRIPT_DIR/_site/log"
+
+# Target size: 16000 bytes is ~15.6 KB
+CONTENT_SIZE=16000
+
+# Ensure the target directory exists
+mkdir -p "$BASE_DIR"
+
+for i in $(seq 1 $TOTAL); do
+ DIR="$BASE_DIR/site_$i"
+ mkdir -p "$DIR"
+
+ # Start the file structure
+ echo "<html><head><title>Site $i</title></head><body><main><p>" > "$DIR/index.html"
+
+ # Generate random text using dd for byte-level precision
+ # We read 32KB of raw data to account for characters filtered out by tr,
+ # then use dd again to trim the result to exactly CONTENT_SIZE bytes.
+ dd if=/dev/urandom bs=32768 count=1 2>/dev/null | tr -dc 'a-zA-Z0-9 ' | dd bs=1 count=$CONTENT_SIZE 2>/dev/null >> "$DIR/index.html"
+
+ # Append keyword and close tags
+ echo " Searchable content here for keyword_$i. </p></main></body></html>" >> "$DIR/index.html"
+
+ # Print progress every 100 files
+ if [ $((i % 100)) -eq 0 ]; then
+ echo "Created $i files..."
+ fi
+done
+
+echo "Done! $TOTAL directories created in $BASE_DIR."