#! /usr/bin/perl # Server daemon to import data into request tracker (part of MJohn) # !!! Experimental: this all is subject to change very soon !!! use strict; use warnings; # Configuration # TODO: the same paragraph as in daemon script. use Config::Simple; my %C; Config::Simple->import_from('~/.john/mjohn.conf', \%C); # TODO: check that we are there. chdir $C{lair}; # This daemon shares settings and whole architecture with client # daemon. # We traverse our folders in the lair. while (1) { `git pull`; for (<*/>) { chdir $_; # We add new attack. my $attack_name = $_; # Check if we already added that attack. # TODO: remember to export vars with credentials to access rt. # TODO: inefficient. We could get list of all once. Or we # could store status in file near, though it could become not # synced with rt. # TODO: 'No matches found' could be in field. Add ^ and $ and # test. Is there a machine readable interface? # TODO: rt ls 'subject=user1_name1341851801/' # -> Query:subject='user1_name1341851801'/ . "/" is in wrong place. if (`rt ls "subject='$attack_name'"` =~ 'No matches found') { # No such attack. Add it. # TODO: cats are nice pets. Do not use them so. # TODO: text is not for parameters. Use custom fields instead! # TODO: should not I add a ticket from user which did this attack? `rt create -t ticket set 'subject=$attack_name' "text=\$(cat parameters)"`; } # TODO: We update speeds. chdir $C{lair}; } # TODO: probably we should sleep during delay minus time spent on work. sleep $C{daemon_delay}; }