#!/bin/bash echo "=== Complete apt-ostree System Test ===" echo "Date: $(date)" echo "" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Function to print colored output print_status() { if [ $1 -eq 0 ]; then echo -e "${GREEN}✅ $2${NC}" else echo -e "${RED}❌ $2${NC}" fi } echo "1. Checking binaries..." if [ -f /usr/bin/apt-ostree ]; then print_status 0 "CLI binary exists" /usr/bin/apt-ostree --help > /dev/null 2>&1 print_status $? "CLI binary works" else print_status 1 "CLI binary missing" fi if [ -f /usr/libexec/apt-ostreed ]; then print_status 0 "Daemon binary exists" /usr/libexec/apt-ostreed --help > /dev/null 2>&1 print_status $? "Daemon binary works" else print_status 1 "Daemon binary missing" fi echo "" echo "2. Checking D-Bus configuration..." if [ -f /etc/dbus-1/system.d/org.aptostree.dev.conf ]; then print_status 0 "D-Bus policy file exists" else print_status 1 "D-Bus policy file missing" fi echo "" echo "3. Checking systemd service..." if [ -f /etc/systemd/system/apt-ostreed.service ]; then print_status 0 "Systemd service file exists" else print_status 1 "Systemd service file missing" fi echo "" echo "4. Starting daemon..." # Kill any existing daemon sudo pkill -f apt-ostreed 2>/dev/null || true sleep 2 # Start daemon sudo /usr/libexec/apt-ostreed & DAEMON_PID=$! sleep 3 if kill -0 $DAEMON_PID 2>/dev/null; then print_status 0 "Daemon started (PID: $DAEMON_PID)" else print_status 1 "Daemon failed to start" exit 1 fi echo "" echo "5. Testing D-Bus registration..." sleep 2 if busctl list | grep org.aptostree.dev > /dev/null; then print_status 0 "Daemon registered on D-Bus" else print_status 1 "Daemon not registered on D-Bus" fi echo "" echo "6. Testing D-Bus methods..." PING_RESULT=$(busctl call org.aptostree.dev /org/aptostree/dev/Daemon org.aptostree.dev.Daemon Ping 2>&1) if [ $? -eq 0 ]; then print_status 0 "Ping method works: $PING_RESULT" else print_status 1 "Ping method failed: $PING_RESULT" fi STATUS_RESULT=$(busctl call org.aptostree.dev /org/aptostree/dev/Daemon org.aptostree.dev.Daemon Status 2>&1) if [ $? -eq 0 ]; then print_status 0 "Status method works" else print_status 1 "Status method failed: $STATUS_RESULT" fi echo "" echo "7. Testing CLI communication..." if [ -f /usr/bin/apt-ostree ]; then CLI_PING=$(apt-ostree daemon-ping 2>&1) if [ $? -eq 0 ]; then print_status 0 "CLI ping works: $CLI_PING" else print_status 1 "CLI ping failed: $CLI_PING" fi CLI_STATUS=$(apt-ostree daemon-status 2>&1) if [ $? -eq 0 ]; then print_status 0 "CLI status works" else print_status 1 "CLI status failed: $CLI_STATUS" fi else print_status 1 "CLI binary not found" fi echo "" echo "8. Testing package operations..." LIST_RESULT=$(busctl call org.aptostree.dev /org/aptostree/dev/Daemon org.aptostree.dev.Daemon ListPackages 2>&1) if [ $? -eq 0 ]; then print_status 0 "List packages works" else print_status 1 "List packages failed: $LIST_RESULT" fi echo "" echo "9. Testing search functionality..." SEARCH_RESULT=$(busctl call org.aptostree.dev /org/aptostree/dev/Daemon org.aptostree.dev.Daemon SearchPackages "apt" false 2>&1) if [ $? -eq 0 ]; then print_status 0 "Search packages works" else print_status 1 "Search packages failed: $SEARCH_RESULT" fi echo "" echo "10. Summary..." echo "Daemon PID: $DAEMON_PID" echo "D-Bus registered: $(busctl list | grep org.aptostree.dev > /dev/null && echo 'Yes' || echo 'No')" echo "CLI available: $(which apt-ostree > /dev/null && echo 'Yes' || echo 'No')" echo "" echo "=== Test Complete ===" echo "If you see mostly ✅ marks, everything is working!" echo "" echo "To stop the daemon: sudo kill $DAEMON_PID" echo "To test more commands: apt-ostree --help"