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

require_once('config.inc');
require_once('functions.inc');
require_once('shaper.inc');
require_once('captiveportal.inc');
require_once('rrd.inc');

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

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();
captiveportal_init_webgui();
enable_rrd_graphing();

echo 'done.' . PHP_EOL;