Скрипты и файлы для изучения

Файл /etc/rc2.d/S98cms_ndd. В случае, если на CMS два порта eth, нужно запретить маршрутизацию пакетов с одного порта на другой. У нас,во-первых, только один eth0, а во-вторых, опция включена.

ndd -set /dev/ip ip_forwarding 0
ndd -set /dev/ip ip_strict_dst_multihoming 1
ndd -set /dev/ip ip_forward_directed_broadcasts 0
ndd -set /dev/ip ip_forward_src_routed 0
ndd -set /dev/ip ip_respond_to_echo_broadcast 0
ndd -set /dev/ip ip_respond_to_timestamp_broadcast 0
ndd -set /dev/ip ip_respond_to_address_mask_broadcast 0
ndd -set /dev/ip ip_ignore_redirect 1
ndd -set /dev/ip ip_send_redirects 0
ndd -set /dev/ip ip_respond_to_timestamp 0
ndd -set /dev/tcp tcp_conn_req_max_q0 2048
ndd -set /dev/tcp tcp_conn_req_max_q 1024

Содержимое каталога /opt/informix/bin (почти всё — двоичные файлы)

(ucacms1)-(root)=# ls /opt/informix/bin
about_files    esqlvers             infoshp          onedpu         onspaces
about.html     filtersym.sh         infxmsg          oninit         onsrvapd
archecker      finderr              instterm         onload         onstat
blademgr       GenMacKey            ipload           onlog          ontape
cdr            genoncfg             libcairo-swt.so  onmode         onunload
check_version  glfiles              loadshp          onparams       plugins
chkenv         hdrmkpri.sh          msgfile          onpassword     rofferr
configuration  hdrmksec.sh          onaudit          onperf         setenv
crtcmap        ibmifmx_security.sh  onbar            onpladm        setisqlenv
db2dbgm.jar    idsd                 onbar_d          onpload        snmpdm
dbaccess       ifmxgcore            oncheck          onpsm          txbsapswd
dbexport       ifxbkpcloud.jar      onclean          onrestorept    unloadshp
dbimport       ifxclone             oncmsm           onsecurity     xtrace
dbinit.sh      ifxcollect           onconfig_diff    onshowaudit    xtree
dbload         ifxdeploy            ondblog          onshutdown.sh
dbschema       ifxdeployassist      ondwachk         onsmsync
drdaprint      ifxpipecat           onedcu           onsnmp

Содержимое каталога /cms/toolsbin

(ucacms1)-(root)=# ls /cms/toolsbin
age_pw                   chktunes   db_util    lib        parsecv         setSimLink  tsdatemod
age_pw_exclude_template  clint      diff_rtdb  link_perf  perfcmd.sh      showtime    ts_mod
age_pw_template          cmsu       fakepc     maintlock  PerfHistLogger  slem        ttlist
awk_rtdb                 cow_paste  getlog     mqtool     rebuild_dbtemp  swversion   tz_paste
chk_ext                  custfiles  GET.METS   netconfig  reset_tenants   tenRptMig

Скрипт /opt/Informix/bin/hdrnksec.sh

/opt/informix/bin/hdrmksec.sh
#!/bin/sh
#  Title      : hdrmksec.sh
#  Description: This script changes the type of the Data replication server
#               to Secondary. This script will soon be depricated. Need to
#               use command line steps after that.
 
cat << EOF
 
This script changes the type of the Data replication server to Secondary.
 
Steps to switch server types in an HDR pair:
 
  Instance A (currently Primary)          Instance B (currently Secondary)
  ------------------------------          --------------------------------
  1] onmode -ky                              (server should be up)
                                          2] hdrmkpri.sh <primary_server_name>
  3] hdrmksec.sh <secondary_server_name>
     (now a Secondary server)             4] oninit (now a Primary server)
EOF
 
# Check usage
if (test $# -gt 1) then
    echo " "
    echo "Usage: $0 [paired server name]"
    echo " "
    exit 1
fi
 
cat << EOF
 
WARNING: Please ensure the following before proceeding further:
 
           1] the paired  database server is OFFLINE, and
           2] the current database server has Data replication turned off.
 
         Not doing so, shall make the two database servers in the
         Data replication pair out-of-sync, and shall require
         re-establishing the pair.
 
Press return to continue...
EOF
read ignore_var
 
server_up=`onstat - | egrep -- "-- Up"`
if (test "${server_up}") then
    onstat_g_dri=`onstat -g dri | egrep -i "standard|primary|secondary"`
    dri_type=`echo ${onstat_g_dri}          | awk '{ print $1 }'`
    dri_state=`echo ${onstat_g_dri}         | awk '{ print $2 }'`
    dri_paired_server=`echo ${onstat_g_dri} | awk '{ print $3 }'`
if (test "${dri_type}" = "HDR" || test "${dri_type}" = "SDS" || test "${dri_type}" = "RSS") then
        dri_type=`echo ${onstat_g_dri}         | awk '{ print $2 }'`
        dri_state=`echo ${onstat_g_dri}        | awk '{ print $3 }'`
        dri_paired_server=`echo ${onstat_g_dri} | awk '{ print $4 }'`
fi
 
    echo " "
    echo " "
    echo "Replication Status: Type          : ${dri_type}"
    echo "                    State         : ${dri_state}"
    echo "                    Paired server : ${dri_paired_server}"
 
    if (test "${dri_type}" = "secondary") then
        echo " "
        echo "ERROR: Database server is already a Secondary server."
        echo "This script should be run on a Primary or Standard server only."
        echo " "
        exit 1
    fi
 
    if (test "${dri_state}" = "on") then
        echo " "
        echo "ERROR: Please ensure that the paired database server in the"
        echo "       Data replication pair is OFFLINE and data replication"
        echo "       is turned OFF, before proceeding further."
        echo " "
        exit 1
    fi
 
    echo " "
    echo "Shutting down the current database server via:"
    echo "      onmode -ky"
    onmode -ky
else
    echo " "
    echo "Current database server is down/off-line."
fi # End of if (test "${server_up}"...
 
 
echo " "
echo "Run \$INFORMIXDIR/bin/hdrmkpri.sh on the paired server."
echo "After the run OR if it has already been run, then"
echo "Press Return to continue ..."
read ignore_var
 
# Note: The paired server name is available only for Primary/Secondary type,
# and NOT for Standard type.
#
paired_server=""
if (test $# -eq 0) then
    if (test "${dri_paired_server}") then
        paired_server=${dri_paired_server}
    fi
else
    paired_server=$1
fi
 
if (test ! "${paired_server}") then
    echo " "
    echo "Enter the paired server name and press return:"
    read paired_server
fi
 
# A change from Primary to Standard type is NOT needed.
 
echo " "
# Do Physical recovery and bypass logical recovery from disk.
echo "Starting the database server via :"
echo "  oninit -PHY"
echo "  Note : -PHY is an undocumented option only used in this"
echo "         HDR failover script"
oninit -PHY
 
sleep 2
 
echo " "
echo "Changing to Secondary type via: (could take a couple of minutes)"
echo "  onmode -d secondary ${paired_server}"
 
# This is needed, as 'oninit -PHY' resets HDR type and state information,
# and new HDR type and state information changed via 'onmode -d secondary'
# do not make it to the disk, unless the HDR pair becomes operational.
# This is because the HDR state and type changes are stored in the reserved
# pages, which are updated via checkpoints and checkpoints can happen on a
# Secondary database server only through the Primary database server.
#
echo " "
echo "WARNING: The current database server should NOT be shutdown now."
echo "         If it is shutdown for any reason, then you need to re-run"
echo "         this script again from the start."
 
echo " "
echo "Start the paired (now Primary) database server, while the current"
echo "(now Secondary) database server tries to connect to it, to make the"
echo "Data replication pair operational."
echo " "

Расширенная информация о системе

swversion (/cms/toolsbin/swversion)

/cms/toolsbin/swversion
#!/bin/ksh
# NAME: swversion
# DESCRIPTION:  Shell to display CMS version, platform and OS information
# Arguments:  none
# Installed: /cms/toolsbin/swversion
# Usage: swversion
#
# MODIFICATIONS:
# DATE        WHO   DESCRIPTION
# 08/25/17    sms   CMS-1731  Inital development
# 01/08/18    dsb   CMS-1830  Change the name of cms_info to swversion
 
uname -a | grep -i linux > /dev/null
LINUX=$?
uname -a | grep -i sparc > /dev/null
SPARC=$?
uname -a | grep -i sunos > /dev/null
SUNOS=$?
uname -a | grep -i i86pc > /dev/null
SUNx86=$?
VMWARE=1
AMAZON=1
if [ $LINUX -eq 0 ];
then
        echo CMS is running on Linux
        dmidecode | grep -i vmware > /dev/null
        VMWARE=$?
        dmidecode | grep -i amazon > /dev/null
        AMAZON=$?
elif [ $SUNOS -eq 0 ]
then
        if [ $SPARC -eq 0 ]
        then
                echo CMS is running on Solaris SPARC
        elif [ $SUNx86 -eq 0 ]
        then
                echo CMS is running on Solaris x86
        fi
fi
if [ $VMWARE -eq 0 ];
then
        echo CMS is running on VMware
elif [ $AMAZON -eq 0 ]
then
        echo CMS is running on Amazon AWS
else
        echo CMS is running on physical hardware
fi
 
if [ $LINUX -eq 0 ];
then
        rpm -qi cms | grep "Summary"
        echo -n "Version     : "
        rpm -qa | grep -i "^cms-"
        rpm -qi cmsweb | grep "Summary"
        echo -n "Version     : "
        rpm -qa | grep -i "^cmsweb-"
elif [ $SUNOS -eq 0 ]
then
        pkginfo -l cms | grep "NAME"
        pkginfo -l cms | grep "VERSION"
        pkginfo -l cmsweb | grep "NAME"
        pkginfo -l cmsweb | grep "VERSION"
fi

Пример вывода:

# /cms/toolsbin/swversion
CMS is running on Linux
CMS is running on VMware
Summary     : Avaya(TM) Call Management System R18.0.2.0
Version     : cms-R18.0.2.0-ma.k.x86_64
Summary     : Avaya(TM) CMS Web Supervisor
Version     : cmsweb-R18.0.2.0-ma.k.x86_64

Оболочки

Какие оболочки shell есть в Linux (Avaya CMS). Вариант 2 — использовать команду смены оболочки chsh (change shell) с параметром -l ( --list-shells) :

# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/ksh
/bin/tcsh
/bin/csh
 
# chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/ksh
/bin/tcsh
/bin/csh

Пароли

/cms/toolsbin/age_pw

/cms/toolsbin/age_pw
#!/bin/ksh
# Script name: age_pw (LINUX Version)
# This program invokes password aging for all cms users. New users created
# will also have their passwords aged.
# To match age_pw.sh on the Sun, the user will be prompted for the password
# aging interval in weeks. It will be stored in days in PWAGE_FILE.
#
# MODIFICATIONS
# DATE     WHO           DESCRIPTION
#--------------------------------------------------------------------------
# 07/12    ctb           wi01033398: Initial Linux version.
# 10/12    ctb           wi01049926: Linux: passwd command gets error on perms
#                                    for /etc/login.defs
# **************************************************************************
#                                 age_pw
# **************************************************************************
 
OSNAME=`uname`
# Security precautions
#
if [ "$OSNAME" = "SunOS" ]; then
PATH=/usr/bin:/usr/sbin:/usr/5bin; export PATH
fi
IFS="
"; export IFS
DEFAULTIFS=$IFS
trap ":" 0 2 3 4 5 6 7 8 10 12 13 14 15
#
# End security precautions
 
# **************************************************************************
# Function:     check_for_quit()
# Description:  Verifies if the user types "q" to a menu prompt.  The
#               function examines the content's of the global ksh built-in
#               variable REPLY and take the appropriate action.
# Arguments:    None.
# Return Value: None.
# **************************************************************************
function check_for_quit
{
  if [ "$REPLY" = "q" ]
  then
    cleanup_exit 0
  else
    display "Invalid selection!\n"
  fi
} # End check_for_quit()
 
# **************************************************************************
# Function:     check_for_yorn()
# Description:  Verifies if the user types "y", "n" or "q" to a menu prompt.
#               The function requires that string PS3 has already been set
#               by the caller function.  The default is set to yes (y).
# Arguments:    $1 = name of variable which the valid response (y|n) is
#                    placed in.  The resulting value placed in $1 is always
#                    "y" or "n".
# Return Value: None.
# Note:         Here's an example showing how to use this function:
#               check_for_yorn RESPONSE
#               if [ "$RESPONSE" = "y" ]; then
#                 print "the answer is yes"
#               else
#                 print "the answer is no"
#               fi
# **************************************************************************
function check_for_yorn
{
  typeset L_VARNAME=$1
 
  while true
  do
    display -n "$PS3 (default y) "
    read REPLY
    test -z "$REPLY" && REPLY=y
    case "$REPLY" in
      n|y) break;;
      *  ) check_for_quit;;
    esac
  done
  eval "${L_VARNAME}=\"${REPLY}\""
} # End check_for_yorn()
 
