#
# Local configuration definitions that might change from host to host
#
# I've added comments to indicate the consequences of changing things.
# CAREFUL means that you can change something anytime, but to be
# particularly careful about side effects.  SAFE means that you can
# change it anytime you want.  UNSAFE means that if you change it
# after you've started a database, you'll screw things up.
#

    #
    # Uncomment the appropriate version, or add code to set 
    # the right options automatically.
    #
if ( -f "/bin/uname") {
    $uname = `/bin/uname`;

    $ultrix = ($uname =~ /ULTRIX/);
    $hpux = ($uname =~ /HP-UX/);
    $irix = ($uname =~ /IRIX/);

    $un2 = `/bin/uname -v`;
    $riscos = ($un2 =~ /UMIPS/ || $un2 =~ /RISCos/);
}

    #
    # Blast, gotta set these by hand!
    #
$svr4 = 0;
$svr4 = 1 if -f "/etc/vfstab" && -x "/sbin/mount" && -d "/usr/sbin";

die "error: fooey, you can't be running both svr4 and ultrix!\n" if $svr4 && $ultrix;
die "error: fooey, you can't be running both svr4 and ultrix!\n" if $svr4 && $hpux;

    #
    # Search for the name of the fstab file (or equivalent).
    #
$fstab_file_name = "/etc/checklist" if -f "/etc/checklist";
$fstab_file_name = "/etc/vfstab" if -f "/etc/vfstab";
$fstab_file_name = "/etc/fstab" if -f "/etc/fstab";

    #
    # This is a list of the file system types in fstab or checklist 
    # that represent local file systems.  check-backups uses this to 
    # detect file systems that aren't mentioned in /etc/backups.
    #
    # Its SAFE to add entries.  If you delete an entry, then
    # check-backups won't know that that's an entry to pay attention
    # to.  
@fs_types = ("4.2", "4.3", "hfs", "ufs", "ffs");

    #
    # Where to look for things...you might want to add other entries.
    # CAREFUL - I wouldn't remove anything from the list.
    #
@search_path = ("/usr/athena/bin", "/bsd43/bin", "/usr/local/bin",
		"/usr/ucb", "/bin", "/usr/bin",
		"/usr/etc", "/etc", "/usr/lib", "/usr/ucblib", "/usr/sbin",
		"/sbin", "/afs/athena.mit.edu/project/gnu/bin");

    #
    # simple routine for finding things.  Uses search_path, returns pathname
    # to the first occurance of $what that it can find.
    #
sub find {
    local($file, $dir, $pathname);

    foreach $file (@_) {
	foreach $dir (@search_path) {
	    $pathname = "$dir/$file";
	    return($pathname) if -x $pathname;
	}
    }

    return("");
}

$hostname_prog =	&find("hostname");

    #
    # You shouldn't need to change this.
    #
if ($hostname eq "") {
    chop($hostname = `$hostname_prog`);
    ($hostname) = split(/\./, $hostname);
}

    #
    # Whether to use the .chain files or not.  These are intended to 
    # detect cases where a full restore has been done on a file system,
    # or where a full dump failed and needs to be redone.  Unfortunately, 
    # its common for the .chain files to get screwed up in other ways
    # so I've found them to be more annoying than useful.
    #
    # SAFE to change when you want.
    #
$use_chain_files = 0;

    #
    # ... per-host list of what to backup...might be useful to change 
    # this in test configurations.  This is SAFE to change at any
    # time.
    #
$backup_file =		"/afs/sipb.mit.edu/service/backups/lib/backup.hosts";

    #
    # Program that the tape checker should invoke.  Should accept a
    # message on stdin and do something useful with it.  SAFE to
    # change. 
    #
$bitch_prog =		"/usr/athena/bin/zwrite -c sipb -i backups -m 'tapechange'";

    #
    # Set to 1 if the local version of GNU tar can deal with remote 
    # users as 'user@host:device', 0 otherwise.
    #
$gtar_does_remote_users = 1;

    #
    # set to 1 if you are using a version of GNU tar that supports the 
    # listed-incremental option (such as GNU tar 1.10).  SAFE to change.
    #
$gtar_listed_incrementals = 1;

    #
    # Where the tardates file is, and where the exclude file is.  
    # &gtar_exclude_hook is called just before GNU tar is run - you can
    # insert code to change $gtar_exclude in a dynamic way if you want.
    # These are SAFE to change at any time.
    #
$tardates =		"/etc/tardates";

$gtar_exclude =		"--exclude-from $db_dir/exclude";

sub gtar_exclude_hook {
    if (! -f "$db_dir/exclude") {
	$gtar_exclude = "";
    }
}

    #
    # If you want to pass extra arguments to gtar when you make a backup, 
    # add them here.
    #
    # --ignore-failed-reads keeps gtar from exiting with an error if 
    # it hits unreadable files.  This is new in gtar 1.11.
    #
$gtar_extra_args =	"--ignore-failed-read";

    #
    # Define this if you want to allow GNU tar to warn you when it 
    # needs a new tape.
    #
