home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume30 / mserv-3.0 / part02 / chkconfig.pl next >
Encoding:
Perl Script  |  1992-06-19  |  8.4 KB  |  286 lines

  1. #!/usr/local/bin/perl
  2. # chkconfig.pl -- check mserv configuration
  3. # SCCS Status     : @(#)@ chkconfig    1.11
  4. # Author          : Johan Vromans
  5. # Created On      : Mon Apr 27 21:47:41 1992
  6. # Last Modified By: Johan Vromans
  7. # Last Modified On: Sat Jun  6 21:27:19 1992
  8. # Update Count    : 94
  9. # Status          : Development
  10.  
  11. # DISCLAIMER: This prograim aids in finding configuration values
  12. # and potential problems. No guarantees, however.
  13.  
  14. $my_name = "chkconfig";
  15. $my_version = "1.11";
  16. #
  17. ################ Common stuff ################
  18.  
  19. $libdir = $ENV{"MSERVLIB"} || "/usr/local/lib/mserv";
  20. unshift (@INC, $libdir);
  21. require "mserv_common.pl";
  22.  
  23. ################ Options handling ################
  24.  
  25. &options if @ARGV > 0 && $ARGV[0] =~ /^-+[^-]+/;
  26. @ARGV = ("-") unless @ARGV > 0;
  27. print ($my_package, " [", $my_name, " ", $my_version, "]\n");
  28.  
  29. ################ Main ################
  30.  
  31. print ("MSERVLIB = ", $ENV{"MSERVLIB"} || "(not set)", "\n");
  32. print ("Program library: ", $libdir, " ", &fstat($libdir,1,1), "\n");
  33. print ("\n");
  34.  
  35. if ( defined $mserv_owner && $mserv_owner ) {
  36.     if ( @u = getpwnam ($mserv_owner) ) {
  37.     print ("Server owner: ", $mserv_owner, ", uid = $u[2], gid = $u[3]",
  38.            ", \"", $u[6], "\"\n");
  39.     }
  40.     else {
  41.     print ("Server owner: ", $mserv_owner, " *** Unknown ***\n");
  42.     }
  43. }
  44. else {
  45.     die ("\$mserv_owner is not defined!\n");
  46. }
  47. if ( defined $mserv_bcc && $mserv_bcc ) {
  48.     if ( @u = getpwnam ($mserv_bcc) ) {
  49.     print ("Bcc user: ", $mserv_bcc, ", uid = $u[2], gid = $u[3]",
  50.            ", \"", $u[6], "\"\n");
  51.     }
  52.     else {
  53.     print ("Bcc user: ", $mserv_bcc, " *** Unknown ***\n");
  54.     }
  55. }
  56. print ("\n");
  57.  
  58. if ( $have_setruid ) {
  59.     print ("The 'listener' program will use the setruid system call\n");
  60.     print ("  It will change identity to compiled-in uid $u[2]\n")
  61.     if $use_uid;
  62.     print ("  (setenv will be used to set USER, LOGNAME and HOME)\n")
  63.     if $have_setenv;
  64.     if ( -x "$libdir/listener" ) {
  65.     @st = stat (_);
  66.     unless ( $st[4] == $u[2] && $st[2] & 0004000 == 0004000 ) {
  67.         print ("The 'listener' program is not installed correctly!\n",
  68.            "  It should be installed setuid $mserv_owner\n");
  69.     }
  70.     }
  71.     else {
  72.     print ("The 'listener' program is not yet installed.\n",
  73.            "  Do not forget to install it setuid $mserv_owner\n");
  74.     }
  75. }
  76. else {
  77.     print ("The 'listener' program will use 'su' to change identity\n");
  78.     if ( -x "$libdir/listener" ) {
  79.     @st = stat (_);
  80.     unless ( $st[4] == 0 && $st[2] & 0004000 == 0004000 ) {
  81.         print ("The 'listener' program is not installed correctly!\n",
  82.            "  It should be installed setuid root\n");
  83.     }
  84.     }
  85.     else {
  86.     print ("The 'listener' program is not yet installed\n",
  87.            "  Do not forget to install it setuid root\n");
  88.     }
  89. }
  90. print "\n";
  91.  
  92. $f = $sendmail;
  93. $f = $` if $f =~ / /;
  94. print ("Replies will be sent using \"$sendmail\" ", &fstat($f,0,1), "\n");
  95. print ("Preset mail headers:\n");
  96. print (defined $sender ? "  $sender\n" : "  *** sender not defined ***\n");
  97. print ("  ", join ("\n  ", @x_headers), "\n") if defined @x_headers;
  98. print ("\n");
  99.  
  100. print ("Transfer strategies:\n");
  101. if ( defined $chunkmail ) {
  102.     $f = $chunkmail;
  103.     $f = $` if $f =~ / /;
  104.     print ("  email: \"$chunkmail\" ", &fstat($f,0,1), "\n");
  105.     print ("         wait ", $mailer_delay, " seconds between chunks\n")
  106.     if defined $mailer_delay;
  107.     print ("         limits: ", $email_limits[1], "K (default), ",
  108.        $email_limits[0], "K (min), ", $email_limits[2], "K (max)\n");
  109. }
  110. if ( defined $uucp ) {
  111.     $f = $uucp;
  112.     $f = $` if $f =~ / /;
  113.     print ("  uucp : \"$uucp\" ", &fstat($f,0,1), "\n");
  114.     $f = $uuname;
  115.     $f = $` if $f =~ / /;
  116.     print ("         check host names using \"$uuname\" ", &fstat($f,0,1), "\n")
  117.     if $uuname ne "";
  118.     print ("         limits: ", $uucp_limits[1], "K (default), ",
  119.        $uucp_limits[0], "K (min), ", $uucp_limits[2], "K (max)\n");
  120. }
  121. print ("\n");
  122.  
  123. print ("Search strategies:");
  124. print (" File") if $dofilesearch;
  125. print (" Directory") if $dodirsearch;
  126. print (" Index") if $doindexsearch;
  127. print ("\n");
  128. print ("\n");
  129.  
  130. if ( ! ($dofilesearch || $dodirsearch || $doindexsearch) ) {
  131.     print ("*** No search strategy defined ***\n\n");
  132. }
  133.  
  134. print ("Archives:\n");
  135. foreach $lib ( @libdirs ) {
  136.     print ("  ", $lib, " ", &fstat($lib,1,1), "\n");
  137. }
  138. if ( defined $indexfile && defined $indexlib ) {
  139.     print ("Archive for Index:\n");
  140.     print ("  ", $indexlib, " ", &fstat($indexlib,1,1), "\n");
  141. }
  142. print ("\n");
  143.  
  144. if ( $doindexsearch && !( defined $indexfile ) ) {
  145.     print ("*** No value for `indexfile' ***\n\n");
  146. }
  147.  
  148. if ( $doindexsearch && defined $indexfile ) {
  149.     print ("Indexfiles:\n");
  150.     if ( $indexfile =~ m|^/| ) {
  151.     print ("  ", $indexfile, " ", &fstat($indexfile), "\n");
  152.     print ("  Archive for this index: ", $indexlib, "\n")
  153.         if defined $indexlib;
  154.     }
  155.     else {
  156.     foreach $lib ( @libdirs ) {
  157.         local ($indexfile) = $lib . "/" . $indexfile;
  158.         print ("  ", $indexfile, " ", &fstat($indexfile), "\n");
  159.     }
  160.     }
  161.     print ("Limit per index request: ", $maxindexlines, " lines.\n")
  162.     if $maxindexlines > 0;
  163.     print ("\n");
  164.     print ("Index tools:\n");
  165.     print ("  gfind      ", $gfind, " ", &fstat($gfind,0,1), "\n");
  166.     print ("  ixlookup   ", $ixlookup, " ", &fstat($ixlookup,0,1), "\n");
  167.     print ("  locatelib  ", $locatelib, " ", &fstat($locatelib,1,1), "\n");
  168.     print ("\n");
  169. }
  170.  
  171. print ("Server files:\n");
  172. print ("  queue      ", $queue, " ", &fstat($queue), "\n");
  173. print ("  logfile    ", $logfile, " ", &fstat($logfile), "\n");
  174. print ("  lockfile   ", $lockfile, " ", &fstat($lockfile), "\n");
  175. print ("  notes      ", $notesfile, " ", &fstat($notesfile), "\n");
  176. print ("  hints      ", $hintsfile, " ", &fstat($hintsfile), "\n");
  177. print ("\n");
  178.  
  179. # Locking
  180. if ( defined $lock_fcntl ) {
  181.     print ("Locking with fcntl(2).\n");
  182. }
  183. if ( defined $lock_flock ) {
  184.     print ("Locking with flock(2).\n");
  185. }
  186. if ( defined $lock_lockf ) {
  187.     print ("Locking with syscall(2)/lockf(2).\n");
  188. }
  189. if ( defined $lock_fcntl + defined $lock_flock + defined $lock_lockf > 1 ) {
  190.     print ("*** Select one lock method.\n");
  191. }
  192. if ( defined $lock_fcntl + defined $lock_flock + defined $lock_lockf == 0 ) {
  193.     print ("No locking selected. Proceed at your own risk\n");
  194. }
  195. else {
  196.     # Just a quick test to see if things fit.
  197.     local ($lf) = "/usr/tmp/fl$$";
  198.     open (LF, ">$lf");
  199.     eval { &locking (*LF, 0); };
  200.     print "$@" if "$@";
  201.     close (LF);
  202.     unlink ($lf);
  203.     print ("Use the 'testlock' program to verify the locking! (See INSTALL)\n");
  204. }
  205. print ("\n");
  206.  
  207. %enctab = ("B", "btoa", "U", "uuencode", "X", "xxencode", "D", "uue");
  208.  
  209. print ("Default encoding is ", $default_encoding, 
  210.        " (", $enctab{$default_encoding}, ")\n");
  211. print ("Encoders:\n");
  212. foreach $f ( "btoa", "uuencode", "uue", "xxencode" ) {
  213.     $exec = eval("\$$f");
  214.     printf ("  %-10s %s %s\n", $f, $exec, 
  215.         &fstat($exec,0,
  216.            $f eq "uuencode" || $f eq $enctab{$default_encoding}),
  217.         "\n");
  218. }
  219.  
  220. # print ("Tools:\n");
  221. print ("\n");
  222.  
  223. if ( defined $packing_limit ) {
  224.     print ("Support for packing is included.\n",
  225.        "  Packing limit = $packing_limit blocks.\n",
  226.        "  Dusk usage obtained using \"$du\" ", &fstat($du,0,1), "\n",
  227.        "  File list obtained using \"$find\" ", &fstat($find,0,1), "\n",
  228.        "  Methods:");
  229.     if ( defined $pdtar ) {
  230.     print (" tar ", &fstat($pdtar,0,1));
  231.     }
  232.     else {
  233.     print (" tar ", &fstat($tar,0,1));
  234.     }
  235.     print (" zip ", &fstat($zip,0,1));
  236.     print (" zoo ", &fstat($zoo,0,1));
  237.     print ("\n");
  238.     if ( defined $pdtar ) {
  239.     print ("  Compress/Tar using \"$pdtar\" ", &fstat($pdtar,0,1), "\n");
  240.     }
  241.     else {
  242.     print ("  Compress/Tar using \"$tar\" ", &fstat($tar,0,1), " and ",
  243.            "\"$compress\" ", &fstat($compress,0,1), "\n");
  244.     }
  245.     print ("\n");
  246. }
  247. else {
  248.     print ("Packing functionality not selected.\n\n");
  249. }
  250. print ("Working storage: $tmpdir ", &fstat($tmpdir,1,1), "\n\n");
  251. print ("The queue will ", $auto_runrequest ? "automatically" : "not",
  252.        " be run upon completion of process.\n\n");
  253.  
  254. ################ Subroutines ################
  255.  
  256. sub fstat {
  257.     local ($file, $dir, $mustexist) = @_;
  258.     return "[*** Not found ***]" if ! -e $file && $mustexist;
  259.     return "[Not found, but that's OK]" unless -e _;
  260.     return "[*** Not a directory ***]" if $dir && ! -d _;
  261.     "[OK]";
  262. }
  263.  
  264. sub options {
  265.     require "newgetopt.pl";
  266.     $opt_ident = $opt_help = 0;
  267.     if ( !&NGetOpt ("ident", "help")
  268.     || $opt_help
  269.     || (@ARGV > 0)) {
  270.     &usage;
  271.     }
  272. }
  273.  
  274. sub usage {
  275.     print STDERR <<EndOfUsage;
  276. $my_package [$my_name $my_version]
  277.  
  278. Usage: $my_name [-help] [-ident]
  279.  
  280. Options:
  281.     -help    this message
  282.     -ident    print identification
  283. EndOfUsage
  284.     exit (1);
  285. }
  286.