# **************************************************************************
# Function:     check_for_123()
# Description:  The function requires that string PS3 has already been set
#               by the caller function.  The default is set to 1.
# Arguments:    $1 = name of variable which the valid response (y|n) is
#                    placed in.  The resulting value placed in $1 is always
#                    "y" or "n".
# Return Value: None.
# Note:         Here's an example showing how to use this function:
#               check_for_123 RESPONSE
#               case "$RESPONSE" in
#                  1) print "You chose 1" ;;
#                  2) print "You chose 2" ;;
#                  3) print "You chose 3" ;;
#               esac
# **************************************************************************
 
function check_for_123
{
  typeset L_VARNAME=$1
 
  while true
  do
    display -n "$PS3 (default 1) "
    read REPLY
    test -z "$REPLY" && REPLY=1
    case "$REPLY" in
      1|2|3) break;;
      *  ) check_for_quit;;
    esac
  done
  eval "${L_VARNAME}=\"${REPLY}\""
} # End check_for_123()
 
# **************************************************************************
# Function:     check_range()
# Description:  The function requires that string PS3 has already been set
#               by the caller function.  The default is set to 1.
# Arguments:    $1 = name of variable which the valid response (y|n) is
#                    placed in.  The resulting value placed in $1 is always
#                    "y" or "n".
# Return Value: None.
# Note:         Here's an example showing how to use this function:
#               check_range RESPONSE
#               case "$RESPONSE" in
#                  1) print "You chose 1" ;;
#                  2) print "You chose 2" ;;
#                  3) print "You chose 3" ;;
#                    ...
#                  52) print "You chose 52" ;;
#               esac
# **************************************************************************
function check_range
{
  typeset L_VARNAME=$1
  while true
  do
    display -n "$PS3 (default $DEF_WEEKS) "
    read REPLY
    test -z "$REPLY" && REPLY=$DEF_WEEKS
    case "$REPLY" in
      1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|\
     21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40| \
     41|42|43|44|45|46|47|48|49|50|51|52) break;;
      *  ) check_for_quit;;
    esac
  done
  eval "${L_VARNAME}=\"${REPLY}\""
} # End check_range()
 
# **************************************************************************
# Function:     display()
# Description:  Displays messages to screen
# Arguments:    $1 = message to be displayed.
# Return Value: None.
# **************************************************************************
function display
{
  print "$@"
} # End display()
 
# **************************************************************************
# Function:     display_and_log_message()
# Description:  Log a message to LOGFILE and to the screen.
# Arguments:    $1 = message to be logged.
# Return Value: None.
# **************************************************************************
function display_and_log_message
{
  printf "$1\n" | tee -a $LOGFILE
} # End display_and_log_message()
 
# **************************************************************************
# Function:     log_message()
# Description:  Log a message and its date only to LOGFILE
# Arguments:    $1 = message to be logged.
# Return Value: None.
# **************************************************************************
function log_message
{
  printf "$1 on `date`\n" >> $LOGFILE
} # End log_message()
 
# **************************************************************************
# Function:     get_aging_interval()
# Description:  Print out the aging interval if there is one. For what
#               could be an inappropriate action, issue a warning.
# Arguments:    1, 2 or 3
# Return Value: The current PW aging interval (0 if not turned on)
#               If the user appears to be doing an inappropriate action
#               a warning is issued.
# **************************************************************************
function get_aging_interval
{
 if [ "$OSNAME" = "SunOS" ]; then
    CUR_VALUE="`grep MAXWEEKS $PWAGE_FILE | cut -f 2 -d '='`"
 else
    CUR_VALUE=`egrep ^PASS_MAX_DAYS $PWAGE_FILE | awk '{print $2}'`
 fi
 
 if [ "$CUR_VALUE" = "" ] || [ "$CUR_VALUE" = "99999" ]
 then
   if [ $1 = 2 ]
   #Aging is already off, warn if user trying to re-turn it off
   then
     display "\n***WARNING, it appears that password aging is already off."
     display "   Enter q below if you wish to quit.\n"
   elif [ $1 = 3 ]
   then
     display "\n***WARNING, it appears that password aging is not turned on."
     display "   To turn it on enter the aging interval or q to quit.\n"
   fi
   return 0 && continue
 else
   if [ $1 = 1 ]
   then
     #Aging is already on, warn if user and give current interval
     display "\n***WARNING, it appears that password aging is already on"
     if [ "$OSNAME" = "SunOS" ]; then
        display "   and aging at the rate of $CUR_VALUE week(s)."
     else
        CUR_WEEKS=`expr $CUR_VALUE \/ 7`
        display "   and aging at the rate of $CUR_WEEKS week(s)."
     fi
     display "   To change, enter an interval or q to quit.\n"
   elif [ $1 = 3 ]
   then
     if [ "$OSNAME" = "SunOS" ]; then
        display "Passwords are currently expiring every $CUR_VALUE week(s)."
     else
        CUR_WEEKS=`expr $CUR_VALUE \/ 7`
        display "Passwords are currently expiring every $CUR_WEEKS week(s)."
     fi
   fi
 fi
 if [ "$OSNAME" = "SunOS" ]; then
    return $CUR_VALUE
 else
    return $CUR_WEEKS
 fi
} # End get_aging_interval
 
# **************************************************************************
# Function: check_lock()
# Description:  Checks to see if LOCKFILE exists; if so see if age_pw
#               process exists. If so, exit with message.
# Arguments:    None.
# Return Value: None.
# **************************************************************************
function check_lock
{
  # Verify if the age_pw lock file exists, if so warn user then exit.
  if [ -r $LOCKFILE ]; then
    PS="`ps -ef| grep age_pw | grep -v grep | grep -v $$`"
    if [ "$PS" != "" ]; then
      display "** WARNING:"
      display "** Only one user may run age_pw at one time."
      display "** If you are certain nobody else is running the command,"
      display "** please run \" rm $LOCKFILE\"."
      cleanup_exit 0
    fi
  else
    touch $LOCKFILE
  fi
} # end check_lock ()
 
# **************************************************************************
# Function: modify_policy_file()
# Description:  Modifies ${PWAGE_FILE}, the Solaris or Linux file used to set up
#               password aging when new users are created.
# Arguments:    One: number of MAXWEEKS to use; if "" is argument,
#               password aging is turned off. (WARNWEEKS is invalid if
#               aging is turned off.)
# Return Value: None.
# **************************************************************************
function modify_policy_file
{
  # set up password policy file (used when new users are created)
  printf "Modifying $PWAGE_FILE policy file...\n" >> $LOGFILE
  if [ "$OSNAME" = "SunOS" ]; then
     egrep -v "MAXWEEKS|WARNWEEKS" $PWAGE_FILE > $TMPFILE
     echo "MAXWEEKS=$1" >> $TMPFILE
     echo "WARNWEEKS=1" >> $TMPFILE
     chmod 644 $PWAGE_FILE
     mv $TMPFILE $PWAGE_FILE
     chmod 444 $PWAGE_FILE
  else
     if [ "$1" = "" ]; then
        DAYS=99999
     else
        DAYS=`expr $1 \* 7`
     fi
     egrep -v "Password aging controls modified|^PASS_MAX_DAYS|^PASS_WARN_AGE" \
                $PWAGE_FILE > $TMPFILE
     printf "# Password aging controls modified `date`\n" >> $TMPFILE
     printf "PASS_MAX_DAYS      $DAYS\n" >> $TMPFILE
     printf "PASS_WARN_AGE      7\n" >> $TMPFILE
     chmod 644 $PWAGE_FILE
     cp $TMPFILE $PWAGE_FILE
  fi
} # End modify_policy_file ()
 
