#!/usr/local/bin/perl
#
# Make_Config (c) 1997 Chris Church / aD! Data Systems
# v. 0.03
# psylark@netropolis.net
#-----------------------------------

################
# default values
################

$AMDIR = "/usr/local/etc/adbbs/mods";
$WDIR = "/usr/local/etc/adbbs/welcome";
$NDIR = "/usr/local/etc/adbbs/news";
$MDIR = "/usr/local/etc/adbbs/menu";
$MTOP = "/usr/local/etc/adbbs/menu/mtop";
$GBFILE = "/usr/local/etc/adbbs/goodbye.msg";
$FDIR = '/usr/multi/ftp/pub';
$IDIR = '/usr/multi/ftp/incoming';
$RNDIR = '/usr/local/etc/adbbs/mtop';
$PASSWDF = '/etc/passwd';
$sz = '/usr/bin/sz -b';
$sx = '/usr/bin/sx -b';
$rz = '/usr/bin/rz -b';
$rx = '/usr/bin/rx -b';
$tppath = "/usr/bin/tput";
$hostrt = "chao";
$hostend = "ad.org";
$showwel = 1;
$shownews = 1;
$showmail = 1;
$u_singk = 0;
$u_ktime = 0;
$kbsec = 120;
$sllogin = 1;
$skwel = 1;
$lib_file = '/usr/local/etc/adbbs/fildb.db';
$CF = '/usr/local/etc/adbbs/crunch.db';
$uisr = 0;
$shfsize = 1;
$shmmsg = 1;
$ansi = 1;
$rndmtp = 0;
$ugroup = 1;
$ufil = 1;
#######################
# end defaults
#######################

print("aD!BBS Make_Config (v) 0.04\n");
print("(c) 1997-1998 Chris Church\n");
print("psylark\@netropolis.net\n");
print("Initializing\n");

open(IF, "confs/prewel");
open(OF, "> /usr/local/etc/prewel");
while(<IF>) { 
	print(OF);
	}
close(IF); close(OF);

&full;


