diff options
author | Carlo von lynX <lynX@time.to.get.psyced.org> | 2016-06-09 14:36:14 +0000 |
---|---|---|
committer | Carlo von lynX <lynX@time.to.get.psyced.org> | 2016-06-09 14:36:14 +0000 |
commit | a970e9d70979c0e378a009791dc9da6c029f8526 (patch) | |
tree | 4cce2ce03d93461707a8cdbbe74e09e0048e650c /contrib | |
parent | 727c093dc23c71c792261e295c3d628824bd8ccc (diff) | |
download | gnunet-a970e9d70979c0e378a009791dc9da6c029f8526.tar.gz gnunet-a970e9d70979c0e378a009791dc9da6c029f8526.zip |
improved usability for gnunet-logread -f
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/gnunet-logread | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/contrib/gnunet-logread b/contrib/gnunet-logread index 6205f4123..2e54d133f 100755 --- a/contrib/gnunet-logread +++ b/contrib/gnunet-logread | |||
@@ -31,9 +31,13 @@ Options: | |||
31 | -m <regex> Only pass messages matching a regular expression. | 31 | -m <regex> Only pass messages matching a regular expression. |
32 | X | 32 | X |
33 | 33 | ||
34 | use POSIX qw(mkfifo); | ||
35 | |||
34 | use Term::ANSIColor qw(:constants :pushpop); | 36 | use Term::ANSIColor qw(:constants :pushpop); |
35 | $Term::ANSIColor::AUTOLOCAL = 1; | 37 | $Term::ANSIColor::AUTOLOCAL = 1; |
36 | 38 | ||
39 | my %levels = ( NONE => 0, ERROR => 1, WARNING => 2, INFO => 4, DEBUG => 8 ); | ||
40 | |||
37 | # Message type numbers to names | 41 | # Message type numbers to names |
38 | my %msgtypes; | 42 | my %msgtypes; |
39 | my $prefix = $ENV{GNUNET_PREFIX} || '/usr'; | 43 | my $prefix = $ENV{GNUNET_PREFIX} || '/usr'; |
@@ -57,10 +61,19 @@ Try also '$0 -h' for help | |||
57 | X | 61 | X |
58 | } | 62 | } |
59 | 63 | ||
60 | my %levels = ( NONE => 0, ERROR => 1, WARNING => 2, INFO => 4, DEBUG => 8 ); | 64 | die "You can't read and write the socket at the same time" |
61 | if (exists $opts{n}) | 65 | if exists $opts{f} and exists $opts{n}; |
62 | { | 66 | |
63 | die "You can't read and write the socket at the same time" if exists $opts{f}; | 67 | if ((exists $opts{n} or exists $opts{f}) and not -r $ipc) { |
68 | undef $!; | ||
69 | die "Could not mkfifo $ipc: $!" unless mkfifo $ipc, 0600; | ||
70 | system('chgrp', 'gnunet', $ipc); | ||
71 | die "Could not chgrp $ipc to 'gnunet': $!" if $!; | ||
72 | chmod 0660, $ipc; | ||
73 | die "Could not chmod $ipc to allow gnunet group writes: $!" if $!; | ||
74 | } | ||
75 | |||
76 | if (exists $opts{n}) { | ||
64 | $name = $opts{n}; | 77 | $name = $opts{n}; |
65 | $msg_level = $opts{L} && exists $levels{$opts{L}} ? $levels{$opts{L}} : 0; | 78 | $msg_level = $opts{L} && exists $levels{$opts{L}} ? $levels{$opts{L}} : 0; |
66 | $msg_regex = $opts{m}; | 79 | $msg_regex = $opts{m}; |
@@ -69,7 +82,6 @@ if (exists $opts{n}) | |||
69 | } | 82 | } |
70 | 83 | ||
71 | if (exists $opts{f}) { | 84 | if (exists $opts{f}) { |
72 | system('/bin/mkfifo', $ipc) unless -r $ipc; | ||
73 | open(I, $ipc) or die "Cannot read from $ipc: $!"; | 85 | open(I, $ipc) or die "Cannot read from $ipc: $!"; |
74 | &perform while <I>; | 86 | &perform while <I>; |
75 | close I; | 87 | close I; |