#$gtar_vol_prog =		"-F someprogram";

    #
    # Normally, the system will maintain several dumpdates files (one
    # for each chain, in each configuration that you have installed,
    # plus the default).  This allows you to have several backup systems
    # that won't interfere with each other.  It can be bothersome if you
    # want to be able to run backups as some non-root user, since that
    # user would have to have write access to /etc to rearrange the
    # dumpdates files.
    #
    # If you are only using one chain AND the config name in 
    # backup.config is "" AND you don't care whether dumps interfere
    # with the /etc/dumpdates files on the hosts, and
    # $only_one_dumpdates is set to 1, THEN the system will maintain
    # only one copy of /etc/dumpdates, and you should be able to run
    # dump as a non-root user.
    #
    # SAFE to change at any time, but think carefully about whether you
    # have other programs that run dump that might interfere with this
    # system (and visa versa).
    #
$only_one_dumpdates = 0;

    #
    # density and length settings to use with dump on this host.  Since
    # we don't support backups that span multiple tapes, this doesn't
    # have to be correct, just big enough that dump won't ask for a new
    # tape.  
    #
$dump_density = 54000;
$dump_length = 60000;

    #
    # Set to 1 if the local version of dump/rdump can deal with remote 
    # users as 'user@host:device', 0 otherwise.
    #
$dump_does_remote_users = 0;

    #
    # Some Ultrix users use the version of dump that comes with the
    # system ($ultrix_dump = 1), and some get a better version from 
    # gatekeeper.dec.com ($ultrix_dump = 0).  Set the value of
    # $ultrix_dump to 1 if you are using the stock dump that comes with
    # the Ultrix distribution. 
    #
$ultrix_dump = $ultrix;

    #
    # What status does dump return if the dump succeeds?  Set to 0
    # normally, but on Ultrix systems it returns 1.  Sigh.
    #
#if ($ultrix_dump) {
#    $dump_return_status = 256;		# ultrix
#} else {
    $dump_return_status = 0;		# normal
#}

    #
    # Extra options to supply to dump.  These are inserted into the 
    # key list and after the rest of the args.
    #
    # If this is an Ultrix host and you want to use tape drives on 
    # pre-2.0 Ultrix hosts or non Ultrix hosts, uncomment the 
    # appropriate entries.
    #
$dump_extra_keys = "";
$dump_extra_args = "";

if ($ultrix_dump) {
    $restore_extra_keys = "o";			# Ultrix
} else {
    $restore_extra_keys = "";
}
$restore_extra_args = "";

    #
    # Where the lock file for the /etc/dumpdates file should go.
    # Should be unique to each host, which is why its set to this
    # instead of being put in $db_dir.
    #
    # SAFE to change, though you shouldn't need to.
    #
$dump_lock =		"/tmp/dumpdates.$hostname";

    #
    # This backup system maintains several versions of the dumpdates file 
    # (one for each chain).  Usually it acts by making hard links named 
    # /etc/dumpdates that point at the appropriate dumpdates.chain* file.  
    # The alternative is to copy dumpdates.chain* to dumpdates and back 
    # again.  This is essential on some systems like Ultrix where the links
    # don't work right for some reason.
    #
if ($ultrix) {
    $dumpdates_by_link = 0;
} else {
    $dumpdates_by_link = 1;
}

    #
    # Parse a line from the fstab/checklist file and return the 
    # device, directory and type.  We coulda done this with a variables 
    # to select ' ' or ':' as the separator, but there's no guarantee
    # that the fields would be in the right order on all systems anyway.
    #
    # Uncomment the appropriate lines for your system.
    #
