3 # CLI admin client for the FEX service
5 # Author: Ulli Horlacher <framstag@rus.uni-stuttgart.de>
12 use Digest::MD5 'md5_hex';
14 use constant M => 1024*1024;
15 use constant DS => 60*60*24;
18 exit if $ENV{SCRIPT_NAME};
20 unless ($FEXLIB = $ENV{FEXLIB}) {
22 $FEXLIB = $ENV{FEXHOME}.'/lib';
23 } elsif (-f '/usr/share/fex/lib/fex.ph') {
24 $FEXLIB = '/usr/share/fex/lib';
26 $FEXLIB = dirname(dirname(abs_path($0))).'/lib';
28 $ENV{FEXLIB} = $FEXLIB;
30 die "$0: no FEXLIB\n" unless -f "$FEXLIB/fex.pp";
32 # become effective user fex
34 if (my @pw = getpwnam('fex')) {
39 die "$0: no such user 'fex'\n";
46 our ($FEXHOME,$FHS,$hostname,$spooldir,$logdir,$akeydir,$docdir);
47 our ($durl,@durl,$mdomain,$admin,$mailmode);
48 our ($autodelete,$keep_default,$keep_max,$recipient_quota,$sender_quota);
49 our (@local_rdomains);
50 local $notification = 'full';
52 # load common code, local config : $HOME/lib/fex.ph
53 require "$FEXLIB/fex.pp" or die "$0: cannot load $FEXLIB/fex.pp - $!\n";
55 die "$0: \$admin not configured in $FEXLIB/fex.ph\n" unless $admin;
57 $EDITOR = $ENV{EDITOR} || $ENV{VISUAL} ||
58 (-x '/usr/bin/editor' ? '/usr/bin/editor' : 'vi');
60 $opt_c = $opt_v = $opt_l = $opt_L = $opt_h = $opt_w = $opt_u = $opt_R = 0;
62 $opt_r = $opt_d = $opt_q = $opt_a = $opt_n = $opt_k = $opt_m = '';
63 $opt_y = $opt_S = $opt_C = $opt_D = $opt_A = $opt_V = $opt_P = '';
67 while (my $a = shift @__) {
75 chdir $spooldir or die "$0: no $spooldir\n";
77 @stat = stat $spooldir or die "$0: cannot access $spooldir - $!\n";
78 warn "WARNING: $spooldir with owner=root !?\n" unless $stat[4];
79 if (abs_path($spooldir) ne abs_path("$FEXHOME/spool")) {
80 warn "WARNING: \$spooldir differs from $FEXHOME/spool !\n";
83 getopts('hcvlLwuMRE/q:r:d:a:n:k:m:y:S:C:A:V:D:P:') or usage(2);
89 my $id = shift or die "usage: $0 -/ admin-email-address auth-ID\n";
90 if ($admin !~ /.\@[\w.-]+\.[a-z]+$/) {
91 die "$0: $admin is not an email address\n";
94 my $aa = "$spooldir/$admin/@";
95 open $aa,'>',$aa or die "$0: cannot write $aa - $!\n";
97 close $aa or die "$0: cannot write $aa - $!\n";
98 my $fph = "$FEXLIB/fex.ph";
99 $_ = slurp($fph) or die "$0: cannot read $fph\n";
100 s/^\s*\$admin\s*=.*/\$admin = '$admin';/m or
101 $_ = "\$admin = '$admin';\n".$_;
102 open $fph,">$fph.new" or die "$0: cannot write $fph.new\n";
105 rename "$fph.new",$fph or die "$0: cannot rename $fph.new to $fph\n";
106 my $fid = "$ENV{HOME}/.fex/id";
108 rename $fid,$fid.'_save';
109 open $fid,'>',$fid or die "$0: cannot create $fid - $!\n";
110 if ($durl =~ m{(https?://.+?)/}) {
113 print {$fid} "$hostname\n";
115 print {$fid} "$admin\n";
116 print {$fid} "$id\n";
118 print "new admin account: $admin\n";
125 while (my ($hh,$vh) = each (%vhost)) {
126 if ($opt_V eq basename($vh) or $opt_V eq $hh) {
127 $ENV{HTTP_HOST} = $hh;
128 $ENV{VHOST} = "$hh:$vh";
129 $ENV{FEXLIB} = "$vh/lib";
130 die "$0: no $ENV{FEXLIB}/fex.ph\n" unless -f "$ENV{FEXLIB}/fex.ph";
132 die "$0: cannot re-exec\n";
135 die "$0: no virtual host $opt_V defined\n";
139 $fup =~ s:/[^/]+$:/fup:;
143 if ($opt_m eq 'exit') {
144 if (unlink '@MAINTENANCE') {
145 warn "$0: leaving maintenance mode\n";
147 warn "$0: no maintenance mode\n";
150 unlink '@MAINTENANCE';
151 symlink $opt_m,'@MAINTENANCE'
152 or die "$0: cannot write $spooldir/\@MAINTENANCE - $!";
153 warn "$0: entering maintenance mode\n";
158 # list files or resend notification e-mails
160 my ($mtime,$comment,$file,$keep);
164 foreach $file (glob("@ARGV")) {
165 $mtime = mtime("$file/data") or next;
166 $comment = slurp("$file/comment")||'';
167 next if $comment =~ /NOMAIL/;
168 $keep = readlink "$file/keep"
169 || readlink "$file/../../\@KEEP"
171 $keep = $keep - int((time-mtime("$file/data"))/60/60/24);
175 dkey => readlink "$file/dkey",
176 filename => filename($file),
179 warn => int(($mtime-time)/DS)+$keep,
180 autodelete => readlink "$file/autodelete" || $autodelete,
182 print "send notification e-mail for $file\n";
186 foreach $file (glob "*/*/*/data") {
187 next if $file =~ /^_?(anonymous|fexmail)/;
189 $comment = "$file/comment";
190 if (open $comment,$comment and <$comment> =~ /NOMAIL/) {
201 $log = "$logdir/fexsrv.log";
202 warn "$0: polling $log\n\n";
203 exec "$FEXHOME/bin/logwatch",$log;
204 die "$0: logwatch not found\n";
207 # list files and download URLs
210 chdir $spooldir or die "$0: $spooldir - $!\n";
211 foreach $file (glob "*/*/*") {
212 if (-s "$file/data" and
213 $dkey = readlink("$file/dkey") and
216 push @L,sprintf "%2\$s --> %1\$s : $durl/$dkey/%3\$s\n",split "/",$file;
223 # list files detailed
226 my ($comment,$file,$keep,$old,$size,$download);
229 foreach $file (glob "*/*/*/data") {
230 next if $file =~ m:(.+?)/: and -l $1;
231 $size = -s $file or next;
233 next if $filter and $file !~ /$filter/;
234 $comment = slurp("$file/comment")||'';
235 $dkey = readlink("$file/dkey")||'';
236 $keep = readlink("$file/keep")||$keep_default;
237 $old = int((time-mtime("$file/data"))/60/60/24);
238 $download = join(' & ',split("\n",(slurp("$file/download")||'')));
240 printf " comment: %s\n",decode_utf8($comment);
241 printf " size: %s\n",d3($size);
242 printf " sender ip: %s\n",readlink("$file/ip")||'';
243 printf " expire in: %s days\n",$keep-$old;
244 printf " upload speed: %s kB/s\n",readlink("$file/speed")||0;
245 printf " URL: $durl/$dkey/%3\$s\n",split "/",$file;
246 printf " download: %s\n",$download;
253 $idf = "$spooldir/$opt_d/\@";
254 die "$0: no such user $opt_d\n" unless -f $idf;
255 unlink $idf or die "$0: cannot remove $idf - $!\n";
256 foreach $rf (glob "$spooldir/$opt_d/\@*") { unlink $rf }
257 print "$opt_d deleted\n";
261 # set user restriction file
263 $user = shift or die "usage: $0 -R user\n";
264 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
265 die "$0: no user $user\n" unless -d "$spooldir/$user";
266 unless (@local_rdomains) {
267 die "$0: no \@local_rdomains in server config\n";
269 my $rf = "$spooldir/$user/\@ALLOWED_RECIPIENTS";
270 open $rf,'>',$rf or die "$0: cannot open $rf - $!";
271 print {$rf} "\@LOCAL_RDOMAINS\n";
273 print "$user restricted\n";
277 # edit user restriction file
279 if ($opt_r =~ /^r/i) { $opt_r = 'ALLOWED_RECIPIENTS' }
280 elsif ($opt_r =~ /^u/i) { $opt_r = 'UPLOAD_HOSTS' }
281 elsif ($opt_r =~ /^d/i) { $opt_r = 'DOWNLOAD_HOSTS' }
283 $user = shift or usage(2);
284 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
285 die "$0: no user $user\n" unless -d "$spooldir/$user";
286 my $rf = "$spooldir/$user/\@$opt_r";
288 open $rf,'>',$rf or die "$0: cannot open $rf - $!";
289 if ($opt_r eq 'ALLOWED_RECIPIENTS') {
291 # Restrict allowed recipients. Only listed addresses are allowed as recipients.
292 # Make this file COMPLETLY empty if you want to disable the restriction.
293 # An allowed recipient is an e-mail address. You can use * as wildcard.
295 # framstag\@rus.uni-stuttgart.de
298 } elsif ($opt_r eq 'UPLOAD_HOSTS') {
300 # Restrict allowed upload hosts.
301 # Only listed addresses are allowed as upload hosts.
302 # Make this file COMPLETLY empty if you want to disable the restriction.
303 # You can add single ip adresses or ip ranges.
306 # 10.0.10.0-10.0.10.255
308 } elsif ($opt_r eq 'DOWNLOAD_HOSTS') {
310 # Restrict allowed download hosts.
311 # Only listed addresses are allowed as download hosts.
312 # Make this file COMPLETLY empty if you want to disable the restriction.
313 # You can add single ip adresses or ip ranges.
316 # 10.0.10.0-10.0.10.255
319 die "$0: unknown option -r $opt_r\n";
324 unlink $rf if -s $rf<5;
330 exec $EDITOR,"$FEXLIB/fex.ph";
335 if ($opt_A =~ /(.+):(.+)/) {
339 die "usage: $0 -A alias:hostname\n".
340 "example: $0 -A flupp:fex.flupp.org\n";
343 $vhd = "/var/lib/fex/vhosts/$vhost";
344 mkdir $vhd or die "$0: cannot mkdir $vhd - $!\n";
345 mkdir "/etc/fex/vhosts/$vhost";
346 symlink "/etc/fex/vhosts/$vhost", "$vhd/lib";
347 mkdir "$spooldir/vhosts/$vhost";
348 symlink "$spooldir/vhosts/$vhost","$vhd/spool";
350 $vhd = "$FEXHOME/$vhost";
351 mkdir $vhd or die "$0: cannot mkdir $vhd - $!\n";
357 mkdir "$vhd/htdocs/locale";
358 $_ = slurp("$FEXLIB/fex.ph");
359 s/\$hostname\s*=.*/\$hostname = '$hhost';/ or s/^/\$hostname = '$hhost';\n/;
360 $fph = "$vhd/lib/fex.ph";
361 open $fph,">$fph" or die "$0: cannot write to $fph - $!\n";
364 system "cp $FEXLIB/fup.pl $vhd/lib/fup.pl";
365 foreach $i (qw'dop fex.pp fup.pl lf.pl reactivation.txt') {
366 # symlink "$FEXLIB/$i","$vhd/lib/$i";
367 symlink "../../lib/$i","$vhd/lib/$i";
370 index.html tools.html SEX.html robots.txt
371 logo.jpg small_logo.jpg action-fex-camel.gif favicon.ico
374 cpa("$docdir/$i","$vhd/htdocs");
376 symlink "$docdir/version","../../htdocs/version";
377 symlink "$docdir/download","../../htdocs/download";
378 cpa("$FEXHOME/locale",$vhd);
379 foreach $ld (glob "$vhd/locale/*") {
380 if (not -l $ld and -d "$ld/cgi-bin") {
381 $locale = basename($ld);
383 # symlink "../../../locale/$locale/cgi-bin","$ld/cgi-bin";
384 symlink "../../../locale/$locale/htdocs","$vhd/htdocs/locale/$locale";
385 unlink "$ld/lib/fex.ph";
386 symlink "../../../lib/fex.ph","$ld/lib/fex.ph";
387 symlink "../../../../locale/$locale/lib","$ld/lib/master";
388 foreach $f (qw'dop fex.pp lf.pl reactivation.txt') {
390 symlink "master/$f","$ld/lib/$f";
394 $fph = "$FEXLIB/fex.ph";
395 open $fph,">>$fph" or die "$0: cannot write to $fph = $!\n";
396 print {$fph} "\n\$vhost{'$hhost'} = '$vhd';\n";
398 print "You must now edit and configure $vhd/lib/fex.ph\n";
399 print "or execute: $0 -V $vhost -c\n";
405 print "config from $FEXLIB/fex.ph :\n";
406 print " spooldir = $spooldir\n";
407 print " logdir = $logdir\n";
408 print " docdir = $docdir\n";
409 print " durl = @durl\n";
410 print " admin = $admin\n";
411 print " mdomain = $mdomain\n";
412 print " mailmode = $mailmode\n";
413 print " autodelete = $autodelete\n";
414 print " keep_default = $keep_default\n";
415 printf " keep_max = %s\n",$keep_max||'unlimited';
416 printf " recipient_quota = %d GB\n",int($recipient_quota/1024);
417 printf " sender_quota = %d GB\n",int($sender_quota/1024);
418 while (($hh,$vh) = each %vhost) {
419 printf " virtual server %s : %s\n",basename($vh),$hh;
422 # foreach $ph (glob "$ENV{HOME}/*/lib/fex.ph") {
423 # $ENV{FEXLIB} = dirname($ph);
425 # system $0,'-v',$ph;
428 if ($m = readlink '@MAINTENANCE') {
429 print "server is in maintenance mode ($m)!\n" ;
434 # add user or show user config
436 if ($opt_u = shift @ARGV) {
438 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
440 $idf = "$spooldir/$user/@";
441 if (open $idf,$idf) {
442 chomp($ido = <$idf>||'');
446 die "$0: $user is not a FEX user\n" unless -f "$spooldir/$user/@";
447 showuser($user,$ido);
450 unless ($user =~ /\w@[\w.-]+\.[a-z]+$/) {
451 die "$0: $user is not a valid email-address!\n";
453 unless (-d "$spooldir/$user") {
454 mkdir "$spooldir/$user",0755
455 or die "$0: cannot mkdir $spooldir/$user - $!\n";
457 open F,">$idf" or die "$0: cannot write $idf - $!\n";
459 close F or die "$0: cannot write $idf - $!\n";
462 print "Users in $spooldir:\n";
463 foreach $user (glob "$spooldir/*/@") {
464 $user =~ s:.*/(.+)/@:$1:;
471 # set user autodelete default
474 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
475 $_ = shift @ARGV || '';
476 if (/^n/i) { $autodelete = 'no' }
477 elsif (/^y/i) { $autodelete = 'yes' }
478 elsif (/^d/i) { $autodelete = 'delay' }
480 die "usage: $0 -a user yes\n".
481 "usage: $0 -a user no\n".
482 "usage: $0 -a user delay\n".
483 "example: $0 -a framstag\@rus.uni-stuttgart.de no\n";
485 mkdir "$spooldir/$user",0755;
486 my $adf = "$spooldir/$user/\@AUTODELETE";
488 symlink $autodelete,$adf or die "$0: cannot create symlink $adf - $!\n";
492 # set user notification default
495 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
496 $_ = shift @ARGV || '';
497 if (/^n/i) { $notification = 'no' }
498 elsif (/^[sb]/i) { $notification = 'short' }
499 elsif (/^[fd]/i) { $notification = '' }
501 die "usage: $0 -n user no\n".
502 "usage: $0 -n user brief\n".
503 "usage: $0 -n user detailed\n".
504 "example: $0 -n framstag\@rus.uni-stuttgart.de brief\n";
506 mkdir "$spooldir/$user",0755;
507 my $ndf = "$spooldir/$user/\@NOTIFICATION";
510 symlink $notification,$ndf or die "$0: cannot create symlink $ndf - $!\n";
515 # set user keep default
518 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
519 my $keep = shift @ARGV || '';
520 if ($keep !~ /^\d+$/) {
521 die "usage: $0 -k user keep_days\n".
522 "example: $0 -k framstag\@rus.uni-stuttgart.de 30\n";
524 mkdir "$spooldir/$user",0755;
525 my $kf = "$spooldir/$user/\@KEEP";
527 symlink $keep,$kf or die "$0: cannot create symlink $kf - $!\n";
534 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
535 unless (-d "$spooldir/$user") {
536 die "$0: $user is not a regular FEX user\n";
544 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
545 unless (-f "$spooldir/$user/@") {
546 die "$0: $user is not a regular FEX user\n";
548 $_ = shift @ARGV || '';
550 open $user,">>$spooldir/$user/\@CAPTIVE";
552 print "$user is now captive\n";
554 unlink "$spooldir/$user/\@CAPTIVE";
555 print "$user is no more captive\n";
557 die "usage: $0 -C user yes\n".
558 "usage: $0 -C user no\n".
559 "example: $0 -C framstag\@rus.uni-stuttgart.de no\n";
564 # FEXYOURSELF = user can only fex to himself via web interface
567 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
568 unless (-f "$spooldir/$user/@") {
569 die "$0: $user is not a regular FEX user\n";
571 $_ = shift @ARGV || '';
573 open $user,">>$spooldir/$user/\@FEXYOURSELF";
575 print "$user has now \"fex yourself\" web default\n";
577 unlink "$spooldir/$user/\@FEXYOURSELF";
578 print "$user has no \"fex yourself\" web default\n";
580 die "usage: $0 -y user yes\n".
581 "usage: $0 -y user no\n".
582 "example: $0 -y framstag\@rus.uni-stuttgart.de no\n";
589 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
590 $_ = shift @ARGV || '';
592 open $user,">>$spooldir/$user/\@DISABLED";
594 print "$user is now disabled\n";
596 unlink "$spooldir/$user/\@DISABLED";
597 print "$user is now enabled\n";
599 die "usage: $0 -D user yes\n".
600 "usage: $0 -D user no\n".
601 "example: $0 -D framstag\@rus.uni-stuttgart.de no\n";
608 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
609 $_ = shift @ARGV || '';
611 open $user,">>$spooldir/$user/\@PERSISTENT";
613 print "$user is now persistent\n";
615 unlink "$spooldir/$user/\@PERSISTENT";
616 print "$user is no more persistent\n";
618 die "usage: $0 -P user yes\n".
619 "usage: $0 -P user no\n".
620 "example: $0 -P framstag\@rus.uni-stuttgart.de yes\n";
625 if ($opt_S eq 'fup') {
630 if ($opt_S eq 'fop') {
640 my ($keep,$autodelete,$notification);
642 $user .= '@'.$mdomain if $mdomain and $user !~ /@/;
644 print "[using config $FEXLIB/fex.ph]\n";
645 print "$fup?from=$user&id=$id\n";
646 printf "%s/%s\n",$fup,b64("from=$user&id=$id");
647 # printf "%s/%s\n",$fup,b64("from=$user&to=$user&id=$id&submit=.");
648 print "spool: $spooldir/$user/\n";
649 printf "fex yourself web default: %s\n",
650 -e "$spooldir/$user/\@FEXYOURSELF" ? 'yes' : 'no';
651 printf "persistent: %s\n",
652 -e "$spooldir/$user/\@PERSISTENT" ? 'yes' : 'no';
653 printf "captive: %s\n",
654 -e "$spooldir/$user/\@CAPTIVE" ? 'yes' : 'no';
655 printf "disabled: %s\n",
656 -e "$spooldir/$user/\@DISABLED" ? 'yes' : 'no';
657 printf "recipients restrictions: %s\n",
658 -e "$spooldir/$user/\@ALLOWED_RECIPIENTS" ? 'yes' : 'no';
659 printf "upload restrictions: %s\n",
660 -e "$spooldir/$user/\@UPLOAD_HOSTS" ? 'yes' : 'no';
661 printf "download restrictions: %s\n",
662 -e "$spooldir/$user/\@DOWNLOAD_HOSTS" ? 'yes' : 'no';
663 $autodelete = lc(readlink "$spooldir/$user/\@AUTODELETE" || $::autodelete);
664 print "autodelete default: $autodelete\n";
665 $notification = lc(readlink "$spooldir/$user/\@NOTIFICATION" || $::notification);
666 print "notification default: $notification\n";
667 $keep = readlink "$spooldir/$user/\@KEEP" || $keep_default;
668 print "keep default: $keep\n";
670 printf "account creation: %s\n",slurp("$spooldir/$user/.auto")||'manual';
673 # set or show disk quota
678 my $qf = "$spooldir/$user/\@QUOTA";
684 $rquota = $1 if /recipient.*?(\d+)/i;
685 $squota = $1 if /sender.*?(\d+)/i;
692 $rquota = $1 if /^r.*:(\d*)/i;
693 $squota = $1 if /^s.*:(\d*)/i;
695 open $qf,'>',$qf or die "$0: cannot write $qf - $!\n";
696 print {$qf} "recipient:$rquota\n" if $rquota =~ /\d/;
697 print {$qf} "sender:$squota\n" if $squota =~ /\d/;
701 $rquota = $recipient_quota if $rquota !~ /\d/;
702 $squota = $sender_quota if $squota !~ /\d/;
703 printf "recpient quota (used): %d (%d) MB\n",
704 check_recipient_quota($user) if $rquota;
705 printf "sender quota (used): %d (%d) MB\n",
706 check_sender_quota($user) if $squota;
711 my (%user,%domain,%du);
715 if (-t) { $log = "$logdir/fup.log" }
716 else { $log = '>&=STDIN' }
717 open $log,$log or die "$0: cannot open $log - $!\n";
720 if (/^([\d: -]+) (\[[\d_]+\] )?(\w\S*) .* (\d+)$/) {
723 $u .= '@'.$mdomain if $mdomain and $u !~ /@/;
727 $d =~ s/.*\.(.+\.\w+)/$1/;
734 foreach $u (sort {$user{$a} <=> $user{$b}} keys %user) {
735 printf "%s : %d\n",$u,$user{$u}/M;
737 print "========================================================\n";
738 foreach $d (sort {$domain{$a} <=> $domain{$b}} keys %domain) {
739 printf "%s : %d MB, %d user\n",$d,$domain{$d}/M,scalar(keys %{$du{$d}});
741 printf "Total: %d GB\n",$Z/M/1024;
750 my (%user,%domain,%du);
752 if (-t) { $log = "$logdir/fop.log" }
753 else { $log = '>&=STDIN' }
754 open $log,$log or die "$0: cannot open $log - $!\n";
757 if (/^([\d: -]+) (\[[\d_]+\] )?[\d.]+ (.+?)\/.* (\d+)\/\d+/) {
760 $u .= '@'.$mdomain if $mdomain and $u !~ /@/;
764 $d =~ s/.*\.(.+\.\w+)/$1/;
771 foreach $u (sort {$user{$a} <=> $user{$b}} keys %user) {
772 printf "%s : %d\n",$u,$user{$u}/M;
774 print "========================================================\n";
775 foreach $d (sort {$domain{$a} <=> $domain{$b}} keys %domain) {
776 printf "%s : %d MB, %d user\n",$d,$domain{$d}/M,scalar(keys %{$du{$d}});
778 printf "Total: %d GB\n",$Z/M/1024;
787 die "(cpa): $dd is not a directory" unless -d $dd;
788 system "rsync -a @_ $dd/" ;
794 return @s ? $s[9] : undef;
799 my $admin_id = slurp("$spooldir/$admin/@") or
800 die "$0: no admin account - you have to create it with:\n".
801 "$0 -/ $admin ".randstring(8)."\n";
805 my $fid = "$ENV{HOME}/.fex/id";
806 if (open $fid,$fid) {
808 chomp($_ = <$fid>||'');
810 warn "WARNING: user $admin not in $fid\n";
813 chomp($_ = <$fid>||'');
814 if ($_ ne $admin_id) {
815 warn "WARNING: $admin auth-ID mismatch in $fid\n";
820 warn "$0: moving $fid to ${fid}_save\n";
821 rename $fid,$fid.'_save';
826 open $fid,'>',$fid or die "$0: cannot create $fid - $!\n";
827 if ($durl =~ m{(https?://.+?)/}) {
830 print {$fid} "$hostname\n";
832 print {$fid} "$admin\n";
833 print {$fid} "$admin_id\n";
835 warn "$0: new $fid created\n";
842 while (s/(\d)(\d\d\d\b)/$1,$2/) {};
851 if ($durl =~ /:(\d+)/) { $port = ":$1" }
852 if ($durl =~ /^(https?)/) { $proto = $1 }
857 $0 -u # list full users
858 $0 -u user # show user config
859 $0 -u user auth-ID # create new user or set new auth-ID
860 $0 -/ admin auth-ID # set new admin and auth-ID
861 $0 -q user s:quota # set new disk quota (MB) for sender user
862 $0 -q user r:quota # set new disk quota (MB) for recipient user
863 $0 -R user # restrict user: only internal recipients allowed
864 $0 -rr user # edit user recipients restriction
865 $0 -ru user # edit user upload restriction
866 $0 -rd user # edit user download restriction
867 $0 -d user # delete user
868 $0 -D user [yn] # disable user (yes,no)
869 $0 -P user [yn] # make user persistent = no account expiration (yes,no)
870 $0 -a user [ynd] # set user autodelete default (yes,no,delay)
871 $0 -n user [dbn] # set user notification default (detailed,brief,no)
872 $0 -k user days # set user keep default in days
873 $0 -C user [yn] # set user captive (yes,no)
874 $0 -y user [yn] # set user "fex yourself" web default (yes,no)
875 $0 -S fup # file upload statistics
876 $0 -S fop # file download statistics
877 $0 -v # show server config
878 $0 -c # edit server config
879 $0 -w # watch fexsrv.log (continously)
880 $0 -l # list pending files with download URLs
881 $0 -L [filter] # list pending files in detail
882 $0 -M # list pending files with TO/FROM/FILE
883 $0 -M TO/FROM/FILE # resend notification email
884 $0 -m "reason" # enter maintenance mode (reason "exit" to leave)
885 $0 -A alias:hostname # add new virtual server
886 $0 -V virtualhost ... # operations on virtualhost (alias or hostname)
887 $0 -E # show usage examples
889 if (-x "$FEXHOME/cgi-bin/fac") {
890 print "See also web admin interface $proto://$hostname$port/fac\n";
899 $0 -u framstag\@rus.uni-stuttgart.de schwubbeldidu
901 set 10 GB sender quota for this user:
902 $0 -q framstag\@rus.uni-stuttgart.de s:10240
904 set file expiration to 30 days for this user:
905 $0 -k framstag\@rus.uni-stuttgart.de 30
907 disable account expiration for this user:
908 $0 -P framstag\@rus.uni-stuttgart.de y
910 list spooled files and resend notification email for this file:
912 $0 -M framstag\@rus.uni-stuttgart.de/hoppel\@flupp.org/jump.avi