#!/bin/sh # Helper script to check for updates and system status # Configuration UPDATE_SERVER="" BOARD_NAME="raspberrypi3" SW_VERSION=$(cat /etc/sw-version 2>/dev/null || echo "1.0.0") # Get current system state get_current_status() { # Get active partition ACTIVE_PART=$(fw_printenv -n active_part 2>/dev/null || echo "Unknown") echo "Active partition: $ACTIVE_PART" # Get inactive partition INACTIVE_PART=$(fw_printenv -n inactive_part 2>/dev/null || echo "Unknown") echo "Inactive partition: $INACTIVE_PART" # Get boot count BOOT_COUNT=$(fw_printenv -n bootcount 2>/dev/null || echo "Unknown") echo "Boot count: $BOOT_COUNT" # Check if system was recently updated if [ -e /tmp/swupdate.done ]; then echo "System was updated" UPDATED=1 else echo "No recent update" UPDATED=0 fi # Check if there's an update available (if server is configured) if [ -n "$UPDATE_SERVER" ]; then echo "Checking for updates from $UPDATE_SERVER..." # Simple curl check - in production, this would be more robust if curl -s -f "$UPDATE_SERVER/api/check?board=$BOARD_NAME&version=$SW_VERSION" >/dev/null; then echo "Update available" UPDATE_AVAILABLE=1 else echo "No update available" UPDATE_AVAILABLE=0 fi else echo "No update server configured" UPDATE_AVAILABLE=0 fi } # Reset update status reset_update_status() { echo "Resetting update status" rm -f /tmp/swupdate.done } # Main case "$1" in status) get_current_status ;; reset) reset_update_status ;; *) echo "Usage: $0 {status|reset}" exit 1 ;; esac exit 0