#!/usr/local/bin/php
<?php

require_once('config.inc');
require_once('util.inc');

use OPNsense\RMMAgent\RMMAgent;

$mdl = new RMMAgent();

$backendUrl = (string)$mdl->general->BackendUrl;
$apiKey = (string)$mdl->general->ApiKey;
$interval = (string)$mdl->general->Interval;
$agentName = (string)$mdl->general->AgentName;
$insecure = (string)$mdl->general->Insecure;

if (empty($interval)) {
    $interval = "60";
}

echo "# RMM Agent Configuration — auto-generated\n";
echo "# Do not edit — changes via OPNsense WebGUI\n\n";
echo "backend_url: \"{$backendUrl}\"\n";
echo "api_key: \"{$apiKey}\"\n";
echo "interval_seconds: {$interval}\n";

if (!empty($agentName)) {
    echo "agent_name: \"{$agentName}\"\n";
}

// insecure is handled via command-line flag, not config
