mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 01:51:59 +01:00
Added command line options to export-attachments.php
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
ca6fddedf6
commit
edceee12c9
@ -2,8 +2,31 @@
|
|||||||
|
|
||||||
define('LOCK_FILE', '/var/piler/tmp/export-attachments.lock');
|
define('LOCK_FILE', '/var/piler/tmp/export-attachments.lock');
|
||||||
|
|
||||||
|
$webuidir = "";
|
||||||
|
|
||||||
require_once("config.php");
|
$outdir = '';
|
||||||
|
|
||||||
|
|
||||||
|
$opts = 'hw:d:';
|
||||||
|
$lopts = [
|
||||||
|
'webui:',
|
||||||
|
'dir:',
|
||||||
|
'help'
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
if($options = getopt($opts, $lopts)) {
|
||||||
|
if(isset($options['webui'])) { $webuidir = $options['webui']; }
|
||||||
|
if(isset($options['dir'])) { $outdir = $options['dir']; }
|
||||||
|
if(isset($options['help'])) { usage(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($webuidir == '' || $outdir == '') { usage(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
require_once("$webuidir/config.php");
|
||||||
|
|
||||||
require(DIR_SYSTEM . "/startup.php");
|
require(DIR_SYSTEM . "/startup.php");
|
||||||
|
|
||||||
@ -27,8 +50,6 @@ Registry::set('db', $db);
|
|||||||
|
|
||||||
Registry::set('auditor_user', 1);
|
Registry::set('auditor_user', 1);
|
||||||
|
|
||||||
$outdir = "/path/to/attachments";
|
|
||||||
|
|
||||||
openlog("export-attachments", LOG_PID, LOG_MAIL);
|
openlog("export-attachments", LOG_PID, LOG_MAIL);
|
||||||
|
|
||||||
$fp = fopen(LOCK_FILE, "w");
|
$fp = fopen(LOCK_FILE, "w");
|
||||||
@ -68,3 +89,14 @@ $attachment->update_checkpoint($i);
|
|||||||
// Release lock
|
// Release lock
|
||||||
flock($fp, LOCK_UN);
|
flock($fp, LOCK_UN);
|
||||||
fclose($fp);
|
fclose($fp);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function usage() {
|
||||||
|
print "\nUsage: " . __FILE__ . "\n\n";
|
||||||
|
print "\t--webui <path to webui directory>\n";
|
||||||
|
print "\t--dir <basedir to write attachments>\n";
|
||||||
|
print "\t--help\n\n";
|
||||||
|
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user