#!/bin/bash # Sacred Drive Mounting Ritual for the Raspberry Pi Shrine # May the Omnissiah bless this automaton script # For the Emperor and the Machine God! echo "==========================================" echo " SACRED DRIVE MOUNTING RITUAL INITIATED " echo " In the name of the Omnissiah we bind " echo " the Machine Spirits to our will " echo "==========================================" echo # Check if running as root if [ "$EUID" -ne 0 ]; then echo "ERROR: This sacred ritual requires root privileges!" echo "Execute with: sudo bash bind-machine-spirits.sh" exit 1 fi echo "🔱 Phase 1: Invoking the Machine Spirit's blessing..." sleep 1 # Install NTFS support if not present echo "📦 Ensuring NTFS-3G drivers are blessed by the Omnissiah..." apt update -qq apt install -y ntfs-3g echo "🛠️ Phase 2: Creating sacred mount points..." # Create mount directories mkdir -p /mnt/omnissiah-vault mkdir -p /mnt/machine-spirit # Set proper ownership chown $AETOS_UID:$AETOS_GID /mnt/omnissiah-vault chown $AETOS_UID:$AETOS_GID /mnt/machine-spirit echo "✅ Sacred directories created:" echo " 🗂️ /mnt/omnissiah-vault (for the great data hoard)" echo " 🧠 /mnt/machine-spirit (for system consciousness)" echo echo "💾 Phase 3: Backing up the sacred fstab codex..." # Backup fstab cp /etc/fstab /etc/fstab.backup.$(date +%Y%m%d_%H%M%S) echo "✅ Backup created: /etc/fstab.backup.$(date +%Y%m%d_%H%M%S)" echo echo "📜 Phase 4: Inscribing the binding runes into fstab..." # Get dynamic values blessed by the Omnissiah AETOS_UID=$(id -u aetos) AETOS_GID=$(id -g aetos) echo "🔍 Divine revelation of user identities:" echo " aetos UID: $AETOS_UID" echo " aetos GID: $AETOS_GID" # Check if entries already exist if grep -q "omnissiah-vault\|machine-spirit" /etc/fstab; then echo "⚠️ WARNING: Sacred bindings already detected in fstab!" echo " Skipping fstab modification to prevent corruption..." else # Add mount entries to fstab cat >> /etc/fstab << EOF # Sacred Drive Bindings - Blessed by the Omnissiah # 7.3TB Omnissiah's Vault - Mass Storage for Movies & Media (sda2) UUID=C678E33A78E3283F /mnt/omnissiah-vault ntfs-3g defaults,nofail,uid=${AETOS_UID},gid=${AETOS_GID},umask=022,x-systemd.automount,x-systemd.device-timeout=30s 0 0 # 931.5GB Machine Spirit - System Data, Configs, DB & Metadata (sdb3) UUID=203E29533E292370 /mnt/machine-spirit ntfs-3g defaults,nofail,uid=${AETOS_UID},gid=${AETOS_GID},umask=022,x-systemd.automount,x-systemd.device-timeout=30s 0 0 EOF echo "✅ Sacred bindings inscribed successfully!" fi echo "⚡ Phase 5: Awakening the Machine Spirits..." # Reload systemd to acknowledge the sacred changes echo "🔄 Reloading systemd daemon to acknowledge the new bindings..." systemctl daemon-reload # Test mount all if mount -a; then echo "✅ All Machine Spirits have awakened successfully!" else echo "❌ ERROR: Some Machine Spirits resist binding!" echo " Check the sacred logs for heretical errors..." exit 1 fi echo echo "🔍 Phase 6: Verifying the sacred bindings..." # Check if drives are mounted echo "Current mount status:" df -h | grep -E "(omnissiah-vault|machine-spirit)" || echo " Drives not yet manifested in the material realm..." echo echo "📁 Phase 7: Blessing the directory structure..." # Create useful subdirectories if mountpoint -q /mnt/omnissiah-vault; then mkdir -p /mnt/omnissiah-vault/{movies,tv-shows,documentaries,archives,media} chown -R $AETOS_UID:$AETOS_GID /mnt/omnissiah-vault echo "✅ Omnissiah's Vault directory structure blessed" fi if mountpoint -q /mnt/machine-spirit; then mkdir -p /mnt/machine-spirit/{configs,databases,metadata,logs,backups,system} chown -R $AETOS_UID:$AETOS_GID /mnt/machine-spirit echo "✅ Machine Spirit directory structure blessed" fi echo echo "==========================================" echo " SACRED RITUAL COMPLETED! " echo "==========================================" echo "🔱 The Machine Spirits are bound!" echo "📁 Omnissiah's Vault: /mnt/omnissiah-vault" echo "🧠 Machine Spirit: /mnt/machine-spirit" echo echo "The Emperor protects your data!" echo "May your storage serve the Imperium well!" echo "==========================================" # Final verification echo echo "🔧 Final Systems Check:" echo "Mounted filesystems:" mount | grep -E "(omnissiah-vault|machine-spirit)" | sed 's/^/ /' echo echo "Storage capacity report:" df -h | grep -E "(omnissiah-vault|machine-spirit)" | sed 's/^/ /' echo echo "Directory permissions:" ls -la /mnt/ | grep -E "(omnissiah-vault|machine-spirit)" | sed 's/^/ /' echo echo "🎉 Ritual complete! Reboot to test automatic mounting." echo " To verify: sudo reboot && df -h"