summaryrefslogtreecommitdiffstats
path: root/pki/base/setup/pkihost
diff options
context:
space:
mode:
Diffstat (limited to 'pki/base/setup/pkihost')
-rwxr-xr-xpki/base/setup/pkihost157
1 files changed, 157 insertions, 0 deletions
diff --git a/pki/base/setup/pkihost b/pki/base/setup/pkihost
new file mode 100755
index 000000000..bdd5ff5c8
--- /dev/null
+++ b/pki/base/setup/pkihost
@@ -0,0 +1,157 @@
+#!/usr/bin/perl
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright (C) 2007 Red Hat, Inc.
+# All rights reserved.
+# --- END COPYRIGHT BLOCK ---
+#
+
+##############################################################
+# This script is used to display the fully qualified name
+# of this host.
+#
+# Sample Invocation:
+#
+# ./pkihost
+#
+##############################################################
+
+
+##############################################################
+# Perl Version
+##############################################################
+
+my $MINIMUM_PERL_VERSION = "5.006001";
+
+my $perl_version_error_message = "ERROR: Using Perl version $] ...\n"
+ . " Must use Perl version "
+ . "$MINIMUM_PERL_VERSION or later to "
+ . "run this script!\n";
+
+die "$perl_version_error_message" if $] < $MINIMUM_PERL_VERSION;
+
+
+##############################################################
+# Execution Check
+##############################################################
+
+# Check to insure that this script's original
+# invocation directory has not been deleted!
+my $cwd = `/bin/pwd`;
+chomp $cwd;
+if( "$cwd" eq "" ) {
+ print( STDERR "Cannot invoke '$0' from non-existent directory!\n" );
+ print( STDOUT "\n" );
+ exit 255;
+}
+
+
+##############################################################
+# Environment Variables
+##############################################################
+
+# untaint called subroutines
+if( ( $^O ne 'Windows_NT' ) && ( $^O ne 'MSWin32' ) ) {
+ $> = $<; # set effective user ID to real UID
+ $) = $(; # set effective group ID to real GID
+ $ENV{ 'PATH' } = '/bin:/usr/bin';
+ $ENV{ 'ENV' } = '' if $ENV{ 'ENV' } ne '';
+}
+
+
+##############################################################
+# Command-Line Variables
+##############################################################
+
+my $ARGS = ( $#ARGV + 1 );
+
+
+##############################################################
+# Shared Common Perl Data and Subroutines
+##############################################################
+
+# Compute "flavor" of Operating System
+my $pki_flavor = "";
+if( $^O eq "linux" ) {
+ $pki_flavor = `pkiflavor`;
+} elsif( $^O eq "solaris" ) {
+ $pki_flavor = `pkiflavor`;
+} else {
+ print( STDERR
+ "ERROR: Unsupported platform '$^O'!\n" );
+ print( STDOUT "\n" );
+ exit 255;
+}
+
+$pki_flavor =~ s/\s+$//g;
+
+# Establish path to scripts
+my $pki_subsystem_common_area = "/usr/share/$pki_flavor";
+my $common_path = "/usr/share/pki/scripts";
+
+if( ! -d "$common_path" ) {
+ print( STDERR
+ "ERROR: The path '$common_path' does not exist!\n"
+ . " Unable to load shared Common Perl Data "
+ . "and Subroutines!\n" );
+ print( STDOUT "\n" );
+ exit 255;
+}
+
+if( ! -e "$common_path/pkicommon" ) {
+ print( STDERR
+ "ERROR: The file '$common_path/pkicommon' does not exist!\n"
+ . " Unable to load shared Common Perl Data "
+ . "and Subroutines!\n" );
+ print( STDOUT "\n" );
+ exit 255;
+}
+
+eval( "use lib '" . $common_path . "'" );
+require( 'pkicommon' );
+
+# make -w happy by suppressing warnings of Global variables used only once
+my $suppress = "";
+$suppress = $hostname;
+
+
+##############################################################
+# Main Program
+##############################################################
+
+# no args
+# no return value
+sub main()
+{
+ my $host = "";
+
+ # obtain the fully-qualified domain name of this host
+ $host = get_FQDN( $hostname );
+
+ print( STDOUT "$host\n" );
+
+ return;
+}
+
+
+##############################################################
+# PKI Instance Creation
+##############################################################
+
+main();
+
+exit 0;
+