|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T d
Length: 14824 (0x39e8)
Types: TextFile
Names: »do_start_lm«
└─⟦1e97d88e5⟧ Bits:30000533 8mm tape, Rational 1000, RATIONAL ASIS (AIX) 110.2.4.15
└─⟦this⟧ »./releases/asis.110.2.4.15/install/do_start_lm«
#!/bin/sh
# @(#)do_start_lm $Revision: 1.9 $ $Date: 1994/01/17 17:45:02 $
# @(#)Copyright(c) 1993,1994 by Rational.
#
# MODULE SPECIFICATION
# Name:
# do_start_lm
#
# Subsystem:
# install
#
# Description:
# Start or re-start the license manager.
# You must be root to run this command.
#
#------------------------------------------------------------------------
LM_DAEMON=lmgrd
ps_opts=axw
ps_header=`ps $ps_opts | head -1`
this_host=${1:-local}
if [ $this_host = remote ]
then
command=start_lm
install_dir=`dirname $0`
cd $install_dir
. ./install_lib
fi
lm_vars=$install_dir/$command.vars
def_home=`dirname $install_dir`
check_and_set_arch
read_prod_desc
. $install_dir/.install_defaults
#------------------------------------------------------------------------
replace_lm_vars() {
#------------------------------------------------------------------------
#
# Replace var in the '.vars' file.
#
grep -v "^$1=" $lm_vars > /tmp/lm_vars.$$
cp /tmp/lm_vars.$$ $lm_vars
/bin/rm -f /tmp/lm_vars.$$
eval echo $1=\\\"\$$1\\\" >> $lm_vars
}
#------------------------------------------------------------------------
save_lm_vars() {
#------------------------------------------------------------------------
#
# Append vars if not in the '.vars' file.
#
for var in $*
do
if grep "^$var=" $lm_vars >/dev/null
then
:
else
eval echo $var=\\\"\$$var\\\" >> $lm_vars
fi
done
}
#------------------------------------------------------------------------
have_remote_access() {
#------------------------------------------------------------------------
#
# Check that we can access the invocation entry on remote servers.
# Return $TRUE if we can.
#
if [ "$SV_VERIFY_WITH_RSH" = no ]
then
return $FALSE
fi
if [ -z "`rsh $server ls $install_dir/$invoke_entry`" ]
then
fmt_mesg "Cannot start license server on $server.
The file '$install_dir/$invoke_entry' could not
be found. Is the 'install' directory network
accessible?"
return $FALSE
fi
return $TRUE
}
#------------------------------------------------------------------------
find_process() {
#------------------------------------------------------------------------
#
# Look for process by name. If found, return TRUE.
#
# Arg 1: Name of process to look for on local/remote machine.
#
ps $ps_opts | grep -v grep | grep "$1"
return $?
}
#------------------------------------------------------------------------
daemon_running() {
#------------------------------------------------------------------------
#
# Look for license manager daemon running on local machine.
# The variable 'server' must be defined for remote use.
# If found, return TRUE.
#
if find_process $LM_DAEMON >/dev/null
then
return $TRUE
fi
return $FALSE
}
#------------------------------------------------------------------------
show_daemon() {
#------------------------------------------------------------------------
#
# Display the license daemon and our daemon (rational), if running.
#
sleep 10
if find_process $LM_DAEMON
then
sleep 10
if find_process " rational "
then
return $TRUE
else
warning "The rational daemon has not started yet.
Wait a couple of minutes and check if it is running by doing
the command:"
echo " % ps $ps_opts | grep ' rational '"
return $FALSE
fi
else
warning "$LM_DAEMON was not started on $HOSTNAME"
return $FALSE
fi
}
#------------------------------------------------------------------------
restart_daemon() {
#------------------------------------------------------------------------
get_yn "Would you like to re-start the license manager daemon now?" yes
if [ "$result" = no ]
then
return $FALSE
fi
if [ -x $LMDOWN ]
then
echo
$LMDOWN -q
fi
if proc_line=`find_process $LM_DAEMON`
then
pid=`echo "$proc_line" | awk '{print $1}'`
kill $pid
fi
#if proc_line=`find_process $LM_DAEMON`
#then
# pid=`echo "$proc_line" | awk '{print $1}'`
# kill -9 $pid
#fi
echo
echo "Starting $LM_DAEMON daemon on $HOSTNAME"
$start_daemon >/dev/null
return $?
}
#------------------------------------------------------------------------
update_init_file() {
#------------------------------------------------------------------------
#
# Update entry in system initialization file, if necessary.
#
daemon_path=`grep "^DAEMON rational" $LM_LICENSE_FILE | awk '{print $3}'`
if grep $LM_LICENSE_FILE $init_file >/dev/null
then
if grep $daemon_path/$LM_DAEMON $init_file >/dev/null
then
if [ "$SYS_NAME" = AIX ]
then
return
elif daemon_running
then
return
else
need_to=start
return
fi
fi
fi
fmt_mesg "The file '$init_file' appears to be out of date with respect to
the invocation entry created from running get_license_info. You need
to update this file."
get_yn "Would you like to do this now?" yes
if [ "$result" = no ]
then
exit 0
fi
fmt_mesg "Saving $init_file as $init_file.old."
cp $init_file $init_file.old
case "$ARCH" in
rs6k )
# Delete old entry.
sed -e "/^$LM_DAEMON:/d" $init_file > /tmp/init_file.$$
need_to=restart
replace_lm_vars need_to
;;
sun4 )
# Delete old entry.
sed -e '/Run the license manager for Rational/,/^fi/d' \
$init_file > /tmp/init_file.$$
if daemon_running
then
need_to=restart
else
need_to=start
fi
replace_lm_vars need_to
;;
esac
# Append new entry.
cat $invoke_entry >> /tmp/init_file.$$
# Replace system init file with new one.
if cp /tmp/init_file.$$ $init_file
then
echo "The '$init_file' file has been updated."
else
fatal "The '$init_file' file could not be updated."
fi
}
#------------------------------------------------------------------------
add_to_init_file() {
#------------------------------------------------------------------------
#
# Add entry into system initialization file, if necessary.
#
fmt_mesg "You $need_should add the license manager invocation to
$init_file so that it will automatically start when
$HOSTNAME is started."
get_yn "Would you like to do this now?" yes
if [ "$result" = yes ]
then
if cat $invoke_entry >> $init_file
then
echo "The '$init_file' file has been updated."
need_to=start
replace_lm_vars need_to
else
fatal "The '$init_file' file could not be updated."
fi
elif [ "$need_should" = "need to" ]
then
fmt_mesg "To start the license manager daemon, you are required
to have an entry in the $init_file file."
exit 1
fi
}
#------------------------------------------------------------------------
# Main
#------------------------------------------------------------------------
require_root
#
# Source file to allow remote (rsh) use of this script.
#
if [ -s $lm_vars ]
then
. $lm_vars
else
touch $lm_vars
chmod 666 $lm_vars
fi
if [ "$this_host" = remote ]
then
echo
echo "$SEP"
echo "Running $command on $HOSTNAME"
echo "$SEP"
else
add_cleanup_file $lm_vars
fi
#
# Make sure that APEX_HOME or ROSE is setup.
#
case $feature in
apex )
base_product=Apex
base_var=APEX_HOME
if [ -n "$APEX_HOME" ]
then
phys_cur_home=`cpath $APEX_HOME`
if [ "$def_home" != "$phys_cur_home" ]
then
echo
echo "APEX_HOME ($APEX_HOME)"
echo "is not the same as the parent of the install directory"
echo "($def_home)"
echo "APEX_HOME will be set to $def_home."
get_yn "Do you want to continue?" yes
if [ "$result" = no ]
then
exit 1
fi
APEX_HOME=$def_home
fi
else
APEX_HOME=$def_home
fi
PROD_HOME=$APEX_HOME
LMDOWN=$APEX_HOME/$ARCH/cots/license/lmdown
save_lm_vars APEX_HOME PROD_HOME
;;
rose )
base_product=Rose
base_var=ROSE
if [ -z "$ROSE" ]
then
ROSE=`get_var INST_HOMEDIR`
fi
if [ -z "$ROSE" ]
then
fatal "ROSE must be defined. Have you run 'install' yet?"
fi
if [ ! -d "$ROSE" ]
then
fatal "$ROSE not found"
fi
PROD_HOME=$ROSE
LMDOWN=$ROSE/license/$ARCH/lmdown
save_lm_vars ROSE PROD_HOME
;;
* )
base_product=Apex
base_var=APEX_HOME
if [ -z "$APEX_HOME" ]
then
fatal APEX_HOME must be defined
fi
if [ ! -d $APEX_HOME ]
then
fatal "$APEX_HOME not found"
fi
PROD_HOME=$APEX_HOME
LMDOWN=$APEX_HOME/$ARCH/cots/license/lmdown
save_lm_vars APEX_HOME PROD_HOME
;;
esac
#
# Setup parameters for specific system installations:
# On AIX, use /etc/inittab and lmgrd.rsk6 file.
# On SunOS, use /etc/rc.local the lmgrd.sun4 file.
#
case "$ARCH" in
rs6k )
init_file=/etc/inittab
invoke_entry=lmgrd.rs6k
start_daemon="telinit q"
need_should="need to"
daemon="^$LM_DAEMON:"
;;
sun4 )
init_file=/etc/rc.local
invoke_entry=lmgrd.sun4
start_daemon="sh $invoke_entry"
need_should="should"
daemon="/$LM_DAEMON "
;;
* )
fatal "Cannot run $command on $SYS_NAME systems"
;;
esac
if [ -f $state_info ]
then
load_vars
LM_LICENSE_FILE=$SV_LIC_FILE_NAME
export LM_LICENSE_FILE
# Verify that the user has run get_license_info.
if [ ! -f "$LM_LICENSE_FILE" ]
then
fatal "There is no license.dat file for $LM_DAEMON.
It appears that you have not run get_license_info yet.
Please run get_license_info before $command."
fi
else
fatal "Cannot find $base_product licensing information. Is $base_var
set to the correct directory?
Have you run get_license_info and add_license_info yet?
$base_var=$PROD_HOME."
fi
#
# Verify that there are SERVER lines in the license file
# and that HOSTNAME is one of the servers.
#
if [ -z "$servers" ]
then
servers=`grep "^SERVER " $LM_LICENSE_FILE | awk '{print $2}'`
num_servers=`echo $servers | wc -w`
if [ $num_servers -eq 0 ]
then
fatal "There are no SERVER lines in the license file '$LM_LICENSE_FILE'"
fi
if echo $servers | grep $HOSTNAME >/dev/null
then
:
else
fatal "You must run the $command script from one of your license
servers: $servers"
fi
if [ $num_servers -gt 1 ]
then
if [ $SV_VERIFY_WITH_RSH = no ]
then
fmt_mesg "This script needs to use rsh to access remote license
server hosts to add to or update the system process
initialization file,
start license servers and verify its actions."
get_yn "Should this script use rsh?" $SV_VERIFY_WITH_RSH
SV_VERIFY_WITH_RSH=$result
if [ $SV_VERIFY_WITH_RSH = yes ]
then
save_vars >/dev/null
else
fmt_mesg "You will need to add or replace the $LM_DAEMON
invocation entry ($invoke_entry) in the $init_file files
on each of the remote license server machines.
You can login to each of the remote machines and run
this script."
fi
fi
fi
save_lm_vars servers num_servers
fi
#
# If, the license.dat file has more than one server listed,
# verify they are all of the same architecture type.
#
if [ -z "$CHECKED_ARCH" -a $num_servers -gt 1 ]
then
fmt_mesg "There are multiple servers listed in the license file.
The hardware architecture of each server must match $HOSTNAME's."
if [ $SV_VERIFY_WITH_RSH = no ]
then
fmt_mesg "Since remote command capability (rsh) was not chosen,
the $command script will assume that all of the
license servers listed are of the same architecture type."
else
fmt_mesg "These servers are now being checked:"
echo
grep "^SERVER " $LM_LICENSE_FILE | sed -e "s/^/ /g"
for server in $servers
do
if [ $server = "$HOSTNAME" ]
then
continue
fi
arch=`rsh $server uname -s`
arch=${arch:-UNKNOWN}
if [ "$arch" != "$SYS_NAME" ]
then
fatal "The architecture type of $server ($arch)
does not match the architecture type of $HOSTNAME
($SYS_NAME). Since the architecture of these servers
do not match, you may need to rerun the get_license_info
script and specify servers with matching hardware
architectures."
fi
done
fi
fi
CHECKED_ARCH=yes
save_lm_vars CHECKED_ARCH
#
# Run this command on remote servers, as needed.
#
if [ "$this_host" = local ]
then
for server in $servers
do
if [ "$server" != "$HOSTNAME" ]
then
if have_remote_access
then
rsh $server $install_dir/do_$command remote
fi
fi
done
fi
#
# Add or update entry in system initialization file, if necessary.
#
need_to=do_nothing # for now. Used to start/restart servers.
save_lm_vars need_to
if grep "$daemon" $init_file >/dev/null
then
update_init_file
else
add_to_init_file
fi
case $need_to in
start )
echo
echo "Starting $LM_DAEMON daemon on $HOSTNAME"
$start_daemon >/dev/null
show_daemon
exit $?
;;
restart )
if restart_daemon
then
show_daemon
exit $?
fi
;;
* )
echo
echo "The file '$init_file' appears to be up-to-date."
;;
esac
# End of do_start_lm