# 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
# For Sun systems running Solaris 5.x
#

sub unix {
  &Copy("etc/inetd",   "/usr/sbin/inetd.afs");
  &Copy("etc/ftpd",    "/usr/sbin/in.ftpd.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/inet/inetd.conf.afs";
  open(INETD, ">$InetdConfAfs") || &ErrorMsg("Can't open file", $InetdConfAfs);
  print INETD <<"EOINETD";
ftp		stream tcp nowait root /usr/sbin/in.ftpd.afs	in.ftpd.afs
shell		stream tcp nowait root /usr/sbin/in.rshd	in.rshd
ta-rauth	stream tcp nowait root internal			ta-rauth
EOINETD
  &Symlink("./inet/inetd.conf.afs", "/etc/inetd.conf.afs");

  # comment out the lines in inetd.conf
  $InetdConf = "/etc/inet/inetd.conf";
  &CopyStat($InetdConf, $InetdConfAfs);
  &Patch::FileOpen($InetdConf);

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

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

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

  # Modify the /etc/inet/services file
  # append the ta-rauth to the services file
  $Services = "/etc/inet/services";
  &Patch::FileOpen($Services);
  $ServicesAppend = "ta-rauth	601/tcp rauth";

  if (!&Patch::Patch($Services, [[0, "EOF", "", $ServicesAppend]])) {
    &ErrorMsg("Did not succeed with patch", $Services);
  }
}
