#!/usr/bin/ksh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # bos72L src/bos/usr/sbin/C2admin/chC2admin.sh 1.3.1.1 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 1998,2018 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)77 1.3.1.1 src/bos/usr/sbin/C2admin/chC2admin.sh, cmdsadm, bos72L, l2018_12A5 3/19/18 06:16:31 # # chC2admin # # Change the name of the C2 administrative host # # Usage: # chC2admin [ -a address ] hostname # umask 027 unset PATH export PATH=/usr/bin:/etc:/usr/sbin:/sbin:/usr/ucb # ignore signals to prevent inconsistent state trap "" INT HUP TERM QUIT EXIT isC2host -i 2>/dev/null case $? in 0): # 2. check if currently in C2 mode [[ ! -d /etc/data.shared ]] && { dspmsg C2.cat 3 "%s: This system was not configured to operate in C2 mode.\n" ${0##*/} >&2 exit 2 } ;; 1): # C2 installed but not initialized dspmsg C2.cat 3 "%s: This system was not configured to operate in C2 mode.\n" ${0##*/} >&2 exit 1 ;; 2): # C2 is not installed dspmsg C2.cat 2 "%s: This system was not installed using the C2 option.\n" ${0##*/} >&2 exit 1 ;; *): dspmsg C2.cat 6 "%s: An error occured while initializing the administrative host.\n" ${0##*/} >&2 exit 2 ;; esac while getopts a: var do case $var in a) address="$OPTARG";; *) dspmsg C2.cat 12 "Usage: chC2admin [ -a address ] hostname\n" >&2 exit 2 ;; esac done shift $(( $OPTIND - 1 )) [[ -z $1 ]] && { dspmsg C2.cat 12 "Usage: chC2admin [ -a address ] hostname\n" >&2 exit 2 } [[ $PWD = /etc/data.shared ]] && { dspmsg C2.cat 15 "%s: Cannot unmount %s. Ensure that it is not your current directory.\n" ${0##*/} /etc/data.shared >&2 exit 2 } dspmsg C2.cat 14 "%s: The system may be left in an inconsistent state if this this script is interrupted.\n" ${0##*/} hostname=$1 # verify the supplied hostname if ! host "$hostname" >/dev/null 2>&1 then if [[ -z $address ]] then dspmsg C2.cat 5 "%s: Administrative host \"%s\" is unknown.\n" ${0##*/} >&2 exit 2 else # add to /etc/hosts hostent -a $address -h $hostname || { dspmsg C2.cat 6 "%s: An error occured while initializing the administrative host.\n" ${0##*/} >&2 exit 2; } fi fi # update admin_host file echo "$hostname" > /etc/security/admin_host || { dspmsg C2.cat 6 "%s: An error occured while initializing the administrative host.\n" ${0##*/} >&2 exit 2; } # update local copy of hosts file umount /etc/data.shared || { dspmsg C2.cat 13 "%s: An error occurred changing the administrative host.\n" ${0##*/} >&2 exit 2 } hostent -a $address -h $hostname 2>/dev/null mount /etc/data.shared || { dspmsg C2.cat 13 "%s: An error occurred changing the administrative host.\n" ${0##*/} >&2 exit 2 } # update NFS mount stanzas chnfsmnt -f /etc/data.shared -d /etc/data.master -h $hostname || { dspmsg C2.cat 13 "%s: An error occurred changing the administrative host.\n" ${0##*/} >&2 exit 2 } dspmsg C2.cat 11 "%s: The system must be rebooted for this change to take effect.\n" ${0##*/} exit 0;