#!/usr/bin/perl -w
#
-# fixpaths - substitute makefile variables into text files
+# setup-openssh.pl - substitutes variables into text files and runs
+# ssh key gen programs
+#
+# adapted from 'fixpath', located in the openssh-3.0.2p1 package
+#
+
+$gpath = $ENV{GLOBUS_LOCATION};
+if (!defined($gpath))
+{
+ die "GLOBUS_LOCATION needs to be set before running this script"
+}
+
+#
+# i'm including this because other perl scripts in the gpt setup directories
+# do so
+#
+
+@INC = (@INC, "$gpath/lib/perl");
+
+require Grid::GPT::Setup;
+
+my $globusdir = $gpath;
+my $setupdir = "$globusdir/setup/globus";
+my $myname = "setup-openssh.pl";
+
+print "$myname: Configuring gsi-openssh package";
#
# Set up path prefixes for use in the path translations
#
-$prefix = "/home/cphillip/gsi-openssh/install";
-$exec_prefix = "$prefix";
-$bindir = "$exec_prefix/bin";
-$libexecdir = "$exec_prefix/libexec";
-$sysconfdir = "$prefix/etc";
+$prefix = ${globusdir};
+$exec_prefix = "${prefix}";
+$bindir = "${exec_prefix}/bin";
+$mandir = "${prefix}/man";
+$mansubdir = "man";
+$libexecdir = "${exec_prefix}/libexec";
+$sysconfdir = "${prefix}/etc";
$piddir = "/var/run";
$xauth_path = "/usr/bin/X11/xauth";
"/usr/bin:/bin:/usr/sbin:/sbin" => "/usr/bin:/bin:/usr/sbin:/sbin:${bindir}",
);
- print "dumping list of path translations..\n";
- for $s (keys(%def))
- {
- print "$s = " . $def{$s} . "\n";
- }
-
#
# Files on which to perform path translations
#
@files = (
- "ssh_config",
- "sshd_config",
- "moduli",
- "scp.1",
- "ssh-add.1",
- "ssh-agent.1",
- "ssh-keygen.1",
- "ssh-keyscan.1",
- "ssh.1",
- "sshd.8",
- "sftp-server.8",
- "sftp.1",
+ "${sysconfdir}/ssh_config",
+ "${sysconfdir}/sshd_config",
+ "${sysconfdir}/moduli",
+ "${mandir}/${mansubdir}1/scp.1",
+ "${mandir}/${mansubdir}1/ssh-add.1",
+ "${mandir}/${mansubdir}1/ssh-agent.1",
+ "${mandir}/${mansubdir}1/ssh-keygen.1",
+ "${mandir}/${mansubdir}1/ssh-keyscan.1",
+ "${mandir}/${mansubdir}1/ssh.1",
+ "${mandir}/${mansubdir}8/sshd.8",
+ "${mandir}/${mansubdir}8/sftp-server.8",
+ "${mandir}/${mansubdir}1/sftp.1",
);
- print "\ntranslating files..\n";
+ print "Translating strings in config/man files...\n";
for $f (@files)
{
$f =~ /(.*\/)*(.*)$/;
- $g = "$f.out";
+ $g = "$f.tmp";
- open(IN, "<$f") || die ("$0: input file $f missing!\n");
-
- if ( -e $g )
+ $result = system("mv $f $g");
+ if ($result != 0)
{
- print "$g already exists, skipping.\n";
+ die "Failed to copy $f to $g!\n";
}
- else
- {
- open(OUT, ">$g") || die ("$0: unable to open output file $g!\n");
- while (<IN>)
+ open(IN, "<$g") || die ("$0: input file $g missing!\n");
+ open(OUT, ">$f") || die ("$0: unable to open output file $f!\n");
+
+ while (<IN>)
+ {
+ for $s (keys(%def))
{
- for $s (keys(%def))
- {
- s#$s#$def{$s}#;
- } # for $s
- print OUT "$_";
- } # while <IN>
-
- close(OUT);
- }
+ s#$s#$def{$s}#;
+ } # for $s
+ print OUT "$_";
+ } # while <IN>
+ close(OUT);
close(IN);
+
+ $result = system("rm $g");
+ if ($result != 0)
+ {
+ die "Failed to remove $g\n";
+ }
} # for $f
return 0;
sub runkeygen
{
- print "\nkey gen routine starting..\n";
+ print "Generating ssh keys (if necessary)...\n";
if ( -e "${sysconfdir}/ssh_host_key" )
{
print "${sysconfdir}/ssh_host_key already exists, skipping.\n";
}
fixpaths();
-
runkeygen();
+
+my $metadata = new Grid::GPT::Setup(package_name => "gsi-openssh-setup");
+
+$metadata->finish();