From df623c3680ea8d3c7b030cb81d061e99636333c6 Mon Sep 17 00:00:00 2001 From: SJ Date: Tue, 20 May 2014 12:55:48 +0200 Subject: [PATCH] using --webui in all util scripts --- etc/cron.jobs.in | 4 ++-- util/daily-report.php | 46 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/etc/cron.jobs.in b/etc/cron.jobs.in index 527ac697..d7adfd44 100644 --- a/etc/cron.jobs.in +++ b/etc/cron.jobs.in @@ -13,10 +13,10 @@ piler's crontab: */15 * * * * /usr/local/bin/indexer --quiet note1 --rotate ### optional: the same report you can see on the health page -30 7 * * * /usr/bin/php LIBEXECDIR/piler/daily-report.php /srv/www/webui.yourdomain.com +30 7 * * * /usr/bin/php LIBEXECDIR/piler/daily-report.php --webui /srv/www/webui.yourdomain.com ### optional: populate accouting data -30 6 * * * /usr/bin/php LIBEXECDIR/piler/generate_stats.php /srv/www/webui.yourdomain.com +30 6 * * * /usr/bin/php LIBEXECDIR/piler/generate_stats.php --webui /srv/www/webui.yourdomain.com ### optional: purge aged emails 2 0 * * * /usr/local/bin/pilerpurge diff --git a/util/daily-report.php b/util/daily-report.php index 11e28b74..f24bada2 100644 --- a/util/daily-report.php +++ b/util/daily-report.php @@ -8,12 +8,40 @@ $averagemessagesweekraw = $averagemessagesmonthraw = $averagemessagesizeraw = $a $_SERVER['HTTP_USER_AGENT'] = "daily/cron"; -if(isset($_SERVER['argv'][1])) { $webuidir = $_SERVER['argv'][1]; } - -for($i=2; $i<$_SERVER['argc']; $i++){ - if($_SERVER['argv'][$i] == "verbose") { $verbose = 1; } +$opts = 'h::v'; +$lopts = array( + 'webui:', + 'verbose' + ); + +if ( $options = getopt( $opts, $lopts ) ) +{ + if ( isset($options['webui']) ) + { + $webuidir = $options['webui']; + } else + { + echo("\nError: must provide path to WebUI directory\n\n"); + + display_help(); + exit; + } + + if ( isset($options['h']) ) + { + display_help(); + exit; + } + if ( isset($options['verbose']) ) + { + $verbose = 1; + } +} else { + display_help(); + exit; } + require_once($webuidir . "/config.php"); require(DIR_SYSTEM . "/startup.php"); @@ -157,4 +185,14 @@ if($fp) { } +function display_help() { + $phpself = basename(__FILE__); + echo("\nUsage: $phpself --webui [PATH] [OPTIONS...]\n\n"); + echo("\t--webui=\"[REQUIRED: path to the Piler WebUI Directory]\"\n\n"); + echo("options:\n"); + echo("\t-v Provide a verbose output\n"); + echo("\t-h Prints this help screen and exits\n"); +} + + ?>