# **************************************************************************
# Function: age_existing_users()
# Description:  For existing users, users are aged at the number of
#               weeks specified in first argument, excluding users in
#               ${EXCLUDED_USERS}. Or aging is turned off for all
#               cms users (${EXCLUDED_USERS is irrelevant in this case).
# Arguments:    One: number of MAXWEEKS to use; if value is -1, then
#               password aging will be turned off.
# Return Value: None.
# **************************************************************************
function age_existing_users
{
# create a list of cms users
cat ${ETCPASSWD} | grep '/usr/bin/cms' | cut -d":" -f1 > $TMPFILE
 
if [ $1 != "-1" ]
then
  printf "Changing password aging for cms users...excluding:\n" >> $LOGFILE
  for i in `cat $EXCLUDED_USERS`
  do
    # See if user to exclude exists in /etc/passwd and is a cms user
    grep "^${i}" /etc/passwd | grep '/usr/bin/cms' > /dev/null 2>&1
    if [ $? = 0 ]
    then
      printf "${i}\n" >> $LOGFILE
    fi
  done
  MAXDAYS=`expr $1 \* 7`
  for user in `cat $TMPFILE | egrep -v -f ${EXCLUDED_USERS}`
  do
    if [ "$OSNAME" = "SunOS" ]; then
       passwd -x ${MAXDAYS} -w ${WARNDAYS} $user || \
        display_and_log_message "ERROR: 'passwd' command generated error for user $user--call Services"
    else
       chage -m 0 -M ${MAXDAYS} $user || \
        display_and_log_message "ERROR: 'chage' command generated error for user $user--call Services"
       # This outputs info similar to Solaris (passwd -x)
       printf "password information changed for user $user\n"
    fi
  done
#  log_message "Turning on or changing password aging for users:"
else
  for user in `cat $TMPFILE`
  do
    if [ "$OSNAME" = "SunOS" ]; then
       passwd -x -1 $user || \
        display_and_log_message "ERROR: 'passwd' command generated error for user $user--call Services"
    else
       chage -m 0 -M 99999 $user || \
        display_and_log_message "ERROR: 'chage' command generated error for user $user--call Services"
       # This outputs info similar to Solaris (passwd -x)
       printf "password information changed for user $user\n"
    fi
  done
#  log_message "Turning off password aging for users:"
fi
 
# ljd 6/10/02 The number of cms users can be extensive and fill up
#             the log file. Therefore, no longer do it.
#cat $TMPFILE >> $LOGFILE
 
}
 
# **************************************************************************
# Function: cleanup_exit()
# Description:  Removes all temporary files and exits with argument.
# Arguments:    One: exit code
# Return Value: None.
# **************************************************************************
function cleanup_exit
{
  rm -f $LOCKFILE
  rm -f $TMPFILE
  exit $1
}
# **************************************************************************
# MAIN PROGRAM
# **************************************************************************
 
# ----------------
# GLOBAL CONSTANTS
# ----------------
if [ "$OSNAME" = "SunOS" ]; then
   readonly PWAGE_FILE="/etc/default/passwd"
else
   readonly PWAGE_FILE="/etc/login.defs"
fi
readonly ETCPASSWD="/etc/passwd"
readonly ETCPASSWDSAVE="/cms/tmp/passwd"
readonly NSSWITCH="/etc/nsswitch.conf"
readonly EXCLUDED_USERS="/cms/db/age_pw_exclude"
readonly PWAGE_TEMPLATE="/cms/toolsbin/age_pw_template"
readonly LOGFILE="/cms/install/logdir/admin.log"
readonly LOCKFILE=/cms/tmp/age_pw.lock
readonly TMPFILE=/cms/tmp/passwd.tmp.$$
readonly DEF_WEEKS=9
readonly WARNDAYS=7
readonly true=1
# Error codes
readonly NO_LOGFILE=1
readonly NOT_ROOT=2
readonly NO_EXCL=3
readonly DIR_SERV_USED=4
 
# -----------------------------------------------
# GLOBAL_VARIABLES - sorted in alphabetical order
# -----------------------------------------------
 
# --------------------------
# Check that admin.log exists
# --------------------------
if [ ! -w $LOGFILE ]
then
  printf "age_pw: ERROR: $LOGFILE does not exist--CMS not installed?\n"
  cleanup_exit $NO_LOGFILE
fi
 
# --------------------------
# Verify if the user is root
# --------------------------
if [ $LOGNAME != root ]
then
  display_and_log_message "\nage_pw: ERROR: You must be root to run this command!\n"
  cleanup_exit $NOT_ROOT
fi
 
# --------------------------
# Check that $EXCLUDE_USERS exists
# and cleanup_exit if it does not.
# --------------------------
if [ ! -f $EXCLUDED_USERS ]
then
  display_and_log_message \
        "\nage_pw: ERROR: Required file, $EXCLUDED_USERS does not exist--exiting. Call Services.\n"
  cleanup_exit $NO_EXCL
fi
 
# --------------------------
# Remove any blank lines in the
# file (possible fat finger
# by customers or services).
# --------------------------
. /olds/olds-funcs
remove_blank_lines $EXCLUDED_USERS
 
# --------------------------
# Check that NIS/NIS+ or LDAP
#  is used and cleanup_exit if it does.
# --------------------------
DIR_USED="`grep '^passwd:' $NSSWITCH | egrep '(nis|db|ldap)'`"
if [ "${DIR_USED}" != ""  ]
then
  display_and_log_message \
       "\nERROR: Password aging cannot be implemented on systems using NIS, NIS+ or LDAP.\n"
  cleanup_exit $DIR_SERV_USED
fi
 
check_lock
log_message "** Starting age_pw"
 
# If there is no password policy file, copy the default in
if [ ! -f $PWAGE_FILE ]
then
   cp $PWAGE_TEMPLATE $PWAGE_FILE
   chmod 444 $PWAGE_FILE
fi
 
PS3=" 1) Turn on password aging\n 2) Turn off password aging\n 3) Change password aging interval\n    or q to quit: "
check_for_123 RESPONSE
case $RESPONSE in
      1|3)
       get_aging_interval $RESPONSE
       PS3="Enter Maximum number of week(s) before passwords expire"
       check_range AGE_WEEKS
       modify_policy_file $AGE_WEEKS
       age_existing_users $AGE_WEEKS
       display_and_log_message  "Expiring passwords every $AGE_WEEKS week(s)"
       ;;
      2)
       get_aging_interval $RESPONSE
       PS3="Turn off password aging for all CMS users"
       check_for_yorn YORN
       if [ $YORN = "y" ]
       then
         display_and_log_message "Turning off password aging for all CMS users"
         modify_policy_file ""
         age_existing_users -1
       else
        display_and_log_message "Not turning off password aging for all CMS users"
       fi
       ;;
esac
 
log_message "** Exiting age_pw"
 
cleanup_exit 0

Файл /cms/toolsbin/awk_rtdb

/cms/toolsbin/awk_rtdb
$3=="|" {
    print "CHG",$1,$2,$3,$5
}
$1==">" {
    print "ADD",$2,$3
}
$3=="<" {
    print "DEL",$1,$2
}

Скрипт меню cmssvc

Ищем реальное расположение команды:

$ which cmssvc
/usr/bin/cmssvc

На самом деле это скрипт /usr/bin/cmssvc

/usr/bin/cmssvc
#!/bin/ksh
# set PATH to find any possible command
CMSBASE=`cat /usr/bin/cms_base`
PATH=$CMSBASE/install/bin:$CMSBASE/install/cms_install:$CMSBASE/bin:$PATH export PATH
 
. adm_func
. /opt/informix/bin/setenv
 
ids_run_status
if [ $? -eq 4 ]
then
    if [ "`uname`" = SunOS ]; then
        echo "cmssvc: Warning IDS off-line. IDS can be turned on"
        echo "with the run_ids command on the cmssvc menu."
    else
        echo "cmssvc: Warning IDS off-line.  It will take approx 45 seconds to"
        echo "start cmssvc.  IDS can be turned on with the run_ids command on"
        echo "the cmssvc menu."
    fi
fi
 
export INFORMIXCONTIME=1
exec ins_proc -l $CMSBASE/install/logdir/admin.log -B

Смотрим что за переменная CMSBASE

# cat /usr/bin/cms_base
/cms

Смотрим что в первом упоминаемом каталоге PATH:

# ls /cms/install/bin
adm_func         config_firewall  ins_proc    restart_firewall   turn_off_cms
aom_start        converter        java_fips   restore            turn_off_ids
back_all         db_backup        patch_rmv   restrict_dbaccess  turn_on_cms
backup           db_restore       pkgrm       run_cms            turn_on_ids
compress_backup  firewall         postremove  run_ids            uncompress_backup
config_fips      firewall_status  preremove   stop_firewall

Смотрим скрипт adm_func (включенные функции), выполняемый командой cmssvc:

/cms/install/bin/adm_func
# cat 
 
#!/bin/ksh
################################################################################
#
# Copyright Avaya Inc., All Rights Reserved.
#
# THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF Avaya Inc.
#
# The copyright notice above does not evidence any actual or intended
# publication of such source code.
#
# Some third-party source code components may have  been modified from their
# original versions by Avaya Inc.
#
# The modifications are Copyright Avaya Inc., All Rights Reserved.
#
#############################################################################
#
# Shell functions used for CMS administration
#
# MODIFICATIONS:
#
# DATE        WHO   DESCRIPTION
# 24/07/09    hgl   wi00330195: Changes to remove software mirroring
# 09/22/09    ctb   wi00341160: Changes for Tivoli and onbar (64 bit)
# 09/22/10    ctb   wi00730810: add make_label for cmsadm backup to non-tape
# 10/05/10    ctb   wi00733837: add make_maint_label for maint backups
# 10/21/10    ctb   wi00825053: change date format for make_label
# 11/10/10    ctb   wi00830455: add check_for_stor_slice for LAN maint bkups
# 12/03/10    ctb   wi00838310: Change rotate_bkup_res_log() to handle bigger
#                               size and more files
# 03/28/11    hgl   wi00868445: Make changes to support LSI RAID card
# 04/20/11    ctb   wi00877847: Fix add_uid for 386 for R16.3
# 04/20/11    gps   wi00878382: Limit IDS memory to 85% of physical memory
# 03/08/12    ctb   wi00989256: Changes for R17 - mostly echo -> printf
# 06/21/12    ctb   wi01018226: Turn off IDS should not remove it from upstart
# 08/08/12    hgl   wi01028744: Linux ODBC connection does not work
# 10/04/12    hgl   wi01049418: create RAID controller type check function
# 10/24/12    hgl   wi01054724: Linux tape support
# 11/15/12    hgl   wi01059695: Change CMS GID to 1001 on Linux
# 10/02/13    hgl   wi01118671: Support adding disks for VMware CMS
# 09/19/14    hgl   wi01189368: Only VMware disks are allowed to add to IDS
# 10/07/14    hgl   wi01193149: Add HP support
# 04/14/15    ctb   CMS-505:    add default for $TIMEOUT in ids_on
# 05/07/15    hgl   CMS-535:    Add Dell R220 support
# 06/18/15    hgl   CMS-582:    skip disks with filesystem when add_disks
# 08/08/15    hgl   CMS-478:    move search and exclusive lists from backup to
#                               adm_func so that netbackup can use them
# 04/15/16    sww   CMS-1400    Add support for HPE DL20 G9 platform
# 05/18/16    jba   CMS-1342    Put in dependency check ids.conf or turn_on_ids
#                               for Linux systems
# 03/23/17    jba   CMS-1488    IDS doesn't come up in case iso get mounted in the linux system
#                               after system gets rebooted post baseload upgrade
# 06/21/17   gyeh   CMS-1716    use groupadd to create a user group
# 09/18/17   gyeh   CMS-1722    firewall support: allow quit for menu,
#                               allow default for y/n
# 10/05/17        ctb   CMS-1762:   Support for FIPS mode on/off: setting ciphers
#                                                           in /etc/ssh/sshd_config
# 01/17/18    ctb   CMS-1840:   Fix modify_sshconfig to match requirements
################################################################################
 
