]> andersk Git - gssapi-openssh.git/blame - setup/setup-openssh.pl
Update the perl script to use the GLOBUS/GPT_LOCATION environment
[gssapi-openssh.git] / setup / setup-openssh.pl
CommitLineData
20d3226a 1#!/usr/bin/perl -w
2#
701aa556 3# setup-openssh.pl - substitutes variables into text files and runs
4# ssh key gen programs
5#
6# adapted from 'fixpath', located in the openssh-3.0.2p1 package
7#
20d3226a 8
ad71c979 9my $gpath = $ENV{GPT_LOCATION};
10if (!defined($gpath))
11{
12 $gpath = $ENV{GLOBUS_LCATION};
13}
14if (!defined($gpath))
15{
16 die "GPT_LOCATION or GLOBUS_LOCATION needs to be set before running this script"
17}
18
19#
20# i'm including this because other perl scripts in the gpt setup directories
21# do so
22#
23
24@INC = (@INC, "$gpath/lib/perl");
25
26my $globusdir = $gpath;
27my $setupdir = "$globusdir/setup/globus";
28my $myname = "setup-openssh.pl";
29
30print "$myname: Configuring gsi-openssh package\n";
31
20d3226a 32#
33# Set up path prefixes for use in the path translations
34#
35
ad71c979 36$prefix = $globusdir;
20d3226a 37$exec_prefix = "$prefix";
38$bindir = "$exec_prefix/bin";
39$libexecdir = "$exec_prefix/libexec";
40$sysconfdir = "$prefix/etc";
41$piddir = "/var/run";
42$xauth_path = "/usr/bin/X11/xauth";
43
44sub fixpaths
45{
46 #
47 # Set up path translations for the installation files
48 #
49
50 %def = (
51 "/etc/ssh_config" => "${sysconfdir}/ssh_config",
52 "/etc/ssh_known_hosts" => "${sysconfdir}/ssh_known_hosts",
53 "/etc/sshd_config" => "${sysconfdir}/sshd_config",
54 "/usr/libexec" => "${libexecdir}",
55 "/etc/shosts.equiv" => "${sysconfdir}/shosts.equiv",
56 "/etc/ssh_host_key" => "${sysconfdir}/ssh_host_key",
57 "/etc/ssh_host_dsa_key" => "${sysconfdir}/ssh_host_dsa_key",
58 "/etc/ssh_host_rsa_key" => "${sysconfdir}/ssh_host_rsa_key",
59 "/var/run/sshd.pid" => "${piddir}/sshd.pid",
60 "/etc/moduli" => "${sysconfdir}/moduli",
61 "/etc/sshrc" => "${sysconfdir}/sshrc",
62 "/usr/X11R6/bin/xauth" => "${xauth_path}",
63 "/usr/bin:/bin:/usr/sbin:/sbin" => "/usr/bin:/bin:/usr/sbin:/sbin:${bindir}",
64 );
65
20d3226a 66 #
67 # Files on which to perform path translations
68 #
69
70 @files = (
71 "ssh_config",
72 "sshd_config",
73 "moduli",
74 "scp.1",
75 "ssh-add.1",
76 "ssh-agent.1",
77 "ssh-keygen.1",
78 "ssh-keyscan.1",
79 "ssh.1",
80 "sshd.8",
81 "sftp-server.8",
82 "sftp.1",
83 );
84
701aa556 85 print "\nTranslating strings in config/man files..\n";
20d3226a 86 for $f (@files)
87 {
88 $f =~ /(.*\/)*(.*)$/;
89 $g = "$f.out";
90
91 open(IN, "<$f") || die ("$0: input file $f missing!\n");
92
93 if ( -e $g )
94 {
95 print "$g already exists, skipping.\n";
96 }
97 else
98 {
99 open(OUT, ">$g") || die ("$0: unable to open output file $g!\n");
100
101 while (<IN>)
102 {
103 for $s (keys(%def))
104 {
105 s#$s#$def{$s}#;
106 } # for $s
107 print OUT "$_";
108 } # while <IN>
109
110 close(OUT);
111 }
112
113 close(IN);
114 } # for $f
115
116 return 0;
117}
118
119sub runkeygen
120{
701aa556 121 print "\nGenerating ssh keys (if necessary)..\n";
20d3226a 122 if ( -e "${sysconfdir}/ssh_host_key" )
123 {
124 print "${sysconfdir}/ssh_host_key already exists, skipping.\n";
125 }
126 else
127 {
128 # if $sysconfdir/ssh_host_key doesn't exist..
129 system("$bindir/ssh-keygen -t rsa1 -f $sysconfdir/ssh_host_key -N \"\"");
130 }
131
132 if ( -e "${sysconfdir}/ssh_host_dsa_key" )
133 {
134 print "${sysconfdir}/ssh_host_dsa_key already exists, skipping.\n";
135 }
136 else
137 {
138 # if $sysconfdir/ssh_host_dsa_key doesn't exist..
139 system("$bindir/ssh-keygen -t dsa -f $sysconfdir/ssh_host_dsa_key -N \"\"");
140 }
141
142 if ( -e "${sysconfdir}/ssh_host_rsa_key" )
143 {
144 print "${sysconfdir}/ssh_host_rsa_key already exists, skipping.\n";
145 }
146 else
147 {
148 # if $sysconfdir/ssh_host_rsa_key doesn't exist..
149 system("$bindir/ssh-keygen -t rsa -f $sysconfdir/ssh_host_rsa_key -N \"\"");
150 }
151
152 return 0;
153}
154
155fixpaths();
20d3226a 156runkeygen();
ad71c979 157
158exit 0;
This page took 0.24413 seconds and 5 git commands to generate.