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

require_once('config.inc');
require_once('interfaces.inc');
require_once('rrd.inc');
require_once('util.inc');
require_once('system.inc');

if (count($argv) > 1 && is_numeric($argv[1])) {
    // starting delayed.
    sleep($argv[1]);
}

system_firmware_configure();

echo 'Restarting webConfigurator...';

killbyname('lighttpd');

/*
 * Force reloading all php-cgi children to
 * avoid hiccups with moved include files.
 */
killbyname('php-cgi', 'HUP');

while (is_process_running('lighttpd')) {
        echo '.';
        sleep(1);
}

system_webgui_start();
enable_rrd_graphing();

echo 'done.' . PHP_EOL;