CMSOS=`uname`
export CMSOS
 
# make_menu <heading> <items>
# items are separated by space or newline(\n). if an item has spaces, use @#
# to escape
# e.g. make_menu "Select one of the following" "Turn@#on@#IDS Turn@#off@#IDS"
# if % is part of item use .*}
    DOMAIN=${VALUE[2]}
    IPADDR=${VALUE[3]}
    NETMASK=${VALUE[4]}
    GATEWAY=${VALUE[5]}
    SEARCH=${VALUE[7]}
    # remove spaces
    if [ -n "${VALUE[6]}" ]; then
        DNS1=`echo ${VALUE[6]} |  awk '{print $1}'`
        DNS2=`echo ${VALUE[6]} |  awk '{print $2}'`
        DNS3=`echo ${VALUE[6]} |  awk '{print $3}'`
    fi
    DEFAULTGATEWAY=${VALUE[8]}
}
 
display_inputs ()
{
    echo -e "\n  Interface: $INTERFACE"
    echo -e "  CMS Hostname: $HOSTNAME"
    echo -e "  Domainname: $DOMAIN"
    echo -e "  CMS IP address: $IPADDR"
    echo -e "  Netmask: $NETMASK"
    echo -e "  Gateway: $GATEWAY"
    echo -e "  DNS Server1: $DNS1"
    echo -e "  DNS Server2: $DNS2"
    echo -e "  DNS Server3: $DNS3"
    echo -e "  Search domains: $SEARCH"
    if [ -n "$DEFAULTGATEWAY" ]; then
        echo -e "  Default gateway: $DEFAULTGATEWAY\n"
    else
        echo -e " "
    fi
}
 
echo -e "`date` $0 started" >> $LOGFILE
 
echo " WARNING: This tool only supports IPv4"
 
# Running Network Manager may cause ifup failure
# Stop Network Manager and remove it from startup script
# NetworkManager is removed in R18. Just in case
service NetworkManager stop > /dev/null 2>&1
chkconfig NetworkManager off > /dev/null 2>&1
 
