1 if ( getpwuid($<) ne $ifowner ) { print "You must be owner of ifmail\n"; exit 1; }
3 if ( (@ARGV < 3) || $ARGV[0] eq "-?" || $ARGV[0] eq "-h" ) {
7 $ARGV[0] =~ tr/A-Z/a-z/;
8 $ARGV[3] =~ tr/A-Z/a-z/;
12 if ( $logfile ne "" ) {
13 open(LOG, ">>".$logfile) || die "Can't open logfile";
16 if (substr($ARGV[1], 0, 1) ne "/") {
19 $ARGV[1] = $cwd."/".$ARGV[1];
22 if ($ARGV[3] eq "" || $ARGV[3] eq "normal") {
24 } elsif ($ARGV[3] eq "crash") {
26 } elsif ($ARGV[3] eq "hold") {
29 print "Unknown flavour, assuming normal\n";
33 if ($ARGV[0] eq "send") {
34 &attach($ARGV[1], $ARGV[2]);
35 } elsif ($ARGV[0] eq "get") {
36 &request($ARGV[1], $ARGV[2]);
38 print "Unknown command, try ifman -h\n";
46 #######################################################################
49 local($fspec, $address) = @_;
51 $floname = &resolve($address);
53 open(FLO, ">>".$outbound."/".$floname) || die "Can't open flo-file $outbound/$floname";
54 open(FIND, "find $fspec -print |") || die "Can't generate list of files";
57 print "No matching files, nothing to send\n";
64 $datestamp = `date \"+%D %T\"`;
66 printf LOG "%s %s %s\n", $datestamp, $$, "ifman: sending $_ to $address";
67 printf FLO "%s\n", $_;
75 local($fspec, $address) = @_;
77 $reqname = &resolve($address);
79 $reqname =~ s/\.[fch]lo/\.req/;
81 open(REQ, ">>".$outbound."/".$reqname) || die "Can't open req-file";
83 $datestamp = `date \"+%D %T\"`;
85 printf LOG "%s %s %s\n", $datestamp, $$, "ifman: requesting $fspec from $address";
86 printf REQ "%s\n", $fspec;
94 if ( index($addr, ":") >=0 ) {
95 print "I cannot resolve addresses with zones!\n";
97 } elsif ( index($addr, "/") == -1 ) {
98 print "Not a valid address!\n";
102 ($net, $node, $point) = split(/\/|\./, $addr);
104 if ( defined $point ) {
105 $pointdir = sprintf("%04x%04x.pnt", $net, $node);
106 if ( ! -e $outbound."/".$pointdir ) {
107 mkdir ($outbound."/".$pointdir, 0755) || die "Can't create point directory";
109 $flo = sprintf("0000%04x.%01slo", $point, $flavour);
110 return $pointdir."/".$flo;
112 $flo = sprintf("%04x%04x.%01slo", $net, $node, $flavour);
118 print "ifmail manager script\n";
119 print "usage: ifman <cmd> <filespec> <address> [flavour]\n";
120 print " commands: send, get\n";
121 print " flavours: normal, crash, hold. Default is normal.\n";
122 print "Only 2d addresses with points are supported - no zones!\n";
127 open(CFG, $cfgfile) || die "Can't open ifmail config file";
132 if (/^outbound\s+(\S+)/) { $outbound = $1; }
133 if (/^logfile\s+(\S+)/) { $logfile = $1; }