sub read_fstab_entry {
    local($line) = @_;
    local(@rest, $device, $directory, $type, $tmp);

    # discard comments
    ($line, @rest) = split(/#/, $line);

    if ($ultrix) {
	($device, $directory, $tmp, $tmp, $tmp, $type) = split(/:/, $line);
    } elsif ($svr4 || $fstab_file_name =~ m|/vfstab$|) {
	($tmp, $device, $directory, $type) = split(/[ \t]+/, $line);
    } else {
        ($device, $directory, $type) = split(' ', $line);
    }

    return($device, $directory, $type);
}

    #
    # Set this to 1 if you want to use the &deadman routine from
    # lib-deadman.perl, 0 if not. The routine depends on Perl's waitpid
    # working correctly, which isn't the case on all platforms.  
    #
$use_deadman_stuff = 0;

$use_deadman_stuff = 0 if $hostname eq "mad" || $hostname eq "iron";

#----------------------------------------------------------------------
# You shouldn't need to change much of anything down below.
#----------------------------------------------------------------------

    #
    # ... misc. programs...
    # You shouldn't need to change these in general.  You can replace
    # them with full path names instead of using &find() if you need
    # to. 
    #
$at_prog =		&find("at") 
  			  || print "warning: can't find 'at'.\n";
$cat_prog =		&find("cat") 
			  || print "warning: can't find 'cat'.\n";
$chgrp_prog =		&find("chgrp") 
			  || print "warning: can't find 'chgrp'.\n";
$chmod_prog =		&find("chmod") 
			  || print "warning: can't find 'chmod'.\n";
$cp_prog =		&find("cp") 
			  || print "warning: can't find 'cp'.\n";
$date_prog =		&find("date") 
			  || print "warning: can't find 'date'.\n";
$dd_prog =		&find("dd") 
			  || print "warning: can't find 'dd'.\n";
$egrep_prog =		&find("egrep") 
			  || print "warning: can't find 'egrep'.\n";
    #
    # sigh, dump and rdump aren't always interchangeable.  for simplicity, 
    # we'll use rdump when we deal with tapes, dump when we deal with the 
    # disk (even though dump would suffice for a local tape).
    #
$dump_prog =		&find("dump", "ufsdump") 
			  || print "warning: can't find 'dump'.\n";
$rdump_prog =		&find("rdump", "ufsdump") 
			  || print "warning: can't find 'rdump'.\n";
$dump_restore_prog =	&find("rrestore", "restore", "ufsrestore") 
			  || print "warning: can't find 'restore'.\n";
    #
    # Can be anything that will halt and reboot the system, or force /etc/rc 
    # to be run again.
    #
    # You should eliminate test for $hostname eq mad and saqqara.  I just
    # included it as an example, since we need to do something like this on 
    # some hosts, you might have to also.
    #
if ($riscos) {
    $fastboot_prog = &find("telinit") || print "Can't find the 'telinit' program.\n";
    $fastboot_prog = "$fastboot_prog 6";
} elsif ($hostname eq "saqqara" || $hostname eq "mad") {
    $fastboot_prog =	&find("reboot") 
			  || print "warning: can't find 'reboot'.\n";
} else {
    $fastboot_prog =	&find("fastboot", "reboot") 
	
			  || print "warning: can't find 'fastboot' or 'reboot'.\n";
}

    #
    # Command and args to halt the system
    #
$halt_program =		&find("halt");
$halt_arguments =	"";

if ($hpux) {
    $halt_program = "/etc/reboot";
    $halt_arguments = "-h";
}

    #
    # Can be anything that delivers local mail, if it accepts the message on 
    # stdin and takes a subject with a -s flag.  Use mailx (HP's name for 
    # Berkeley mail) if it exists, or mail and hope you get /usr/ucb/mail 
    # rather than /bin/mail. 
    #
$mail_prog =		&find("mailx", "mail") 
	
			  || print "warning: can't find 'mailx' or 'mail'.\n";
$ln_prog =		&find("ln") 
			  || print "warning: can't find 'ln'.\n";
$mkdir_prog =		&find("mkdir") 
			  || print "warning: can't find 'mkdir'.\n";
$mount_prog =		&find("mount") 
			  || print "warning: can't find 'mount'.\n";
$rm_prog =		&find("rm") 
			  || print "warning: can't find 'rm'.\n";
#$rsh_prog =            "$base_dir/bin/krsh";
#			   || print "warning: can't find 'ssh' or 'remsh' or 'rsh'.\n";
$rsh_prog =		&find("rsh", "ssh", "remsh") 
			  || print "warning: can't find 'ssh' or 'remsh' or 'rsh'.\n";
$sendmail_prog =	&find("sendmail") 
			  || print "warning: can't find 'sendmail'.\n";
    #
    # Has to support remote tapes, various GNU tar flags.
    # We only need this if we are using GNU tar.  Leave this
    # commented if you don't have GNU tar.
    #
if ($hostname ne "iron") {
    $gtar_prog =		&find("gtar") 
			  || print "warning: can't find 'gtar'.\n";
}

$tee_prog =		&find("tee") 
			  || print "warning: can't find 'tee'.\n";
$umount_prog = 		&find("umount", "unmount") 
	
			  || print "warning: can't find 'umount' or 'unmount'.\n";
$compress_prog =	&find("compress") 
			  || print "warning: can't find 'compress'.\n";
$zcat_prog =		&find("zcat") 
			  || print "warning: can't find 'zcat' program.\n";

    #
    # How to convert a device name into a raw device name...uncomment
    # a suitable routine, comment out the rest.  You might need to
    # change this to support hosts that don't use /dev/rsd* or
    # /dev/rsdk/* to name raw disk devices.
    #
sub cvt_raw {				# prepend r to device name...sun, 
    local($dev) = @_;			# others

    if (-d "/dev/rdsk") {		# /dev/dsk/* ==> /dev/rsdk/*, for HP, MIPS
        $dev =~ s,^/dev/dsk/,/dev/rdsk/,;
    } else {
	$dev =~ s,/([^/]+)$,/r$1,;
    }
    if ($riscos && ($dev eq "/dev/root" || $dev eq "/dev/usr")) {
	$dev =~ s,/dev/,/dev/r,;
    }

    return($dev);
}

    #
    # Should be in global.defs, but needed the host name.
    #
$at_lock =		"$db_dir/at.$hostname";

1;