if [ $# -eq 1 ]; then
    if [ ! -e $1 ]; then
        echo "$1 does not exist" | tee -a $LOGFILE
        usage
        err_exit 1
    else
        . $1
    fi
    # make sure one entry for domain
    DOMAIN=`echo $DOMAIN | awk '{print $1}'`
    if [ -z "$INTERFACE" -o -z "$IPADDR" -o -z "$GATEWAY" ]; then
        echo "Wrong input file." | tee -a $LOGFILE
        cat $1 >> $LOGFILE
        usage
        err_exit 1
    fi
    display_inputs
else
    lastinput=`ls -1rt ${INPUTFILE} ${INPUTFILE}.eth[0-9] 2>/dev/null | tail -1`
    if [ -s "$lastinput" ]; then
        . $lastinput
    else
        INTERFACE="" HOSTNAME="" DOMAIN="" SEARCH="" IPADDR="" NETMASK="" GATEWAY=""
        DNS1="" DNS2="" DNS3=""
    fi
    while true
    do
        set_input_default_values
        get_inputs
        display_inputs
        echo -e "  Are the above inputs correct? (y|n) \c"
        read confirm
        if [ "$confirm" == "y" -o "$confirm" == "Y" ]; then
            break
        fi
    done
fi
 
INPUTFILE=${INPUTFILE}.${INTERFACE}
HWADDR=`ifconfig -a | grep "^$INTERFACE" | awk '{print $NF}'`
UUID=`uuidgen`
# INTERFACE and HOSTNAME are used for remembering user inputs
echo "INTERFACE=\"$INTERFACE\"" > $INPUTFILE
echo "HOSTNAME=\"$HOSTNAME\"" >> $INPUTFILE
# without UUID dbus-send (in network-functions) will generate one
echo "UUID=\"$UUID\"" >> $INPUTFILE
echo "ONBOOT=\"yes\"" >> $INPUTFILE
echo "BOOTPROTO=\"static\"" >> $INPUTFILE
echo "HWADDR=\"$HWADDR\"" >> $INPUTFILE
if [ -n "$SEARCH" ]; then
    echo "$SEARCH" | grep -q "$DOMAIN" 2>/dev/null
    if [ $? -eq 0 ]; then
        echo "DOMAIN=\"$SEARCH\"" >> $INPUTFILE
    else
        echo "DOMAIN=\"$DOMAIN $SEARCH\"" >> $INPUTFILE
    fi
    # SEARCH is only used to remember user input
    echo "SEARCH=\"$SEARCH\"" >> $INPUTFILE
else
    echo "DOMAIN=\"$DOMAIN\"" >> $INPUTFILE
fi
echo "IPADDR=\"$IPADDR\"" >> $INPUTFILE
echo "NETMASK=\"$NETMASK\"" >> $INPUTFILE
echo "GATEWAY=\"$GATEWAY\"" >> $INPUTFILE
if [ -n "$DNS1" ]; then
    echo "DNS1=\"$DNS1\"" >> $INPUTFILE
fi
if [ -n "$DNS2" ]; then
    echo "DNS2=\"$DNS2\"" >> $INPUTFILE
fi
if [ -n "$DNS3" ]; then
    echo "DNS3=\"$DNS3\"" >> $INPUTFILE
fi
if [ -n "$DEFAULTGATEWAY" ]; then
    echo "DEFAULTGATEWAY=\"$DEFAULTGATEWAY\"" >> $INPUTFILE
fi
 
 
IFILE=${IFDIR}/ifcfg-${INTERFACE}
OLDIFILE=${CMSBASE}/tmp/.ifcfg-${INTERFACE}
TMPIFILE=${CMSBASE}/tmp/.ifcfg-${INTERFACE}.tmp
 
# update /etc/sysconfig/network-scripts/ifcfg-ethX
# /etc/resolv.conf /etc/sysconfig/network
if [ -e "$IFILE" ]; then
    # Save the original configuration file to $LOGFILE. If rename to
    # ifcfg-${INTERFACE}.sv nmcli con list uuid could point to this file
    echo "### old $IFILE:" >> $LOGFILE
    cat $IFILE >> $LOGFILE
else
    echo "$IFILE does not exist" >> $LOGFILE
    echo "DEVICE=\"$INTERFACE\"" > $IFILE
    echo "NM_CONTROLLED=\"yes\"" >> $IFILE
    echo "TYPE=\"Ethernet\"" >> $IFILE
    chmod 644 $IFILE
fi
/bin/cp -p $IFILE $OLDIFILE
 
cat $IFILE | \
egrep -v "^BOOTPROTO|^HWADDR|^DNS|^GATEWAY|^HOSTNAME|^IPADDR|^NETMASK|^ONBOOT|^DOMAIN|^UUID                       " \
> $TMPIFILE
 
# generate the new interface configuration file
/bin/cp $TMPIFILE $IFILE
cat $INPUTFILE | egrep -v "^INTERFACE|^HOSTNAME|^SEARCH|^DEFAULTGATEWAY" >> $IFILE
 
echo "### new ${IFILE}:" >> $LOGFILE
cat $IFILE >> $LOGFILE
 
#
# Active the network
#
# ifup fails can mess up /etc/resolve.conf
# Save and restore /etc/resolve.conf in case ifup fails
/bin/cp -p /etc/resolv.conf /etc/resolv.conf.sv
echo -e "\n Bring the network up. Please wait...\n"
echo -e "`date` ifup $INTERFACE" >> $LOGFILE
ifdown $INTERFACE > /dev/null 2>&1
ifup $INTERFACE >> $LOGFILE 2>&1
rtn=$?
if [ $rtn -ne 0 ]; then
    echo -e "`date` Rerun ifup $INTERFACE" >> $LOGFILE
    # if ifup fails it modifies $IFILE
    /bin/cp $TMPIFILE $IFILE
    cat $INPUTFILE | egrep -v "^INTERFACE|^HOSTNAME|^SEARCH" >> $IFILE
    sleep 3
    # Sometimes ifup returns 0 but network is still down
    ifup $INTERFACE >> $LOGFILE 2>&1
    ping -c 1 -W 1 $GATEWAY >> $LOGFILE 2>&1
    rtn=$?
    if [ $rtn -ne 0 ]; then
       echo -e "`date` ping $GATEWAY failed." >> $LOGFILE
       echo -e "`date` Retry ifdown and ifup to bring the network up." >> $LOGFILE
       ifdown $INTERFACE >> $LOGFILE 2>&1
       ifup $INTERFACE >> $LOGFILE 2>&1
       ping -c 1 -W 1 $GATEWAY >> $LOGFILE 2>&1
       rtn=$?
    fi
fi
if [ $rtn -ne 0 ]; then
    /bin/cp -p $OLDIFILE $IFILE
    /bin/mv /etc/resolv.conf.sv /etc/resolv.conf
    echo -e "Network configuration failed"
    err_exit 1
else
    /bin/rm -f /etc/resolv.conf.sv
fi
 
# /etc/sysconfig/network
# HOSTNAME=partridge
# NISDOMAIN=dr.avaya.com
hostname $HOSTNAME
grep HOSTNAME /etc/sysconfig/network > /dev/null 2>&1
if [ $? -eq 0 ]; then
    sed -i "/HOSTNAME/s/.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
else
    echo "HOSTNAME=${HOSTNAME}" >> /etc/sysconfig/network
fi
 
# add hostname to /etc/hosts
# using hostname-eth0, hostname-eth1 for multi-NICs
# using IP with default gateway as primary entry
# if miti-NICs have same default gateway take the first one for hostname
# in alphabet order (eth0, eth1)
# in case user inputs an empty HOSTNAME
if [ -n "$HOSTNAME" ]; then
    sed -i "/ $HOSTNAME /d"  /etc/hosts
fi
default_host_flag=yes
for eth in eth0 eth1 eth2 eth3
do
    gw=`grep ^GATEWAY ${IFDIR}/ifcfg-$eth 2>/dev/null | awk -F= '{print $NF}' | sed 's/"//g                       ; s/ //g; /^$/d'`
    if [ -z "$gw" ]; then
        continue
    fi
    ipaddr=`grep ^IPADDR ${IFDIR}/ifcfg-$eth 2>/dev/null | awk -F= '{print $NF}' | sed 's/"                       //g; s/ //g; /^$/d'`
    if [ -z "$ipaddr" ]; then
        continue
    fi
    # if DEFAULTGATEWAY is empty grep -q "" returns 0
    echo "$gw" | grep -q "$DEFAULTGATEWAY"
    # the first IP has default gateway
    if [ $? -eq 0 -a "$default_host_flag" == yes ]; then
        default_host_flag=no
        if [ -n "$HOSTNAME" ]; then
            sed -i "/ $HOSTNAME /d"  /etc/hosts
        fi
        echo "$ipaddr $HOSTNAME ${HOSTNAME}.${DOMAIN}" >> /etc/hosts
    else
        sed -i "/ $HOSTNAME-$eth /d"  /etc/hosts
        echo "$ipaddr $HOSTNAME-$eth ${HOSTNAME}-$eth.${DOMAIN}" >> /etc/hosts
    fi
done
 
domainname $DOMAIN
grep NISDOMAIN /etc/sysconfig/network > /dev/null 2>&1
if [ $? -eq 0 ]; then
    sed -i "/NISDOMAIN/s/.*/NISDOMAIN=${DOMAIN}/" /etc/sysconfig/network
else
    echo "NISDOMAIN=${DOMAIN}" >> /etc/sysconfig/network
fi
 
#
# setup static routing for Multi-NICs on different subnets
#
if [ -n "$DEFAULTGATEWAY" ]; then
    echo -e "`date` eth interfaces are on different subnets" >> $LOGFILE
    for eth in eth0 eth1 eth2 eth3
    do
        gw=`grep ^GATEWAY ${IFDIR}/ifcfg-$eth 2>/dev/null | awk -F= '{print $NF}' | sed 's/                       "//g; s/ //g; /^$/d'`
        if [ -z "$gw" ]; then
            continue
        fi
        ipaddr=`grep ^IPADDR ${IFDIR}/ifcfg-$eth 2>/dev/null | awk -F= '{print $NF}' | sed                        's/"//g; s/ //g; /^$/d'`
        if [ -z "$ipaddr" ]; then
            continue
        fi
        echo -e "`date` processing $eth IP: $ipaddr Gateway: $gw" >> $LOGFILE
        # create routing table for this gateway
        # reuse routing table name when IP changed
        if [ -s ${IFDIR}/route-$eth ]; then
            echo -e "`date` gateway $gw routing table is already set" >> $LOGFILE
            # each interface should have one routing table ID
            tab=`cat ${IFDIR}/route-$eth | head -1 | awk '{print $NF}'`
            i=${tab: -1}
            # this should not happen, just in case
            grep -q " $tab$" /etc/iproute2/rt_tables
            if [ $? -ne 0 ]; then
                echo "$i CMS${i}" >> /etc/iproute2/rt_tables
            fi
            echo -e "`date` delete and reset the routing table" >> $LOGFILE
            while read route
            do
                echo "ip route del $route" >> $LOGFILE
                ip route del $route > /dev/null 2>&1
            done < ${IFDIR}/route-$eth
        else
            i=`egrep -v "^#|^255|^254|^253" /etc/iproute2/rt_tables | awk '{print $1}' | so                       rt -rn | head -1`
            if [ -z "$i" ]; then
                let i=1
            else
                let i=$i+1
            fi
            echo "$i CMS${i}" >> /etc/iproute2/rt_tables
        fi
        echo -e "`date` ip route add default via $gw dev $eth table CMS${i}" >> $LOGFILE
        ip route add default via $gw dev $eth table CMS${i} >> $LOGFILE 2>&1
        if [ $? -ne 0 ]; then
            echo -e "Adding default gateway $gw for $eth to table CMS${i} failed"
            echo -e "ip route add default via $gw dev $eth table CMS${i} failed" >> $LOGFIL                       E
            err_exit 1
        fi
        # persist the setting for reboot
        echo "default via $gw dev $eth table CMS${i}" > ${IFDIR}/route-$eth
 
        # setup rules
        if  [ -s ${IFDIR}/rule-$eth ]; then
            echo -e "`date` routing rules for $ipaddr are already set" >> $LOGFILE
            while read tab
            do
                tab=`echo $tab | awk '{print $NF}'`
                ip rule | grep $tab >> $LOGFILE 2>/dev/null
                echo -e "`date` delete and reset the routing rules" >> $LOGFILE
                echo "while ip rule del table $tab 2>/dev/null; do true; done" >> $LOGFILE
                while ip rule del table $tab 2>/dev/null; do true; done
            done < ${IFDIR}/rule-$eth
        fi
        echo -e "`date` ip rule add from ${ipaddr}/32 table CMS${i}" >> $LOGFILE
        ip rule add from ${ipaddr}/32 table CMS${i} >> $LOGFILE 2>&1
        if [ $? -ne 0 ]; then
            echo -e "Adding rule for ${ipaddr} to table CMS${i} failed"
            echo -e "ip rule add from ${ipaddr}/32 table CMS${i} failed" >> $LOGFILE
            err_exit 1
        fi
        # persist the setting for reboot
        echo "from ${ipaddr}/32 table CMS${i}" > ${IFDIR}/rule-$eth
    done
 
    # set default gateway
    echo -e "`date` Adding default gateway $DEFAULTGATEWAY" >> $LOGFILE
    ip route del default > /dev/null 2>&1
    echo -e "`date` ip route add default via $DEFAULTGATEWAY" >> $LOGFILE
    ip route add default via $DEFAULTGATEWAY >> $LOGFILE 2>&1
    if [ $? -ne 0 ]; then
        echo -e "Adding default gateway $DEFAULTGATEWAY failed"
        echo -e "ip route add default via $DEFAULTGATEWAY failed" >> $LOGFILE
        err_exit 1
    fi
    # persist the setting for reboot
    grep -q "GATEWAY=$DEFAULTGATEWAY" /etc/sysconfig/network 2>/dev/null
    if [ $? -ne 0 ]; then
        sed -i '/^GATEWAY/d' /etc/sysconfig/network
        echo "GATEWAY=$DEFAULTGATEWAY" >> /etc/sysconfig/network
    fi
    # flush cache
    ip route flush cache
fi
 
echo -e "`date` $0 successfully finished\n" | tee -a $LOGFILE

Переменные окружения

Файл /opt/informix/bin/setenv, добавляющий переменные окружения

/opt/informix/bin/setenv
# Environment variables for Informix IDS
DB_LOCALE=en_us.utf8;
export DB_LOCALE;
INFORMIXDIR=/opt/informix;
export INFORMIXDIR;
INFORMIXSERVER=cms_ol;
export INFORMIXSERVER;
ONCONFIG=onconfig.cms;
export ONCONFIG;
INFORMIXCONTIME=2
export INFORMIXCONTIME
PATH=$PATH:$INFORMIXDIR/bin;
export PATH;
 
# 129877: Solaris 9 sets TERMCAP => dbaccess doesn't work
unset TERMCAP;

Cписок переменных окружения — env

(ucacms1)-(root)=# env
SPI6=/cms/pbx/acd6/spi.err
SPI7=/cms/pbx/acd7/spi.err
SPI4=/cms/pbx/acd4/spi.err
SPI5=/cms/pbx/acd5/spi.err
DBPATH=/cms/db/inf
HOSTNAME=ucacms1
SPI2=/cms/pbx/acd2/spi.err
SELINUX_ROLE_REQUESTED=
SPI3=/cms/pbx/acd3/spi.err
TERM=xterm
SHELL=/bin/bash
SPI1=/cms/pbx/acd1/spi.err
HISTSIZE=1000
SSH_CLIENT=10.0.45.51 50181 22
INFORMIXDIR=/opt/informix
SELINUX_USE_CURRENT_RANGE=
SPI8=/cms/pbx/acd8/spi.err
SSH_TTY=/dev/pts/0
USER=root
LD_LIBRARY_PATH=:/opt/informix/lib:/opt/informix/lib/esql
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
U=/usr/spool/uucppublic
ONCONFIG=onconfig.cms
INFORMIXTERM=terminfo
MAIL=/var/spool/mail/root
PATH=/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:usr/informix/bin:/opt/informix/bin:
PWD=/root
INFORMIXCONTIME=2
LANG=en_US.UTF-8
PS1=\n(ucacms1)-(root)=#
SELINUX_LEVEL_REQUESTED=
DB_LOCALE=en_us.utf8
HISTCONTROL=ignoredups
INFORMIXSERVER=cms_ol
SHLVL=1
HOME=/root
TERMINFO=/cms/terminfo
LOGNAME=root
SSH_CONNECTION=10.0.45.51 50181 172.21.103.17 22
LESSOPEN=||/usr/bin/lesspipe.sh %s
G_BROKEN_FILENAMES=1
_=/bin/env

Посмотреть значение конкретной переменной:

# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:usr/informix/bin:/opt/informix/bin:/opt/informix/bin:/opt/informix/bin
 
# env | grep INFORMIX
INFORMIXDIR=/opt/informix
INFORMIXTERM=terminfo
INFORMIXCONTIME=2
INFORMIXSERVER=cms_ol

Скрипт создания базы данных

/opt/Informix/bin/dbinit.sh

/opt/Informix/bin/dbinit.sh
#!/bin/ksh
################################################################################
# Copyright (c) 2015, Avaya. All rights reserved.
#
# NAME: dbinit.sh
#
# DESCRIPTION:
#    Initialize CMS database and create dbspaces for CMS database
#    CMS R16 only has two data dbspaces cmsdbs and aasdbs
#    aasdbs for visual vector is dropped in R17
#
# WARNING: Adding disk relies on the sequence of disks. When a disk is added
#          as data disk or backup disk you can't drop it or change it.
#
# Arguments:
#    None
#
# Installed:
#    on CMS DVD and /opt/informix/bin
#
# Usage:
#    dbinit.sh [add_disks]
#
# MODIFICATIONS:
#
# DATE        WHO   DESCRIPTION
# 06/14/09    hgl   Inital development for CMS R16
# 09/22/11    hgl   wi00939992: In case disk geometry changes, leave 1GB on s7
#                               unused for onbar and ontape binary restore.
# 03/15/12    hgl   wi00990624: Add Linux support. Remove aasdbs since visual
#                               vector is no longer supported.
# 08/08/12    hgl   wi01028744: Linux ODBC connection does not work. Configure
#                               DBSERVERALIASES
# 10/02/13    hgl   wi01118671: Repartition disk and/or add disks for VMware CMS
# 09/19/14    hgl   wi01189368: Only VMware disks are allowed to add to IDS
# 02/13/15    hgl   wi01160841: set new IDS 12 FULL_DISK_INIT parameter to 1
# 06/18/15    hgl   CMS-582: skip disks with filesystem when add_disks
################################################################################
 
trap 'err_exit 3' 1 2 3 15
 
LOGFILE=/opt/informix_install.log
 
err_exit ()
{
  if [ $1 -eq 3 ]; then
    printf "Caught signal, exiting...\n" | tee -a $LOGFILE
  fi
  printf "Please check $LOGFILE and /opt/informix/cmsids.log for details\n"
  printf "Please fix the problem and re-run $0\n"
  printf "`date` Creating CMS database failed\n\n" | tee -a $LOGFILE
  exit $1
}
 
repartition_disk ()
{
 
  # You can use following commands to get original disk partition creating
  # scripts.
  # grep "^# parted" /root/cms_kickstart.log | sed '/^# /s///g'
 
  # check if the size changed or not
  newsize=`parted $cmsdev unit s print | grep "$cmsdev" | awk '{print$3}'`
  let newsize=${newsize%s}-1
  oldsize=`parted $cmsdev unit s print | grep "extended" | awk '{print$3}'`
  let oldsize=${oldsize%s}
 
  printf "`date` The new disk size: ${newsize} sectors\n" | tee -a $LOGFILE
  printf "`date` The old disk size: ${oldsize} sectors\n" | tee -a $LOGFILE
 
  if [ `expr "$newsize" - 2097152` -gt "$oldsize" ]; then
    printf "`date` Repartition the disk for large OVA configuration\n" | tee -a $LOGFILE
  else
    printf "`date` No need to repartition the disk\n" | tee -a $LOGFILE
    return
  fi
 
  # repartition the disk to increase disk size
  # Number  Start     End          Size         Type      File system     Flags
  # 1       2048s     1169400s     1167353s     primary   ext4            boot
  # 4       43112448s 1258291199s  1215178752s  extended                  lba
  # ...
  # F1      F2        F3           F4           F5        F6
 
  # parted skips master boot record
  # [root@cms~]# parted -a cylinder -s /dev/sda unit kB mkpart primary 0 600445
  # Error: You requested a partition from 0.00kB to 600445kB.
  # The closest location we can manage is 32.3kB to 600445kB.
 
  > /root/parted_old_size.sh
  > /root/parted_new_size.sh
  nump=`fdisk -l $cmsdev | grep "^/dev/" | wc -l`
  if [ "$nump" -ne 11 ]; then
    printf "`date` Wrong number of CMS disk partitions: $nump. It should be 11.\n" | tee -a $LOGFILE
    printf "`date` Repartition the disk failed\n" | tee -a $LOGFILE
    err_exit 1
  fi
  parted $cmsdev unit s print | grep "[0-9]" | tail -$nump | \
  while read F1 F2 F3 F4 F5 F6
  do
    F2=${F2%s}; F3=${F3%s}
    if [ "$F1" -eq 4 -o "$F1" -eq "$nump" ]; then
      NF3=$newsize
    else
      NF3=$F3
    fi
    if [ "$F1" -lt 4 ]; then
      echo "# parted -a opt -s $cmsdev unit s mkpart $F5 $F2 $F3" >> /root/parted_old_size.sh
      echo "# parted -a opt -s $cmsdev unit s mkpart $F5 $F2 $NF3" >> /root/parted_new_size.sh
    else
      echo "parted -a opt -s $cmsdev unit s mkpart $F5 $F2 $F3" >> /root/parted_old_size.sh
      echo "parted -a opt -s $cmsdev unit s mkpart $F5 $F2 $NF3" >> /root/parted_new_size.sh
    fi
  done
 
  chmod 755 /root/parted_old_size.sh /root/parted_new_size.sh
  cp -p /root/parted_old_size.sh /root/parted_old_size_`date "+%Y%m%d_%T"`.sh
 
  #
  # delete extended partition. parted does not allow to delete mounted partitions
  #
  printf "`date` Save partition table information\n" | tee -a $LOGFILE
  parted $cmsdev unit s print >> $LOGFILE
  printf "`date` Delete extended paritoin\n" | tee -a $LOGFILE
  fdisk -c -u $cmsdev > /tmp/cms_del_part.log 2>&1 << !EOF
d
4
w
q
!EOF
  rtn=$?
  if [ $rtn -ne 0 ]; then
    grep "Device or resource busy" /tmp/cms_del_part.log > /dev/null
    if [ $? -ne 0 ]; then
      printf "Delete extended partion failed: $rtn\n" | tee -a $LOGFILE
      cat /tmp/cms_del_part.log | tee -a $LOGFILE
      rm -f /tmp/cms_del_part.log
      err_exit 1
    fi
  else
    cat /tmp/cms_del_part.log >> $LOGFILE
    rm -f /tmp/cms_del_part.log
  fi
 
  printf "`date` Repartition the disk\n" | tee -a $LOGFILE
  part_nums1=`cat /root/parted_new_size.sh | grep -v "^#" | wc -l`
  /root/parted_new_size.sh 2>&1 | tee /tmp/cms_part.log
  part_nums2=`grep "Device or resource busy" /tmp/cms_part.log | wc -l`
  cat /tmp/cms_part.log >> $LOGFILE
  rm -f /tmp/cms_part.log
  if [ $part_nums1 -ne $part_nums2 ]; then
    printf "`date` Repartition the disk failed\n" | tee -a $LOGFILE
    # restore to the old partitions
    printf "`date` Restore to the previous disk partitions\n" | tee -a $LOGFILE
    /root/parted_old_size.sh > /dev/null 2>&1
    rm -f /root/parted_old_size.sh
    printf "\nThe disk partition modification scripts are saved as\n" | tee -a $LOGFILE
    printf "`ls -rt /root/parted_*`\n\n" | tee -a $LOGFILE
    err_exit 1
  else
    printf "`date` Reboot the machine to make new partitions effective\n" >> $LOGFILE
    # make sure to reboot
    trap 'printf "`date` Reboot the machine\n"; reboot' 1 2 3 15
    rm -f /root/parted_old_size.sh
    printf "\nWARNING: A reboot is required before the new partitions become effective.\n"
    printf "After the reboot finishes, please re-run $0\n"
    printf "\nPress Enter to continue\n"
    read confirm
    printf "`date` Reboot the machine\n"
    reboot
    exit
  fi
}
 
# VMware Linux only
add_disks ()
{
  printf "`date` Adding disks to cmsdbs started\n" | tee -a $LOGFILE
  onstat - > /dev/null 2>&1
  if [ $? -ne 5 ]; then
    printf "\nInformix IDS must be On-Line before new disk(s) can be added\n\n" | tee -a $LOGFILE
    printf "`date` Adding new disk(s) to cmsdbs failed\n" | tee -a $LOGFILE
    exit 1
  fi
  # all other disks are for Informix
  # CMS-582: support adding disk for backup
  # remove raw devices that are not used by IDS (created by ids_Linux_setup)
  # to handle following scenario: 1) IDS turned on 2) add disks 3) reboot the machine
  # 4) mkfs on disk3 5) dbinit add_disks and it should skip disk3
  #
  for raw in `raw -qa | awk -F: '{print $1}' | egrep -v "/dev/raw/raw1$"`
  do
    onstat -d | grep $raw > /dev/null 2>&1
    if [ $? -ne 0 ]; then
      printf "`date` remove raw device mapping for $raw\n" | tee -a $LOGFILE
      raw $raw 0 0
      if [ $? -ne 0 ]; then
        printf "`date` remove raw device mapping for $raw failed\n" | tee -a $LOGFILE
        err_exit 1
      fi
    else
      printf "`date` $raw was already added to IDS\n" | tee -a $LOGFILE
    fi
  done
  j=1
  for disk in `sfdisk -s | grep -v ^total | sort | awk -F: '{print $1}'`
  do
    # skip boot disk
    if [ $j -eq 1 ]; then
      j=`expr $j + 1`
      continue
    fi
    # /sys/block/sda/device/vendor has vendor information
    grep -iq VMware /sys/block/${disk##*/}/device/vendor
    if [ $? -ne 0 ]; then
      printf "`date` $disk is not a VMware Virtual disk. Skip it.\n" | tee -a $LOGFILE
      continue
    else
      # Skip disks with file system. A disk may be added on a different
      # datastore for backup
      blkid | grep ${disk} > /dev/null
      if [ $? -eq 0 ]; then
        printf "`date` $disk has filesystem on it. Skip it.\n" | tee -a $LOGFILE
        continue
      fi
    fi
    dsize=`sfdisk -s $disk`
    printf "data disk $disk size: ${dsize}KB\n" >> $LOGFILE
    # align partition with 1MB boundary
    offset=1024
    dsize=$dsize-$offset
    dsize=$dsize/${pagesz}*${pagesz}
    raw -q /dev/raw/raw${j} > /dev/null 2>&1
    if [ $? -ne 0 ]; then
      raw /dev/raw/raw${j} $disk >> $LOGFILE 2>&1
      if [ $? -ne 0 ]; then
        printf "`date` raw /dev/raw/raw${j} $infdev failed\n" | tee -a $LOGFILE
        err_exit 1
      fi
      sleep 1
    fi
    chown informix:informix /dev/raw/raw${j}
    chmod 660 /dev/raw/raw${j}
    # add to cmsdbs
    onstat -d 2>&1 | grep "/dev/raw/raw${j}" > /dev/null
    if [ $? -ne 0 ]; then
      printf "onspaces -a cmsdbs -p /dev/raw/raw${j} -o $offset -s $dsize\n" \
        | tee -a $LOGFILE
      # drop this chunk to remove disk
      printf "To remove disk $disk run: onspaces -d cmsdbs -p /dev/raw/raw${j} -o $offset\n" >> $LOGFILE
      onspaces -a cmsdbs -p /dev/raw/raw${j} -o $offset -s $dsize
      if [ $? -ne 0 ]; then
        printf "onspaces -a cmsdbs -p /dev/raw/raw${j} -o $offset -s $dsize failed\n" \
          | tee -a $LOGFILE
        err_exit 1
      else
        printf "new disk $disk was successfully added to cmsdbs\n"
      fi
    else
      printf "`date` $disk was already added to cmsdbs\n" | tee -a $LOGFILE
    fi
    j=`expr $j + 1`
  done
  printf "`date` New disk(s) were successfully added to cmsdbs\n" | tee -a $LOGFILE
}
 
# IDS default page size is 2K.
# IDS 11.50 Data pages per fragment Maximum Capacity per Table is 16,775,134
# For performance and capacity reason use 8K for CMS R16
integer pagesz=8
# roodbs, physical and logical logs page size is 2K
integer logpgsz=2
 
integer sec dsize offset
integer rootdbs logdbs physdbs dbtemp cmsdbs
 
cd /
 
# make sure id is root
uid=`id | cut -d '=' -f 2 | cut -d '(' -f 1`
if [ $uid -ne 0 ]; then
  printf "You must login as root to run $0\n" | tee -a $LOGFILE
  err_exit 1
fi
 
if [ ! -f /opt/informix/bin/setenv ]; then
  printf "/opt/informix/bin/setenv does not exist\n\n" | tee -a $LOGFILE
  err_exit 1
fi
. /opt/informix/bin/setenv
 
if [ "$1" != "noprompt" -a "$1" != "add_disks" ]; then
  printf "WARNING: $0 will initialize CMS database.\n" | tee -a $LOGFILE
  printf "WARNING: All data will be lost!!!\n" | tee -a $LOGFILE
  printf "Do you want to continue? (y or n) : "
  read confirm
  if [[ $confirm != "y" && $confirm != "Y" ]]; then
    printf "Do not continue!\n" >> $LOGFILE
    err_exit 1
  fi
fi
 
dmidecode -s system-manufacturer 2>/dev/null | grep VMware > /dev/null
if [ $? -eq 0 ]; then
  VMware=true
fi
 
if [ "$1" = "add_disks" ]; then
  if [ "$VMware" = "true" ]; then
    add_disks
  else
    printf "\nDisks can only be added to virtual CMS systems\n\n" | tee -a $LOGFILE
  fi
  exit 0
fi
 
printf "`date` Creating CMS database started\n" | tee -a $LOGFILE
 
# create symbolic link for IDS root path
if [ "`uname`" = SunOS ]; then
  printf "disk\n0\nquit\n\n" > /tmp/fmtcmd.$$
  disk=`format -f /tmp/fmtcmd.$$ 2>&1 | grep selecting | awk '{print $2}'`
  if [ -z $disk ]; then
      printf "Can't find boot disk through format command\n" | tee -a $LOGFILE
      rm -f /tmp/fmtcmd.$$
      err_exit 1
  fi
  rm -f /tmp/fmtcmd.$$
  rawdisk=/dev/rdsk/${disk}s7
  datadisk=/dev/rdsk/cmsdisk
 
  rm -f /dev/cmstape
  ln -s /dev/rmt/0c /dev/cmstape
  cmstape="\/dev\/cmstape"
else
  cmsdev=`sfdisk -s | grep -v ^total | sort | head -1 | awk -F: '{print $1}'`
  infdev=`fdisk -l | grep $cmsdev | tail -1 | awk '{print $1}'`
  printf "`date` disk partition for CMS informix: $infdev\n" | tee -a $LOGFILE
 
  # if necessary repartition the disk for VMware CMS
  if [ "$VMware" = "true" ]; then
    printf "`date` Repartition the disk for VMware CMS\n" | tee -a $LOGFILE
    repartition_disk
  fi
 
  raw -q /dev/raw/raw1 > /dev/null 2>&1
  if [ $? -ne 0 ]; then
    raw /dev/raw/raw1 $infdev >> $LOGFILE 2>&1
    if [ $? -ne 0 ]; then
      printf "`date` raw /dev/raw/raw1 $infdev failed\n" | tee -a $LOGFILE
      err_exit 1
    fi
    # If it is the first time run raw /dev/raw/raw1 $infedev and
    # chown informix:informix /dev/raw/raw1 after reboot the informix
    # owner can only last less than a second then changed to root
    # Workaround for this issue is to sleep 1 second before run chown command
    sleep 1
  fi
  rawdisk=/dev/raw/raw1
  datadisk=/cmsdisk
 
  rm -f /cmstape
  ln -s /dev/st0 /cmstape
  cmstape="\/cmstape"
fi
 
rm -f $datadisk
ln -s $rawdisk $datadisk
 
printf "`date` raw disk path: $rawdisk\n" | tee -a $LOGFILE
 
# test the disk
dd if=$datadisk of=/dev/null count=1 > /dev/null 2>&1
if [ $? -ne 0 ]; then
  printf "Can't read data disk: $datadisk\n" | tee -a $LOGFILE
  err_exit 1
fi
 
chown informix:informix $rawdisk
chmod 660 $rawdisk
 
# On Linux it can cause connection problem without cleaning up socket files in /INFORMIXTMP
rm -rf /INFORMIXTMP
 
# Initialize IDS
printf "`date` Initializing Informix IDS started\n" | tee -a $LOGFILE
# make sure IDS is not running
ps -ef | grep oninit > /dev/null 2>&1
if [ $? -eq 0 ]; then
  onmode -ky > /dev/null 2>&1
  sleep 5
fi
# make sure no shared memory segments left
if [ "`uname`" = SunOS ]; then
  ipcs -m | grep ^m | grep informix > /dev/null
  if [ $? -eq 0 ]; then
    printf "`date` There are left over shared memory segments\n" >> $LOGFILE
    for i in `ipcs -m | grep ^m | grep informix | awk '{print $2}'`
    do
      ipcrm -m $i
    done
  fi
  ipcs -s | grep ^s | grep informix > /dev/null
  if [ $? -eq 0 ]; then
    printf "`date` There are left over semaphores\n" >> $LOGFILE
    for i in `ipcs -s | grep ^s | grep informix | awk '{print $2}'`
    do
      ipcrm -s $i
    done
  fi
else
  # On Linux some Informix shared memory segments are owned by root
  # Remove all shared memory segments and semophores. Since CMS is the only
  # application other than Informix uses shared memory and semophores there is
  # a small chance to mess up other applications.
 
  ipcs -m | grep informix > /dev/null
  if [ $? -eq 0 ]; then
    printf "`date` There are left over shared memory segments\n" >> $LOGFILE
    # remove Shared memory
    for i in `ipcs -m | egrep -v "\-|key|^$" | awk '{print $2}'`
    do
      ipcrm -m $i
    done
  fi
 
  ipcs -s | grep informix > /dev/null
  if [ $? -eq 0 ]; then
    printf "`date` There are left over semaphores\n" >> $LOGFILE
    # remove Semaphore
    for i in `ipcs -s | egrep -v "\-|key|^$" | awk '{print $2}'`
    do
      ipcrm -s $i
    done
  fi
fi
 
# create sqlhosts
if [ -f $INFORMIXDIR/etc/sqlhosts ]; then
  cp -p $INFORMIXDIR/etc/sqlhosts $INFORMIXDIR/etc/sqlhosts_`date "+%Y_%m_%d_%T"`
fi
 
# oninit fails if DBSERVERNAME has ".", "-" characters
# Invalid character(s) in DBSERVERNAME or DBSERVERALIASES (cms_emu.dr.avaya.com).
shortname=`hostname | awk -F. '{print $1}' | sed /-/s//_/g`
 
if [ "`uname`" = SunOS ]; then
  printf "cms_ol onipcstr `uname -n` cms_ol\n" > $INFORMIXDIR/etc/sqlhosts
  printf "oacms_ol onipcstr `uname -n` oacms_ol\n" >> $INFORMIXDIR/etc/sqlhosts
  printf "cms_net ontlitcp `uname -n` 50000\n" >> $INFORMIXDIR/etc/sqlhosts
  printf "cms_${shortname} ontlitcp `uname -n` 50001\n" >> $INFORMIXDIR/etc/sqlhosts
else
  printf "cms_ol onipcstr `uname -n` cms_ol\n" > $INFORMIXDIR/etc/sqlhosts
  printf "oacms_ol onipcstr `uname -n` oacms_ol\n" >> $INFORMIXDIR/etc/sqlhosts
  printf "cms_net onsoctcp `uname -n` 50000\n" >> $INFORMIXDIR/etc/sqlhosts
  printf "cms_${shortname} onsoctcp `uname -n` 50001\n" >> $INFORMIXDIR/etc/sqlhosts
fi
chown informix:informix $INFORMIXDIR/etc/sqlhosts
 
# check console.msgs file
if [ ! -f $INFORMIXDIR/console.msgs ]; then
  touch $INFORMIXDIR/console.msgs
  chown informix:informix $INFORMIXDIR/console.msgs
fi
 
# setup sqlhosts for isql
cp -p $INFORMIXDIR/etc/sqlhosts /opt/informix_isql32/etc/sqlhosts
 
printf "`date` Checking kernel parameters\n" | tee -a $LOGFILE
 
integer shmem
if [ "`uname`" = SunOS ]; then
  # Kernel Parameters required by IDS
  # IDS Failure with a Large Intimate Shared Memory Page Size
  # set mmu_ism_pagesize = 4194304
  # Don't need to rebbot the machine since CMS installation requires reboot
  # 05/20/2011 mmu_ism_pagesize is no longer in kernel for Solaris 10 update 9
  # Comment out following 5 lines
  #val=`grep mmu_ism_pagesize /etc/system | awk -F'=' '{print $2}'`
  #if [ -z $val ]; then
  #    printf "add mmu_ism_pagesize=4194304\n" | tee -a $LOGFILE
  #    printf "set mmu_ism_pagesize=4194304\n" >> /etc/system
  #fi
  # Tune IPC for Solaris 10. See IDS release notes for details
  # /etc/system shmsys:shminfo_shmmax sets system project max-shm-memory to
  # a huge number. The root.user and default project max-shm-memory remain
  # the same as shmsys:shminfo_shmmax. If IDS is started by init it belongs
  # to system project otherwise it uses user.root project.
  shmem=`prtconf | grep "Memory size" | awk '{print $3}'`
  printf "`date` Max shared Memory size: $shmem MB\n" | tee -a $LOGFILE
  prctl -n project.max-shm-memory -r -v ${shmem}mb -i project system user.root noproject default 2>&1 | tee -a $LOGFILE
  # Note that the project.max-shm-memory resource control limits the total
  # amount of shared memory of one project, whereas previously,
  # the shmsys:shminfo_shmmax parameter limited the
  # size of a single shared memory segment
  # For CMS R16, use old /etc/system way to set shmmax
  # which is done by /cms/install/bin/SETtunes
  #projmod -s -K "project.max-shm-memory=(priv,${shmem}mb,deny)"\
  #           user.root
  #projmod -A user.root
else
  # Linux kernel parameters
  # ids_machine_notes_11.50.txt: Informix tested kernel parameters as following
  # SHMMAX: 4398046511104 SHMMIN: 1 SHMMNI: 4096 SHMSEG: 128 SHMALL: 4194304
  # SEMMNI: 4096 SEMMSL: 250 SEMMNS: 32000 SEMOPM: 32
  # SEMMSL should be set to at least 100
 
  shmem=`grep MemTotal /proc/meminfo | awk '{print $2}'`
  printf "`date` Max shared Memory size: $shmem KB\n" | tee -a $LOGFILE
  shmem=$shmem*1024
  integer shmall=$shmem/16
 
  # Out of box Linux kernel parameters are good for Informix
  # Just tune semaphore parmaters
  sysctl -p - << !EOF | tee -a $LOGFILE
 
  # Controls the maximum shared segment size, in bytes
  #kernel.shmmax = $shmem
 
  # Controls the maximum number of shared memory segments, in pages
  #kernel.shmall = $shmall
 
  kernel.sem = 250 256000 32 4096
!EOF
fi
 
# Make sure Physical Log fit in rootdbs
# Physical Log might be increased bigger than rootdbs for performance reason
# reset TAPEDEV to /dev/null so that ontape -s can finish quickly
# for physical log modification
cp -p $INFORMIXDIR/etc/onconfig.cms $INFORMIXDIR/etc/onconfig.cms.sv
cp -p $INFORMIXDIR/etc/onconfig.cms $INFORMIXDIR/etc/onconfig.cms.old
sed -e "/^PHYSFILE/s/PHYSFILE.*/PHYSFILE 50000/" \
    -e "/^TAPEDEV/s/TAPEDEV.*/TAPEDEV \/dev\/null/" \
    -e "/^TAPEBLK/s/TAPEBLK.*/TAPEBLK 4096/" \
    -e "/^LTAPEBLK/s/LTAPEBLK.*/LTAPEBLK 4096/" \
    -e "/^IFX_FOLDVIEW/s/IFX_FOLDVIEW.*/IFX_FOLDVIEW 1/" \
    -e "/^FULL_DISK_INIT/s/.*/FULL_DISK_INIT 1/" \
    -e "/^DBSERVERALIASES/s/.*/DBSERVERALIASES oacms_ol,cms_net,cms_${shortname}/" \
    $INFORMIXDIR/etc/onconfig.cms.old > $INFORMIXDIR/etc/onconfig.cms
oninit -ivy
if [ $? -ne 0 ]; then
  printf "`date` Initializing Informix failed\n" | tee -a $LOGFILE
  err_exit 1
fi
# give ids a little time to initialize before checking if it is online
integer cnt=0
  while true
  do
    onstat -m | grep sysadmin | grep successfully > /dev/null
    if [ $? -ne 0 ]; then
      sleep 5
      cnt=$cnt+1
    else
      break
    fi
    # Timeout
    if [ $cnt -eq 30 ]; then
      printf "`date` IDS did not initialize properly\n" | tee -a $LOGFILE
      err_exit 1
    fi
done
 
printf "`date` Initializing Informix IDS successfully finished\n" | tee -a $LOGFILE
 
printf "`date` Creating CMS dbspaces started\n" | tee -a $LOGFILE
#
# For Solaris:
# Creating dbspaces on boot disk s7
# onstat -d shows size in pages
# onspaces using KB as unit
#
# Partition       Size           Name
# 0               22GB           root          /
# 1               8GB            swap
# 2               full_disk      backup
# 3               10GB           unassigned    /cms
# 4               26GB           var           /var
# 5               200GB          unassigned    /storage
# 6               32GB           home          /home
# 7               rest_of_disk   unassigned    Informix
# 8 (x86)         1 cyl (~16MB)  boot          boot loader (start from 0)
#
# For Linux:
# Creating dbspaces on boot disk s11
#
# Partition       Size           System ID
# 1               600MB          Linux(0x83)   /boot
# 2               10GB           Linux(0x83)   /
# 3               10GB           Linux(0x83)   /cms
# 4               total-1-2-3    Linux(0x0f)   extended
# 5               8GB            swap (0x82)   swap
# 6               190000MB       Linux(0x83)   /storage
# 7               32GB           Linux(0x83)   /export/home
# 8               26624MB        Linux(0x83)   /var
# 9               16GB           Linux(0x83)   /tmp
# 10              12224MB        Linux(0x83)   /opt
# 11              rest_of_disk   Linux(0x83)   Informix
 
if [ "`uname`" = SunOS ]; then
  # get number of disk sectors on boot disk s7
  sec=`prtvtoc $datadisk | grep "     7     " | awk '{print $5}'`
  # $sec*512: bytes
  # disk size in KB
  dsize=$sec/2
else
  # For Linux use sfdisk
  # Linux uses 1K block from sfdisk
  dsize=`sfdisk -s $infdev`
fi
printf "data disk $infdev size: ${dsize}KB\n" >> $LOGFILE
 
# rootdbs size is defined in $INFORMIXDIR/etc/onconfig.cms
# 256000 KB for CMS R16
rootdbs=`grep ^ROOTSIZE $INFORMIXDIR/etc/onconfig.cms | awk '{print $2}'`
offset=$rootdbs
# 640M physdbs
# log files cannot be created on dbspaces of big page
# phydbs page size is still 2K
physdbs=655360
onspaces -c -d physdbs -p $datadisk -o $offset -s $physdbs
if [ $? -ne 0 ]; then
  printf "onspaces -c -d physdbs -p $datadisk -o $offset -s $physdbs failed\n" \
        | tee -a $LOGFILE
  err_exit 1
fi
 
# 128MB logdbs
logdbs=131072
offset=$offset+$physdbs
onspaces -c -d logdbs -p $datadisk -o $offset -s $logdbs
if [ $? -ne 0 ]; then
  printf "onspaces -c -d logdbs -p $datadisk -o $offset -s $logdbs failed\n" \
        | tee -a $LOGFILE
  err_exit 1
fi
 
# 5GB dbtemp (need to test)
# for small testing/demo system (less than 25GB data disk) 15% for dbtemp
if [ $dsize -lt 26214400 ]; then
  dbtemp=$dsize/100*15/${pagesz}*${pagesz}
else
  dbtemp=5242880
fi
offset=$offset+$logdbs
onspaces -c -d dbtemp -k $pagesz -p $datadisk -o $offset -s $dbtemp
if [ $? -ne 0 ]; then
  printf "onspaces -c -d dbtemp -k $pagesz -p $datadisk -o $offset -s $dbtemp failed\n" \
        | tee -a $LOGFILE
  err_exit 1
fi
 
# The rest on s7 assign to cmsdbs
offset=$offset+$dbtemp
dsize=$dsize-$offset
# wi00939992. Leave 1GB unused
# This is for binary db backup. For small/demo system no need to waste 1GB
if [ $dsize -gt 26214400 ]; then
  dsize=$dsize-1048576
fi
# chun size must be multiple of page size (8K)
# i=19/8*8 then i=16
dsize=$dsize/${pagesz}*${pagesz}
onspaces -c -d cmsdbs -k $pagesz -p $datadisk -o $offset -s $dsize
if [ $? -ne 0 ]; then
  printf "onspaces -c -d cmsdbs -p $datadisk -o $offset -s $dsize failed\n" \
        | tee -a $LOGFILE
  err_exit 1
fi
 
#
# Move physical and logical logs to physdbs and logdbs
#
 
# Change physical log to physdbs
# Using onstat -d to find free space in physdbs
# Using onstat -l to display physical and logical logs information
physdbs=`onstat -d | grep "  2      2  " | awk '{print $6}'`
# convert from page to KB
physdbs=${physdbs}*${logpgsz}
onparams -p -s $physdbs -d physdbs -y
if [ $? -ne 0 ]; then
  printf "onparams -p -s $physdbs -d physdbs -y failed\n" | tee -a $LOGFILE
  err_exit 1
fi
 
# The physical log has been modified. Do a full archive
ontape -s >> $LOGFILE
 
# switch logical log to logdbs
# add logical logs to logdbs
# onparams will change onconfig.cms LOGFILES value to match
# number of logs added by onparams
# keep number of logs same as before so that no need to modify
# onconfig.cms when we have to run onini -i
integer i=0 logsize lognum=3
logdbs=`onstat -d | grep "  3      3  " | awk '{print $6}'`
logsize=${logdbs}/${lognum}*${logpgsz}
while (((i=$i+1)<$lognum))
do
  onparams -a -d logdbs -s $logsize
  if [ $? -ne 0 ]; then
    printf "onparams -a -d logdbs -s $logsize failed\n" | tee -a $LOGFILE
    err_exit 1
  fi
done
# Round up remainder pages to the last log file
# number of pages
lognum=$lognum-1
logsize=logdbs-logsize/2*${lognum}
# last log file in KB
logsize=logsize*2
onparams -a -d logdbs -s $logsize
if [ $? -ne 0 ]; then
  printf "onparams -a -d logdbs -s $logsize failed\n" | tee -a $LOGFILE
  err_exit 1
fi
 
#
# Drop logical logs in rootdbs
#
 
# Move current logical log to the next one
# Past the first 3 located in rootdbs
onmode -l; onmode -l; onmode -l
# Force a checkpoint that flushes buffers to disk
onmode -c
# Drop logs 1, 2, and 3
i=0
while (((i=$i+1)<4))
do
  onparams -d -l $i -y
  if [ $? -ne 0 ]; then
    printf "onparams -d -l $i -y failed\n" | tee -a $LOGFILE
    err_exit 1
  fi
done
 
# add disks for VMware CMS
if [ "$VMware" = "true" ]; then
  add_disks
fi
 
# Logical log files have been pre-dropped
# In order to delete them from the log list and reuse the space
# need a level 0 archives for all non-temp dbspaces
ontape -s >> $LOGFILE
printf "`date` Creating CMS dbspaces successfully finished\n" | tee -a $LOGFILE
 
printf "`date` Configuring tape drive to `printf $cmstape | sed '/\\\/s/\\\//g'`\n" \
        | tee -a $LOGFILE
# You can change the values of parameters for ontape while the database
# server is online. The change takes effect immediately
# Change the TAPEDEV parameter or the LTAPEDEV parameter to /dev/null,
# You must use the ON-Monitor utility to make this change
# while the database server is online
cp -p $INFORMIXDIR/etc/onconfig.cms $INFORMIXDIR/etc/onconfig.cms.old
sed -e "/^TAPEDEV/s/TAPEDEV.*/TAPEDEV $cmstape/" \
    $INFORMIXDIR/etc/onconfig.cms.old > $INFORMIXDIR/etc/onconfig.cms
rm -rf $INFORMIXDIR/etc/onconfig.cms.old
 
# IDS 11.50 by default schedules update statistics daily
# Since CMS already runs update statistics
# Disable automatic statistics updating
printf "`date` Disabling IDS Automatic Statistics Updating\n" | tee -a $LOGFILE
su - informix -c "
. /opt/informix/bin/setenv
dbaccess sysadmin << !EOF
update ph_task set tk_enable='f' where tk_name='Auto Update Statistics Evaluation';
!EOF" >> $LOGFILE 2>&1
if [ $? -ne 0 ]; then
  printf "Disabling IDS Automatic Statistics Updating failed\n" | tee -a $LOGFILE
  err_exit 1
fi
printf "`date` Disabling IDS Automatic Statistics Updating successfully finished\n"\
      | tee -a $LOGFILE
 
printf "`date` Creating CMS database successfully finished\n\n" | tee -a $LOGFILE