head	1.1;
branch	1.1.1;
access;
symbols
	openafs_debian_version_1_0-1:1.1.1.1
	openafs_upstream_version_1_0:1.1.1.1
	source-dist:1.1.1;
locks; strict;
comment	@# @;
expand	@o@;


1.1
date	2000.11.02.03.35.34;	author hartmans;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.02.03.35.34;	author hartmans;	state Exp;
branches;
next	;


desc
@@



1.1
log
@Initial revision
@
text
@#
# rc
#
# An InstallGuide for installing the initialization script
# For HP 9000 systems running HPUX 9.x
#

sub rc {
# Defaults
$rcfile = "/etc/rc";

# Add AFS kernel loader to RC file
&VPrint("Updating $rcfile file");
&ErrorsAreFatal(1);
&DisplaceFile("/etc/rc.afs");

# Append the generic RC file
&ReadInstallGuide("$InstallGuideDir/GENERIC/rc");
&Appendrc;

# Read in the current RC file
$Section = "rc";
$rc = open(RC, $rcfile);
&ErrorMsg("Could not read file", $rcfile) if (!$rc);
@@line = <RC>;
close(RC);

# Check if AFS is already referenced
if (grep(/\bAFS\b/, @@line) || grep(/\/usr\/vice\/etc/, @@line)) {
  &Print("AFS appears to already be in $rcfile");
  return;  };

# Find where function localrc() is. If it is not there, put it in after
# all of the leading comments
$localrc = -1;
$comments = 0;
foreach $n (0 ... $#line) {
  $comments = $n unless (@@line[$n] =~ /^#/ || $comments > 0);
  if (@@line[$n] =~ /^localrc\(\)/) {
    $localrc = $n;
    last; };  };

# Insert a localrc() function if one was not already there
if ($localrc == -1) {
  splice(@@line, $comments, 0, "localrc()\n", "{\n", "}\n", "\n");
  $localrc = $comments;
  &Print("Inserted function localrc() in $rcfile");
  &Print("This should be run after NFS is started");  };

# Skip past the function name and opening curly brace. Account for "{}"
until (@@line[$localrc] =~ /\{/ || $localrc > $#line) { $localrc ++;  };
if (@@line[$localrc] =~ /\}/) {
  @@line[$localrc] =~ s/\}//;
  splice(@@line, $localrc+1, 0, "}\n"); };
$localrc++;

# Insert a call to the AFS rc file
splice(@@line, $localrc, 0, 
  "\# Start AFS\n",
  "if [ -f /etc/rc.afs ]; then\n", 
  "  /bin/sh /etc/rc.afs\n",
  "fi\n");

# Rewrite the RC file
$rc = open(RC, "> $rcfile");
&ErrorMsg("Could not rewrite file" , $rcfile) if (!$rc);
foreach $line (@@line) {
  print RC $line;  };
close(RC);
}
@


1.1.1.1
log
@Initial Import. 
@
text
@@
