- Add docs/README.md with project overview and current status - Add docs/architecture.md with detailed architecture documentation - Add docs/development.md with development guide for contributors - Update .notes/todo.md to reflect architecture fix completion - Update .notes/plan.md with completed phases and next priorities Architecture fixes (daemon and dbus), bubblewrap integration are now complete. Ready for OCI integration phase.
181 lines
No EOL
6.6 KiB
Bash
Executable file
181 lines
No EOL
6.6 KiB
Bash
Executable file
#!/bin/bash
|
|
# Complete Cleanup and Reinstall for apt-ostree
|
|
# This script removes ALL apt-ostree services and policies, then reinstalls fresh
|
|
|
|
set -e
|
|
|
|
echo "=== Complete apt-ostree Cleanup and Reinstall ==="
|
|
echo
|
|
|
|
echo "Killing all apt-ostree processes..."
|
|
pkill -f apt-ostree || true
|
|
pkill -f apt-ostreed || true
|
|
pkill -f apt-ostree-bootstatus || true
|
|
pkill -f apt-ostree-countme || true
|
|
|
|
# Check if running as root
|
|
if [[ $EUID -ne 0 ]]; then
|
|
echo "This script must be run as root"
|
|
exit 1
|
|
fi
|
|
|
|
echo "=== PHASE 1: STOPPING AND DISABLING ALL SERVICES ==="
|
|
|
|
echo "1. Stopping all apt-ostree services..."
|
|
systemctl stop apt-ostreed.service 2>/dev/null || echo " apt-ostreed.service not running"
|
|
systemctl stop apt-ostree-bootstatus.service 2>/dev/null || echo " apt-ostree-bootstatus.service not running"
|
|
systemctl stop apt-ostree-countme.service 2>/dev/null || echo " apt-ostree-countme.service not running"
|
|
systemctl stop apt-ostreed-automatic.service 2>/dev/null || echo " apt-ostreed-automatic.service not running"
|
|
|
|
echo "2. Disabling all apt-ostree services..."
|
|
systemctl disable apt-ostreed.service 2>/dev/null || echo " apt-ostreed.service not enabled"
|
|
systemctl disable apt-ostree-bootstatus.service 2>/dev/null || echo " apt-ostree-bootstatus.service not enabled"
|
|
systemctl disable apt-ostree-countme.service 2>/dev/null || echo " apt-ostree-countme.service not enabled"
|
|
systemctl disable apt-ostree-countme.timer 2>/dev/null || echo " apt-ostree-countme.timer not enabled"
|
|
systemctl disable apt-ostreed-automatic.service 2>/dev/null || echo " apt-ostreed-automatic.service not enabled"
|
|
systemctl disable apt-ostreed-automatic.timer 2>/dev/null || echo " apt-ostreed-automatic.timer not enabled"
|
|
|
|
echo "=== PHASE 2: REMOVING ALL SERVICE FILES ==="
|
|
|
|
echo "3. Removing systemd service files..."
|
|
rm -f /etc/systemd/system/apt-ostreed.service
|
|
rm -f /etc/systemd/system/apt-ostree-bootstatus.service
|
|
rm -f /etc/systemd/system/apt-ostree-countme.service
|
|
rm -f /etc/systemd/system/apt-ostree-countme.timer
|
|
rm -f /etc/systemd/system/apt-ostreed-automatic.service
|
|
rm -f /etc/systemd/system/apt-ostreed-automatic.timer
|
|
|
|
echo "4. Removing ALL D-Bus policy files (including old ones)..."
|
|
rm -f /etc/dbus-1/system.d/org.aptostree.dev.conf
|
|
rm -f /etc/dbus-1/system.d/org.aptostree*.conf
|
|
rm -f /etc/dbus-1/system.d/org.debian.aptostree1.conf.old_python
|
|
rm -f /etc/dbus-1/system.d/org.projectatomic.aptostree1.conf
|
|
|
|
echo "5. Removing D-Bus service files..."
|
|
rm -f /usr/share/dbus-1/system-services/org.aptostree.dev.service
|
|
rm -f /usr/share/dbus-1/system-services/org.aptostree*.service
|
|
|
|
echo "6. Removing ALL Polkit policy files..."
|
|
rm -f /usr/share/polkit-1/actions/org.aptostree.dev.policy
|
|
rm -f /usr/share/polkit-1/actions/org.aptostree*.policy
|
|
|
|
echo "7. Removing ALL configuration files..."
|
|
rm -rf /etc/apt-ostree/
|
|
mkdir -p /etc/apt-ostree
|
|
|
|
echo "=== PHASE 3: REMOVING BINARIES ==="
|
|
|
|
echo "8. Removing binaries..."
|
|
rm -f /usr/libexec/apt-ostreed
|
|
rm -f /usr/bin/apt-ostree
|
|
rm -f /usr/bin/apt-ostreed
|
|
|
|
echo "=== PHASE 4: RELOADING SYSTEMD AND D-BUS ==="
|
|
|
|
echo "9. Reloading systemd..."
|
|
systemctl daemon-reload
|
|
|
|
echo "10. Reloading D-Bus..."
|
|
systemctl reload dbus
|
|
|
|
echo "11. Waiting for cleanup to complete..."
|
|
sleep 2
|
|
|
|
echo "=== PHASE 5: REBUILDING AND REINSTALLING ==="
|
|
|
|
echo "12. Rebuilding project..."
|
|
# Use the user's environment to find cargo
|
|
if [[ -n "$SUDO_USER" ]]; then
|
|
echo " Using user environment for cargo..."
|
|
sudo -u "$SUDO_USER" cargo build --release
|
|
else
|
|
echo " Trying to find cargo in PATH..."
|
|
# Try common cargo locations
|
|
if command -v cargo >/dev/null 2>&1; then
|
|
cargo build --release
|
|
elif [[ -f "/home/$SUDO_USER/.cargo/bin/cargo" ]]; then
|
|
/home/$SUDO_USER/.cargo/bin/cargo build --release
|
|
elif [[ -f "/usr/local/bin/cargo" ]]; then
|
|
/usr/local/bin/cargo build --release
|
|
else
|
|
echo " ERROR: cargo not found. Please run 'cargo build --release' manually as user, then continue."
|
|
echo " Press Enter when build is complete..."
|
|
read -r
|
|
fi
|
|
fi
|
|
|
|
echo "13. Installing fresh 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 "14. Installing fresh 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 "15. Installing fresh 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 "16. Installing fresh Polkit policy..."
|
|
cp src/daemon/org.aptostree.dev.policy /usr/share/polkit-1/actions/
|
|
|
|
echo "17. Installing fresh configuration..."
|
|
cp src/daemon/apt-ostreed.conf /etc/apt-ostree/
|
|
|
|
echo "18. 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 6: ENABLING AND STARTING SERVICES ==="
|
|
|
|
echo "19. Reloading systemd and D-Bus..."
|
|
systemctl daemon-reload
|
|
systemctl reload dbus
|
|
|
|
echo "20. 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 "21. Starting main daemon..."
|
|
systemctl start apt-ostreed.service
|
|
|
|
echo "22. Waiting for daemon to start..."
|
|
sleep 3
|
|
|
|
echo "=== PHASE 7: VERIFICATION ==="
|
|
|
|
echo "23. 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 "24. 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 "25. 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 "=== CLEANUP AND REINSTALL COMPLETE ==="
|
|
echo "All old services and policies have been removed and fresh ones installed." |