For more Information consult Using the Willeke Script Library.

The .sharedfunctions.sh file contains almost all Variables called by any menu or other script used in the Build Scripts.

The attempt is to set all the default variables we need here for initialization of all the build, menu and maintenance scripts. Changes should NOT be done to the .sharedfunctions.sh file except by the Directory Services TEAM

Overwriting Values#

Some variables may need to be customized for a given host installation, overriding defaults provided by the standard scripts. Since the changing the .sharedfunctions.sh can and eventually will overwrite .sharedfunctions.sh, customizations should not be written to that file. Instead, provide local configuration by creating a /usr/local/share/willeke/.sharedenv.sh.local file.

Local Variable File#

Should it be necessary to change a variable on a specific server,
	
touch  /usr/local/share/willeke/.sharedenv.sh.local
Edit the file and modify the specific variables. NOTE: File names are case sensitive!

All parameters that in the /usr/local/share/willeke/.sharedenv.sh.local file will override any variables defined in the .sharedfunctions.sh file.

Typical .sharedenv.sh#

Typical script content as implemented is shown below:
# SCRIPT: sharedfunctions.sh
# AUTHOR: jim@willeke.com
# DATE:   1/31/2009 10:45:29 AM
SHAREDENV_VER=11.4	# Script Version Number
# REV:    1.1.A 
# (Valid are A, B, D, T, Q, and P (For Alpha, Beta, Dev, Test, QA, and Production)
#
# PLATFORM: bash
#
# REQUIREMENTS:  OpenSSH is required for this shell script to work.
# The file is expected to be located at: /usr/local/share/willeke/
# The following MSUST Be Present:
# . /usr/local/share/willeke/.sharedfunctions.sh
# . /usr/local/share/willeke/.sharedenv.sh
# 
# PURPOSE: # Define variables we use so we do not have to do it again for every new script
#
# REV LIST:
#        DATE: DATE_of_REVISION
#        BY:   AUTHOR_of_MODIFICATION
#        MODIFICATION: Describe what was modified, new features, etc--
#
# 10/15/2002--Changed use of 'export' for readability
#             Change variable for e-mail address from $TO to $EMAIL_NOTIFY and $EMAIL_URGENT
#             Added production e-mail addresses to $EMAIL_NOTIFY and $EMAIL_URGENT
#             Added variable for sudo
# 12/6/2002-- Changed SERVERNAME to be based on value defined in ndsconfig, if available;
#              otherwise, SERVERNAME is based on uppercase version of HOSTNAME
# 1/22/2003-- Changed all references to dc=com to dc=net
#             Changed all references to OU=Servers to dc=svr
#             Added BaseDN and BaseDNdot to help downstream scripts with changes to base
#               tree structure
#             Improved handling of SERVERNAME on a bare box
# 2/21/2003-- Added settings for increasing memory for JRE (for servers running multiple
#              DirXML drivers)
# 2/25/2003-- Added variables to support ndscheck.sh
#             Changed syntax of export commands to make them more "compact"
# 3/18/2003-- Changed $ndscheckMaintFlag ndscheck.sh from /tmp/ndscheck.txt to
#              /tmp/nondscheck
#             Changed $SUDO to be blank if script is run as 'root'
# 6/25/2003-- Changed e-mail & pager notifications to distribution lists maintained by
#              InfoSec
# 8/11/2003-- Added $HostOS $HostOSVer for scripts to decide on platform-specific commands
# 8/21/2003-- "Allocate additional heap space for the JVM" enabled by default
# 8/22/2003-- Changed $SERVERNAME to truncate domain name, if present (Red Hat fix)
# 12/02/2003--Changed a lot for comaptibility with new Functions Definitions
# 12/30/2003--Changed loading of .ndsenv.local to not write to log file
# 1/9/2004 -- Updated to export all variables (some were missing)
# 10/07/2004 - added menupwd is where we launch menu from. So we know where are base dir is
# 7/29/2005 --Fixed a variable ($OSVersion) from f_gethostosversions that was not
#              being exported (so other functions looking for, say, Solaris 9, worked)
#             Changed ulimit to 8192 for open files
# 8/11/2005 --Populated $ndsUserHome
# 8/16/2005 --Added $mailer (defines binary to use for SMTP mail)
# 12/31/2007 8:19:21 AM - Generic items reformed.
#
# set -n   # Uncomment to check script syntax, without execution.
#          # NOTE: Do not forget to put the # comment back in or
#          #       the shell script will never execute!
# set -x   # Uncomment to debug this shell script
#
##########################################################
#         DEFINE SHARED FILES AND VARIABLES HERE
####################################################################
# We try to set all the default varibles we need here for initialization of scripts
# Changes should NOT be done except by the Directory Services TEAM
# Should it be necessary to change a varible on a specific server,
#	create  /usr/local/shared/.sharedenv.sh.local
# NOTE: File name should be cased as above!
# All parameters that are not dynmically set should be defiend in this file
####################################################################
# Requires that .sharedfunctions.sh be loaded before running
# We suggest that this be done in each script like:
# 
# if [ -f /usr/local/shared/.sharedenv.sh ]
# then
# 	. /usr/local/shared/.sharedenv.sh_functions
#  	. /usr/local/shared/.sharedenv.sh
# else
#   	printf "\nMissing /usr/local/shared/.sharedenv.sh -- cannot run!\n"
#   	exit 1
# fi
####################################################################
# User to be present on system
####################################################################
T_THIS_SCRIPT=$(basename $0)
homedirbase=/usr/local/share/willeke
COMPANYNAME=willeke
DOMAINNAME=willeke.com
EMAILDOMAIN=willeke.com
SUNGLEBAR="----------------------------------------------------------------------"
DOUBLEBAR="======================================================================"
####################################################################
#Make sure we have enough open files
####################################################################
f_setulimits 8192
es=$?;f_checkerror $es
####################################################################
# Configuration variables for Script Operation
####################################################################
prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
sbindir=${exec_prefix}/sbin
initdir=/etc/init.d
LOGDIR=/var/log
LOGFILE=$LOGDIR/shared.log
i_licensepath="../$COMPANYNAME/license"
SUPPORTED_OS="SunOS Linux"
export prefix exec_prefix bindir sbindir initdir httpclearport httptlsport LOGFILE i_licensepath SUPPORTED_OS
####################################################################
# Dib Size This is the default DIB size. We set it here as reading the DIB size
# Dynamically fails when a Tree is first created
####################################################################
DIBsize=838860800
export DIBsize
####################################################################
# Items to Check to see if the OS Is setup Right
#
####################################################################
minvarnds=34359738368
minvarndsbkup=34359738368
####################################################################
# Minimum cache we will allow 64MB = 67108864 bytes
# Maximum cache we will allow 1GB  = 1073741824 bytes
####################################################################
cacheMin=67108864
cacheMax=1073741824
export cacheMax
####################################################################
# imon Varibles
####################################################################
httpclearport=8389
httptlsport=8636
lockmask=14
dnsdomain=.svr.$DOMAINNAME
export httpclearport httptlsport lockmask dnsdomain

