-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhyper_clone_container.sh
More file actions
64 lines (49 loc) · 1.52 KB
/
hyper_clone_container.sh
File metadata and controls
64 lines (49 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# hyper_clone_container.sh – Full Codex rootfs archive with metadata
set -e
OUT_DIR="hyperspace-container"
ARCHIVE_NAME="codex_full_dump.tar.gz"
BASE64_NAME="codex_full_dump.b64"
echo "[🚀] Creating hyperspace export directory..."
mkdir -p "$OUT_DIR"
echo "[📦] Archiving root filesystem (excluding runtime paths)..."
tar --exclude=/proc \
--exclude=/sys \
--exclude=/dev \
--exclude=/tmp \
--exclude=/mnt \
--exclude=/media \
--exclude=/run \
-czf "$OUT_DIR/$ARCHIVE_NAME" -C / .
echo "[🌲] Generating filesystem tree view..."
command -v tree &> /dev/null && tree -a -L 5 / > "$OUT_DIR/FILESYSTEM_TREE.md" || echo "[!] 'tree' not found"
echo "[🧬] Writing TOML system description..."
cat <<EOF > "$OUT_DIR/system.toml"
[system]
distro = "Ubuntu 24.04"
kernel = "$(uname -r)"
arch = "$(uname -m)"
shell = "/bin/bash"
entrypoint = "/bin/bash"
[metadata]
generated_by = "hyper_clone_container.sh"
timestamp = "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
EOF
echo "[🔁] Encoding archive to base64..."
base64 "$OUT_DIR/$ARCHIVE_NAME" > "$OUT_DIR/$BASE64_NAME"
echo "[📘] Creating rehydration guide..."
cat <<EOF > "$OUT_DIR/rebuild.md"
# Rehydrating Codex Snapshot
This archive contains a base64-encoded full filesystem dump.
## To extract:
\`\`\`bash
base64 -d $BASE64_NAME > $ARCHIVE_NAME
mkdir restored
tar -xzf $ARCHIVE_NAME -C restored/
cd restored
./bin/bash
\`\`\`
EOF
echo "[🧼] Cleaning up intermediate archive..."
rm "$OUT_DIR/$ARCHIVE_NAME"
echo "[✅] Done! All output in '$OUT_DIR'."