+#
+# Just need a minimal action() subroutine for now..
+#
+
+sub action
+{
+ my ($command) = @_;
+
+ printf "$command\n";
+
+ my $result = system("$command 2>&1");
+
+ if (($result or $?) and $command !~ m!patch!)
+ {
+ die "ERROR: Unable to execute command: $!\n";
+ }
+}
+
+sub copy_setup_files
+{
+ if ( -e "${sysconfdir}/ssh_config" )
+ {
+ print "${sysconfdir}/ssh_config already exists, skipping.\n";
+ }
+ else
+ {
+ action("cp ${globusdir}/setup/globus/ssh_config ${sysconfdir}/ssh_config");
+ }
+
+ if ( -e "${sysconfdir}/sshd_config" )
+ {
+ print "${sysconfdir}/sshd_config already exists, skipping.\n";
+ }
+ else
+ {
+ action("cp ${globusdir}/setup/globus/sshd_config ${sysconfdir}/sshd_config");
+ }
+}
+
+sub runkeygen
+{
+ if ( ! -d "${sysconfdir}" )
+ {
+ print "Could not find ${sysconfdir} directory... creating\n";
+ mkdir($sysconfdir, 16877);
+ # 16877 should be 755, or drwxr-xr-x
+ }
+
+ print "Generating ssh keys (if necessary)...\n";
+ if ( -e "${sysconfdir}/ssh_host_key" )
+ {
+ print "${sysconfdir}/ssh_host_key already exists, skipping.\n";
+ }
+ else
+ {
+ # if $sysconfdir/ssh_host_key doesn't exist..
+ action("$bindir/ssh-keygen -t rsa1 -f $sysconfdir/ssh_host_key -N \"\"");
+ }
+
+ if ( -e "${sysconfdir}/ssh_host_dsa_key" )
+ {
+ print "${sysconfdir}/ssh_host_dsa_key already exists, skipping.\n";
+ }
+ else
+ {
+ # if $sysconfdir/ssh_host_dsa_key doesn't exist..
+ action("$bindir/ssh-keygen -t dsa -f $sysconfdir/ssh_host_dsa_key -N \"\"");
+ }
+
+ if ( -e "${sysconfdir}/ssh_host_rsa_key" )
+ {
+ print "${sysconfdir}/ssh_host_rsa_key already exists, skipping.\n";
+ }
+ else
+ {
+ # if $sysconfdir/ssh_host_rsa_key doesn't exist..
+ action("$bindir/ssh-keygen -t rsa -f $sysconfdir/ssh_host_rsa_key -N \"\"");
+ }
+
+ return 0;
+}
+