Merge branch 'master' of dbucklin/uucp into master

Added PR to provide options for server setup.
This commit is contained in:
praetor 2019-04-05 23:21:38 -04:00 committed by Gitea
commit 2588731e64
1 changed files with 41 additions and 10 deletions

View File

@ -3,14 +3,29 @@
use warnings;
use strict;
use Digest::MD5 qw(md5_hex);
my $myNode = $ARGV[0] || die("usage: ./bootstrap.pl node-id\n");
use Getopt::Std;
my $myNode = "";
my $passwdFile = "passwd";
my $callFile = "call";
my $confFile = "config";
my $sysFile = "sys";
my $portFile = "port";
my %options = ();
sub getNodes {
my $nodelist = "../nodelist";
open(my $data, '<', $nodelist) or die ("Cannot open nodelist");
if ($options{t}) {
print("Truncating existing files\n");
truncate($passwdFile,0);
truncate($callFile,0);
truncate($confFile,0);
truncate($sysFile,0);
truncate($portFile,0);
}
print("Generating files\n");
while (my $line = <$data>) {
chomp $line;
@ -48,7 +63,6 @@ sub generatePort {
protocol etyig
};
my $portFile = "port";
open(FH, '>>', $portFile);
print FH $template;
}
@ -76,8 +90,6 @@ sub generateSys {
port $currentNode
};
my $sysFile = "sys";
open(FH, '>>', $sysFile);
print FH $template;
}
@ -85,7 +97,6 @@ sub generateSys {
sub generateConfig {
my $nodeName = shift;
my $confFile = "config";
open(FH, '>>',$confFile);
my $nodeConfig = "nodename\t\t".$nodeName."\n";
@ -103,7 +114,6 @@ sub getKeys {
sub generateCall{
my $nodeName = shift;
my $callFile = "call";
my $password = $nodeName.$myNode;
my $callHash = md5_hex($password);
@ -116,7 +126,6 @@ sub generateCall{
sub generatePasswd {
my $nodeName = shift;
my $passwdFile = "passwd";
my $password = $myNode.$nodeName;
my $passwdHash = md5_hex($password);
@ -131,14 +140,36 @@ sub preCheck()
{
print("Updating git repo\n");
chdir("../");
system("git pull");
#system("git pull");
print("Installing authorized_keys\n");
rename("authorized_keys",".ssh/authorized_keys");
#rename("authorized_keys",".ssh/authorized_keys");
chdir("./utils");
print("Pre-flight checks done\n");
getNodes();
}
sub showHelp()
{
print("Usage: bootstrap.pl [OPTION...] node-id\n");
print("Generate uucp configuration files.\n\n");
print(" -t truncate files before appending config\n");
print(" -h display this help and exit\n");
}
getopts("ht", \%options);
if ($ARGV[0]) {
my $myNode=$ARGV[0];
} else {
showHelp();
exit;
}
if ($options{h}) {
showHelp();
exit;
}
preCheck();
print("\n\n");
print("This setup script has finished. Please move the generated configuration files as ROOT to /etc/uucp\n");