#!/bin/bash # Complete apt-ostree Installation # This script builds as user, then installs as root set -e echo "=== Complete apt-ostree Installation ===" echo echo "=== PHASE 1: BUILDING PROJECT ===" echo "1. Building project as user..." if ! cargo build --release; then echo "ERROR: Build failed. Please check your Rust environment." exit 1 fi echo "✓ Build completed successfully" echo echo "=== PHASE 2: INSTALLING AS ROOT ===" echo "2. Checking if running as root..." if [[ $EUID -ne 0 ]]; then echo "This script must be run as root for installation" echo "Please run: sudo ./complete-install.sh" exit 1 fi echo "3. Installing binaries..." cp target/release/apt-ostreed /usr/libexec/ cp target/release/apt-ostree /usr/bin/ chmod +x /usr/libexec/apt-ostreed /usr/bin/apt-ostree echo "4. Installing service files..." cp src/daemon/apt-ostreed.service /etc/systemd/system/ cp src/daemon/apt-ostree-bootstatus.service /etc/systemd/system/ cp src/daemon/apt-ostree-countme.service /etc/systemd/system/ cp src/daemon/apt-ostree-countme.timer /etc/systemd/system/ cp src/daemon/apt-ostreed-automatic.service /etc/systemd/system/ cp src/daemon/apt-ostreed-automatic.timer /etc/systemd/system/ echo "5. Installing D-Bus files..." cp src/daemon/org.aptostree.dev.conf /etc/dbus-1/system.d/ cp src/daemon/org.aptostree.dev.service /usr/share/dbus-1/system-services/ echo "6. Installing Polkit policy..." cp src/daemon/org.aptostree.dev.policy /usr/share/polkit-1/actions/ echo "7. Installing configuration..." mkdir -p /etc/apt-ostree cp src/daemon/apt-ostreed.conf /etc/apt-ostree/ echo "8. Setting correct permissions..." chmod 644 /etc/dbus-1/system.d/org.aptostree.dev.conf chmod 644 /usr/share/dbus-1/system-services/org.aptostree.dev.service chmod 644 /usr/share/polkit-1/actions/org.aptostree.dev.policy chmod 644 /etc/apt-ostree/apt-ostreed.conf echo "=== PHASE 3: ENABLING AND STARTING SERVICES ===" echo "9. Reloading systemd and D-Bus..." systemctl daemon-reload systemctl reload dbus echo "10. Enabling services..." systemctl enable apt-ostreed.service systemctl enable apt-ostree-bootstatus.service systemctl enable apt-ostree-countme.timer systemctl enable apt-ostreed-automatic.timer echo "11. Starting main daemon..." systemctl start apt-ostreed.service echo "12. Waiting for daemon to start..." sleep 3 echo "=== PHASE 4: VERIFICATION ===" echo "13. Checking daemon status..." if systemctl is-active --quiet apt-ostreed.service; then echo "✓ Daemon is running" else echo "✗ Daemon failed to start" systemctl status apt-ostreed.service --no-pager exit 1 fi echo "14. Testing D-Bus communication..." echo "Testing introspection:" gdbus introspect --system --dest org.aptostree.dev --object-path /org/aptostree/dev/Daemon 2>&1 || echo "Introspection failed" echo "Testing ping:" gdbus call --system --dest org.aptostree.dev --object-path /org/aptostree/dev/Daemon --method org.aptostree.dev.Daemon.ping 2>&1 || echo "Ping failed" echo "15. Testing client-daemon communication..." echo "Testing client ping:" apt-ostree daemon-ping || echo "Client ping failed" echo "Testing client status:" apt-ostree daemon-status || echo "Client status failed" echo echo "=== INSTALLATION COMPLETE ===" echo "apt-ostree has been successfully installed and is ready to use!"