# Copyright 2000, International Business Machines Corporation and others.
# All Rights Reserved.
# 
# This software has been released under the terms of the IBM Public
# License.  For details, see the LICENSE file in the top-level source
# directory or online at http://www.openafs.org/dl/license10.html

# An InstallGuide for the AFS modified Unix commands
#

sub AIXunix {
  &Copy("etc/inetd", "/usr/sbin/inetd.afs");
  &Copy("etc/ftpd",  "/usr/sbin/ftpd.afs");
  &Copy("etc/rlogind",  "/usr/sbin/rlogind.afs");
  &Symlink ("/usr/sbin/inetd.afs",   "/etc/inetd.afs");
  &Symlink ("/usr/sbin/ftpd.afs",    "/etc/ftpd.afs");
  &Symlink ("/usr/sbin/rlogind.afs", "/etc/rlogind.afs");

  &ErrorsAreFatal(1);
  &Patch::Verbose if ($InstallVerbose);
  &CreateDir("/usr/vice/bin");

  &Copy("bin/rcp", "/usr/vice/bin");
  &Chown (0,2,   "/usr/vice/bin/rcp");
  &Chmod (04755, "/usr/vice/bin/rcp");

  &Copy("bin/rsh", "/usr/vice/bin");
  &Chown (0,2,   "/usr/vice/bin/rsh");
  &Chmod (04755, "/usr/vice/bin/rsh");

  # Create the inetd.conf.afs file
  $InetdConfAfs = "/etc/inetd.conf.afs";
  open(INETD, ">$InetdConfAfs") || &ErrorMsg("Can't open file", $InetdConfAfs);
  print INETD <<"EOINETD";
ftp		stream tcp nowait root /etc/ftpd.afs	ftpd.afs
shell		stream tcp nowait root /etc/rshd	rshd
login		stream tcp nowait root /etc/rlogind.afs 	rlogind.afs
ta-rauth	stream tcp nowait root internal		ta-rauth
EOINETD
  
 # comment out the rshd line in inetd.conf
  $InetdConf = "/etc/inetd.conf";
  &CopyStat($InetdConf, $InetdConfAfs);
  &Patch::FileOpen($InetdConf);

  $Search1 = "^(ftp\\s+.+)";
  $Replace1 = '"#".$1';

  $Search2 = "^(shell\\s+.+)";
  $Replace2 = '"#".$1';

  $Search3 = "^(login\\s+.+)";
  $Replace3 = '"#".$1';

  if (!&Patch::Patch($InetdConf, [[1, "Substitution", $Search1, $Replace1],
				  [1, "Substitution", $Search2, $Replace2],
				  [1, "Substitution", $Search3, $Replace3]])) {
    &ErrorMsg("Did not succeed with patch", $InetdConf);
  }

  # Modify the /etc/services file
  &ReadInstallGuide("$InstallGuideDir/GENERIC/unix");
  &unix;
}

sub unix {
  goto &AIXunix;
}