sub full {
 print("I will now prompt you for information about a few things\n");
 print("The information you enter will be used to create a file named\n");
 print("/tmp/adbbs.cf.mk ; You will need to copy this file over your\n");
 print("/usr/local/etc/adbbs.cf for any changes to take effect.\n");
 print("You may hit enter at any prompt to accept the default.\n");
 print("Do you wish to continue? [Y/n] -> ");
 chomp($ent = <>);
 if($ent =~ /n/i) {
	print("Oh well then!\n");
	exit;
	} 
 print("Welcome directory\n");
 print("This directory is where welcome.X files are stored\n");
 print("This directory MUST exist!\n");
 print("Default \[$WDIR\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $WDIR = $ent;
        }
 if(! -d $WDIR) {
	print("This directory does not exist!\n");
	print("Would you like me to make it for you? [Y/n] -> ");
	chomp($ent = <>);
 	if($ent !~ /n/i) {
		print("Making directory $WDIR\n");
		mkdir("$WDIR",0755) || warn("Unable to mkdir $WDIR -> $!\n");
 		}
	}
 print("News directory\n");
 print("This directory is where news.X files are stored\n");
 print("This directory MUST exist!\n");
 print("Default \[$NDIR\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $NDIR = $ent;
        }
 if(! -d $NDIR) {
        print("This directory does not exist!\n");
        print("Would you like me to make it for you? [Y/n] -> ");
        chomp($ent = <>);
        if($ent !~ /n/i) {
                print("Making directory $NDIR\n");
                mkdir("$NDIR",0755) || warn("Unable to mkdir $NDIR -> $!\n");
                }
        }
 print("Menu directory\n");
 print("This directory is where menu.X files are stored\n");
 print("This directory MUST exist!\n");
 print("Default \[$MDIR\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $MDIR = $ent;
        }
 if(! -d $MDIR) {
        print("This directory does not exist!\n");
        print("Would you like me to make it for you? [Y/n] -> ");
        chomp($ent = <>);
        if($ent !~ /n/i) {
                print("Making directory $MDIR\n");
                mkdir("$MDIR",0755) || warn("Unable to mkdir $MDIR -> $!\n");
                }
        }
 print("Menu Top\n");
 print("This is the file to be displayed above each menu\n");
 print("If it does not exist, it will not be displayed\n");
 print("See README File for other menu top options\n");
 print("Default \[$MTOP\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
	$MTOP = $ent;
	}
 print("Goodbye File\n");
 print("This is the file to be displayed when a user logs out\n");
 print("If it does not exist, it will not be displayed\n");
 print("Default \[$GBFILE\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $GBFILE = $ent;
        }
 print("File directory\n");
 print("This directory is where users may view/download files\n");
 print("This directory MUST exist!\n");
 print("Default \[$FDIR\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $FDIR = $ent;
        }
 if(! -d $FDIR) {
        print("This directory does not exist!\n");
        print("Would you like me to make it for you? [Y/n] -> ");
        chomp($ent = <>);
        if($ent !~ /n/i) {
                print("Making directory $FDIR\n");
                mkdir("$FDIR",0755) || warn("Unable to mkdir $FDIR -> $!\n");
                }
        }
 print("Upload directory\n");
 print("This directory is where users may put files\n");
 print("This directory MUST exist!\n");
 print("Default \[$IDIR\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $IDIR = $ent;
        }
 if(! -d $IDIR) {
        print("This directory does not exist!\n");
        print("Would you like me to make it for you? [Y/n] -> ");
        chomp($ent = <>);
        if($ent !~ /n/i) {
                print("Making directory $IDIR\n");
                mkdir("$IDIR",0755) || warn("Unable to mkdir $IDIR -> $!\n");
                }
        }
 print("sz\n");
 print("This is the path to your 'send zmodem' program\n");
 print("Default \[$sz\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $sz = $ent;
        }
 print("sx\n");
 print("This is the path to your 'send xmodem' program\n");
 print("Default \[$sx\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $sx = $ent;
        }
 print("rz\n");
 print("This is the path to your 'receive zmodem' program\n");
 print("Default \[$rz\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $rz = $ent;
        }
 print("rx\n");
 print("This is the path to your 'receive xmodem' program\n");
 print("Default \[$rx\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $rx = $ent;
        }
 print("tput\n");
 print("This is the path to tput \(screen manipulation program\)\n");
 print("This MUST Be correct\n");
 print("Default \[$tppath\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $tppath = $ent;
        }
 print("15\) Short hostname\n");
 print("This is the \(short\) hostname of your machine\n");
 print("Do NOT put your domain name!\n");
 print("Note: Include everything BUT your domain name, e.g.:\n");
 print("chao \[or if you were bbs.chao.aD.org, you'd put bbs.chao\]\n");
 print("Default \[$hostrt\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $hostrt = $ent;
        }
 print("16\) Domain Name\n");
 print("Enter your domain name\n");
 print("Default \[$hostend\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $hostend = $ent;
        }
 print("17\) file database file\n");
 print("Enter the file to store file database in\n");
 print("\[See documentation\]\n");
 print("Default \[$lib_file\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $lib_file = $ent;
        }
 print("18\) Crunch database file\n");
 print("Enter the file to store the crunch database in\n");
 print("\[See documentation\]\n");
 print("Default \[$CF\]\n");
 print("-> ");
 chomp($ent = <>);
 if($ent =~ /.+/) {
        $CF = $ent;
        }
 
 
 print("Answer the following questions with a 1 or a 0\n");
 print("\[1 for true\(yes\), 0 for false\(no\)\]\n");
 print("Show welcome screens? -> ");
 chomp($showwel = <>);
 print("Show news screens? -> ");
 chomp($shownews = <>);
 print("Show # of mail messages? -> ");
 chomp($showmail = <>);
 print("Use Single Key Entry? -> ");
 chomp($u_singk = <>);
 print("Show last login time? -> ");
 chomp($sllogin = <>);
 print("Show Skip Welcome Screen? -> ");
 chomp($skwel = <>);
 

 print("Ok, now that we've finished with all the questions,\n");
 print("let's go ahead and create the configuration file\n");
 print("There are many configuration options not listed by this program,\n");
 print("Please read the file README for more information on configuring your BBS\n");
 open(TF, "> /tmp/adbbs.cf.mk") || die("Unable to create file! -> $!\n");
 print(".");
 print(TF "
# adbbs.cf Created by Make_Config
# (c) 1995, 1996, 1997, 1998 Chris Church
# psylark\@netropolis.net
#------------------------------------------

\$WDIR = \"$WDIR\";
\$NDIR = \"$NDIR\";
\$MDIR = \"$MDIR\";
\$MTOP = \"$MTOP\";
\$GBFILE = \"$GBFILE\";
\$FDIR = \"$FDIR\";
\$IDIR = \"$IDIR\";
$RNDIR = \"\";
\$sz = \"$sz\";
\$sx = \"$sz\";
\$rz = \"$rz\";
\$rx = \"$rx\";
\$tppath = \"$tppath\";
\$hostrt = \"$hostrt\";
\$hostend = \"$hostend\";
\$showwel = $showwel;
\$shownews = $shownews;
\$showmail = $showmail;
\$u_singk = $u_singk;
\$u_ktime = $u_ktime;
\$kbsec = $kbsec;
\$sllogin = $sllogin;
\$skwel = $skwel;
\$lib_file = \"$lib_file\";
\$CF = \"$CF\";
\$uisr = $uisr;
\$shfsize = $shfsize;
\$shmmsg = $shmmsg;
\$ansi = $ansi;
\$rndmtp = $rndmtp;
\$ugroup = $ugroup;
\$ufil = $ufil;

1;\n");
 print("All done!\n");
 exit;
}


