<?php
namespace App\Model;

class SystemImage {

    public $slotA;
    public $slotB;
    public $compatible;
    public $boot;
    
    public function __construct(){
	$status = json_decode(shell_exec('rauc status --detailed --output-format=json'), true);
	$this->compatible = $status['compatible'];
	$this->boot = $status['booted'];
	foreach($status['slots'] as $slot){
	    if(isset($slot['rootfs.0'])){
		['rootfs.0' => $slotA] = $slot;
		$this->slotA = new SystemSlot($slot['rootfs.0']);		
	    }
	    if(isset($slot['rootfs.1'])){
		['rootfs.1' => $slotB] = $slot;
		$this->slotB = new SystemSlot($slot['rootfs.1']);
	    }
	}
    }
}

?>