####################################################################
# menu Script variables
# menufile is the Menu Disply file
# menupwd is where we launch menu from
# THISBUILDVER - Version of the Custom Build
####################################################################
menufile="$PWD/menulist.txt"
xcommand=""
export menufile

####################################################################
# Host OS and platform variables
####################################################################
f_gethostname
f_gethostosversions
f_getXPG4grep
f_getmailer
#f_getdnshostname
export HOSTNAME DNSNAME HostOS HostOSVer HostOSArch OSVersion XPG4grep mailer
SERVERIP=""
f_gethostipaddress
f_getmemorystats
export SERVERIP availMEMb physMEMkb physMEMmb

######################################################################
# Set NDS items for  Admin, dib directory, tree name
######################################################################
NDSVER=
BaseDN="dc=$COMPANYNAME,dc=net"
BaseDNdot="dc=$COMPANYNAME.dc=net"
ADMIN="cn=admin,ou=Administration,$BaseDN"
ADMINDOT="cn=admin.ou=Administration.$BaseDNdot"
ServersOU="dc=svr,$BaseDN"
ServersOUdot="dc=svr.$BaseDNdot"
f_getndsservername
f_getndstreename
export BaseDN BaseDNdot ADMIN ADMINDOT ServersOU ServersOUdot SERVERNAME TREENAME tmp_errlog_file

####################################################################
# Important paths and tool locations
####################################################################
if [ -f $bindir/ndsconfig ]
then
	edirPATH=`$bindir/ndsconfig get n4u.server.vardir|awk -F"=" '{print $2}'`
  edirdibPATH=`$bindir/ndsconfig get n4u.nds.dibdir|awk -F"=" '{print $2}'`
  edirconfigDIR=`$bindir/ndsconfig get n4u.server.configdir|awk -F"=" '{print $2}'`
else
	edirPATH=""
  edirdibPATH=""
  edirconfigDIR=""
fi
LDAPTOOLS=/usr/ldaptools/bin
LDAPSEARCH=$LDAPTOOLS/ldapsearch
LDAPMODIFY=$LDAPTOOLS/ldapmodify
DATE="`date +%Y%m%d%H%M`"
export edirPATH edirdibPATH edirconfigDIR LDAPTOOLS LDAPSEARCH LDAPMODIFY DATE

####################################################################
# Set value for $SUDO only if we are running as non-root user
####################################################################
if [ `id | awk '{print $1}'|awk -F"=" '{print $2}'|awk -F"(" '{print $1}'` = 0 ]
then
	SUDO=""
else
  	SUDO=/usr/local/bin/sudo
fi
export SUDO

######################################################################
# Used to Set Misc Parameters int he environement
######################################################################
NTP1=time.$DOMAINNAME
export NTP1
######################################################################
# Used by ndsbackup.sh
######################################################################
# This is the primary location where items are backed up. Each 
# Application should build on this path as required
BACKUPDIR=/archive
bkupMountPoint=/archive
# Backup Host info. Remote hosts will need to share ssh keys &
# have same backup directory structure. Use space separated hostnames.
bkupHOSTS='null'
if [ -d /var/nds/dib ]
then 
   	availableBytesRequired=`expr \( \`( du -sk /var/nds/dib | cut -f1 ) 2>/dev/null\` - \`( du -sk /var/nds/dib/core | cut -f1 ) 2>/dev/null\` \) \* 17 / 10`
fi
# Also used by b1nds-OwnerPermsFix.sh
ndsGROUP=ndsgroup
ndsUSER=ndsuser
ndsUserHome=`cat /etc/passwd | grep ndsuser | cut -d: -f6`
localenvfile="/usr/local/shared/.sharedenv.sh.local"
# Following is used to check space available f_checkForSpaceOnFS()
TMP_SPACE=9
ROOT_SPACE=9
export BACKUPDIR bkupMountPoint bkupHOSTS availableBytesRequired ndsGROUP ndsUSER ndsUserHome localenvfile
######################################################################
# Set email Defaults here.
#Where to send e-mail notifications and pages to
######################################################################
EMAIL_NOTIFY="info@$EMAILDOMAIN"
EMAIL_NOTIFY="$EMAIL_NOTIFY"
export EMAIL_NOTIFY
# Include pager e-mail addresses for important (fatal) events to be sent
EMAIL_URGENT="info@$EMAILDOMAIN"
export EMAIL_URGENT

######################################################################
# Variables to allocate heap space for the JVM used for DirXML drivers.
# Make sure NOT to allocate more memory than the system has, or the
# drivers will force a core dump with ndsd.
# This setting only needs to be configured for systems hosting
# DirXML drivers.  These settings are in bytes.
######################################################################
DHOST_JVM_INITIAL_HEAP=104857600
DHOST_JVM_MAX_HEAP=419430400
DHOST_JVM_OPTIONS=-Xss1m
export DHOST_JVM_INITIAL_HEAP DHOST_JVM_MAX_HEAP DHOST_JVM_OPTIONS

######################################################################
# Define maintenance window (start/end time); ndscheck.sh will not process
# during this window.  In the form of "hhmmss".
# All ndsCheck Defaults set here
######################################################################
# Permanent log to keep 90 days worth of ndscheck status messages
ndscheckStatus=/var/nds/ndscheck.log
sMaintTime="010000"
eMaintTime="013000"
# File location to set flag -- ignores down condition during mainteance
# Integer value, skip x number of polls, up to maximum defined by $ndscheckMAX_STATUS_COUNT
ndscheckMaintFlag=/tmp/nondscheck
# Maximum polling internvals to ignore a down condition
ndscheckMAX_STATUS_COUNT=6
ndscheckAlertFile=/tmp/ndscheckAlert.tmp    # Temp file to keep track of what services are down from poll to poll
export ndscheckStatus sMaintTime eMaintTime ndscheckMaintFlag
######################################################################
# Check is local server environement file exists.
# $localenvfile  should be used to override the values in
# 	this file for specific server requirements
######################################################################
if [ -f $localenvfile ]
then
  	. $localenvfile
  	printf " Using $localenvfile\n"
else
    	printf " No $localenvfile found\n"
fi
# This will help in determing errors that could exist in this script.
f_write_and_log "SHAREDENV Version $SHAREDENV_VER loaded successfully"
######################################################################
# Need to clear any varibles not needed as this script is loaded within 
# other scripts.
######################################################################
unset T_THIS_SCRIPT
unset SHAREDENV_VER

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-7) was last changed on 31-Jan-2009 17:58 by jim