2014-11-19 14:42:19 +00:00
|
|
|
#!/bin/bash
|
2007-10-26 22:44:33 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
2008-04-04 18:33:40 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
2008-05-09 02:20:19 +00:00
|
|
|
#=head1 syslog
|
|
|
|
#=head2 syslog command that setsup the syslogd for MS, SV and nodes.
|
|
|
|
# On MS, it makes sure all the xCAT messages goes to /var/log/messages file,
|
|
|
|
# it enables syslogd receving logs from remote machies.
|
|
|
|
# On MS, it sends all the messages to MS,
|
|
|
|
# it enables syslogd receving logs from remote nodes.
|
|
|
|
# On node, it sends all the messages its master.
|
|
|
|
# Input: none, it takes the following environment variables:
|
|
|
|
# OSVER: possible values are sles10, fedora8, redhat5, aix etc.
|
|
|
|
#=cut
|
2008-04-04 18:33:40 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2014-07-23 06:16:48 +00:00
|
|
|
if [ "$(uname -s|tr 'A-Z' 'a-z')" = "linux" ];then
|
|
|
|
str_dir_name=`dirname $0`
|
|
|
|
. $str_dir_name/xcatlib.sh
|
|
|
|
fi
|
2014-06-10 15:54:31 +00:00
|
|
|
|
2008-05-09 02:20:19 +00:00
|
|
|
master=$MASTER
|
|
|
|
conf_file="/etc/syslog.conf"
|
|
|
|
sysconfig="/etc/sysconfig/syslog"
|
|
|
|
init="/etc/init.d/syslog"
|
|
|
|
ng=0
|
|
|
|
isSN=0
|
|
|
|
isLinux=1
|
2008-08-08 20:56:02 +00:00
|
|
|
isRsyslog=0
|
|
|
|
isC3=0
|
2014-06-10 15:54:31 +00:00
|
|
|
#systemdEnabled=0
|
2011-09-06 02:43:12 +00:00
|
|
|
# pmatch determines if 1st argument string is matched by 2nd argument pattern
|
|
|
|
|
|
|
|
pmatch ()
|
|
|
|
{
|
|
|
|
case $1 in
|
|
|
|
$2) return 0;; # zero return code means string matched by pattern
|
|
|
|
esac
|
|
|
|
|
|
|
|
return 1 # non-zero return code means string not matched by pattern
|
|
|
|
}
|
|
|
|
|
2011-10-06 17:45:08 +00:00
|
|
|
# is_lsb_ubuntu exit status indicates whether system appears to be Ubuntu.
|
|
|
|
# Using required /etc/lsb-release file, instead of optional lsb_release command.
|
|
|
|
|
|
|
|
is_lsb_ubuntu ()
|
|
|
|
{
|
|
|
|
awk '
|
|
|
|
(match($0, "^[ \t]*DISTRIB_ID=") == 1) { # A DISTRIB_ID line
|
|
|
|
id = substr($0, RLENGTH + 1) # Save its value
|
|
|
|
}
|
|
|
|
|
|
|
|
END {
|
|
|
|
# Examine last DISTRIB_ID value to see if Ubuntu indicated
|
|
|
|
|
|
|
|
if (match(id, "^(Ubuntu|\"Ubuntu\")[ \t]*$") == 1) {
|
|
|
|
exit 0 # Ubuntu
|
|
|
|
}
|
|
|
|
exit 1 # Not Ubuntu
|
|
|
|
}
|
|
|
|
|
|
|
|
' /etc/lsb-release >/dev/null 2>&1
|
|
|
|
|
|
|
|
# Routine exit status is exit status of the last command -- the awk script.
|
|
|
|
#
|
|
|
|
# Note: if /etc/lsb-release does not exist, the exit status indicates
|
|
|
|
# failure (not Ubuntu), which is the correct outcome.
|
|
|
|
}
|
|
|
|
|
2008-08-08 20:56:02 +00:00
|
|
|
config_Rsyslog_C3()
|
|
|
|
{
|
|
|
|
isReceiving=0
|
|
|
|
isLocal=$1
|
|
|
|
|
2011-03-01 15:42:57 +00:00
|
|
|
if [ -f /etc/xCATMN ] || [ $isSN -eq 1 ]
|
2008-08-08 20:56:02 +00:00
|
|
|
then
|
|
|
|
isReceiving=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f $2.XCATORIG ]; then
|
|
|
|
cp -f $2 $2.XCATORIG
|
2010-07-07 08:34:54 +00:00
|
|
|
else
|
|
|
|
cat $2 > $2.XCATORIG
|
2008-08-08 20:56:02 +00:00
|
|
|
fi
|
|
|
|
|
2009-09-02 07:08:23 +00:00
|
|
|
grep "xCAT settings" $conf_file 2>&1 1> /dev/null
|
2010-06-30 19:20:15 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
2010-07-07 08:34:54 +00:00
|
|
|
sed "/# xCAT settings/,$ d" $2 >/tmp/sed.tmp
|
|
|
|
cat /tmp/sed.tmp >$2
|
2010-06-30 19:20:15 +00:00
|
|
|
fi
|
|
|
|
|
2008-08-08 20:56:02 +00:00
|
|
|
echo "# xCAT settings" >> $2
|
2010-06-30 19:20:15 +00:00
|
|
|
#enable to receive remote logging
|
|
|
|
if [ $isReceiving -eq 1 ]; then
|
2012-04-16 19:40:18 +00:00
|
|
|
sed 's/^\#\(\s\)*\$ModLoad\(\s\)*imudp/\$ModLoad imudp/' $2 >/tmp/sed.tmp
|
2010-07-07 08:34:54 +00:00
|
|
|
cat /tmp/sed.tmp >$2
|
|
|
|
sed 's/^\#\(\s\)*\$UDPServerRun/\$UDPServerRun/' $2 >/tmp/sed.tmp
|
|
|
|
cat /tmp/sed.tmp >$2
|
2010-06-30 19:20:15 +00:00
|
|
|
fi
|
2008-08-08 20:56:02 +00:00
|
|
|
|
2010-06-30 19:20:15 +00:00
|
|
|
#enable to send the logging to master
|
|
|
|
if [ $isLocal -eq 1 ]; then
|
2012-04-17 13:01:34 +00:00
|
|
|
#enable the MN to log all the logs from CN and MN itself
|
|
|
|
sed 's/\(^[^\#].*\/var\/log\/messages\)/\#\1/g' $2 >/tmp/sed.tmp
|
|
|
|
cat /tmp/sed.tmp >$2
|
|
|
|
echo "*.debug /var/log/messages" >> $2
|
|
|
|
touch /var/log/messages
|
2010-06-30 19:20:15 +00:00
|
|
|
else
|
2010-07-07 08:34:54 +00:00
|
|
|
sed 's/^\(\*\..*\)/\#\1/' $2 >/tmp/sed.tmp
|
|
|
|
cat /tmp/sed.tmp >$2
|
|
|
|
sed 's/^\(news\|local7\|mail\|authpriv\|cron\|kern\)\./\#\1\./' $2 >/tmp/sed.tmp
|
|
|
|
cat /tmp/sed.tmp >$2
|
2008-08-08 20:56:02 +00:00
|
|
|
echo "*.* @$master" >> $2
|
2010-06-30 19:20:15 +00:00
|
|
|
fi
|
2008-08-08 20:56:02 +00:00
|
|
|
}
|
2008-05-09 02:20:19 +00:00
|
|
|
|
2014-10-23 13:20:13 +00:00
|
|
|
# This sets up rsyslog 8.x, different from the previous rsyslog versions.
|
|
|
|
# Instead of updating /etc/rsyslog.conf for forwarding to a remote host,
|
|
|
|
# You update /etc/rsyslog.d/remote.conf. The /etc/sysconfig/rsyslog file does not exist.
|
|
|
|
# This is only for Linux, since AIX does not use rsyslog. It ships its own syslog in an lpp,
|
|
|
|
# at least at the time of this code being written
|
2014-10-22 11:42:42 +00:00
|
|
|
|
|
|
|
config_rsyslog_V8()
|
|
|
|
{
|
2014-10-23 13:20:13 +00:00
|
|
|
|
|
|
|
goLocal=0;
|
|
|
|
conf_file="/etc/rsyslog.conf"
|
2014-10-22 11:42:42 +00:00
|
|
|
remoteconf="/etc/rsyslog.d/remote.conf"
|
|
|
|
|
2014-10-23 13:20:13 +00:00
|
|
|
# If this is a Management Node or Service Node, then it will be receiving syslog entries from the
|
|
|
|
# compute nodes. Management Node is receiving from Service Nodes and possibly compute nodes.
|
|
|
|
# They will all be put in /var/log/messages
|
|
|
|
# For the service node, if site table svloglocal is set then we will keep the logs on the servicenode
|
|
|
|
# and not forward to the Management Node.
|
2014-10-22 11:42:42 +00:00
|
|
|
|
2014-10-23 13:20:13 +00:00
|
|
|
#now handling where the logs go, if goLocal=1 then log local, if not forward to MN
|
|
|
|
if [ -f /etc/xCATMN ]; then
|
|
|
|
goLocal=1
|
|
|
|
else
|
|
|
|
# check to see if service node should forward of keep logs
|
|
|
|
if [ $isSN -eq 1 ]; then
|
|
|
|
if [ -n "$SVLOGLOCAL" ] && [ $SVLOGLOCAL -eq 1 ]; then
|
|
|
|
goLocal=1
|
|
|
|
fi
|
|
|
|
fi
|
2014-10-22 11:42:42 +00:00
|
|
|
fi
|
|
|
|
|
2014-10-23 13:20:13 +00:00
|
|
|
if [ $goLocal -eq 1 ]; then
|
|
|
|
#logging is local, do not forward
|
|
|
|
#making sure all the messages goes to /var/log/messages
|
|
|
|
touch /var/log/messages
|
|
|
|
# backup rsyslog.conf
|
|
|
|
if [ ! -f $conf_file.XCATORIG ]; then
|
|
|
|
cp -f $conf_file $conf_file.XCATORIG
|
|
|
|
fi
|
|
|
|
|
|
|
|
grep "xCAT settings" $conf_file 2>&1 1> /dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
sed "/# xCAT settings/,$ d" $conf_file >/tmp/sed.tmp
|
|
|
|
cat /tmp/sed.tmp >$conf_file
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "# xCAT settings" >> $conf_file
|
|
|
|
echo "*.debug /var/log/messages" >> $conf_file
|
|
|
|
else
|
|
|
|
# not logging local, forward logging
|
|
|
|
# backup the existing remote.conf file from the install
|
|
|
|
if [ ! -f $remoteconf.XCATORIG ]; then
|
|
|
|
cp -f $remoteconf $remoteconf.XCATORIG
|
|
|
|
fi
|
|
|
|
# check if already an entry by xCAT. If so, we need to replace it
|
|
|
|
grep "xCAT settings" $remoteconf 2>&1 1> /dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
2014-10-22 11:42:42 +00:00
|
|
|
sed "/# xCAT settings/,$ d" $remoteconf >/tmp/sed.tmp
|
|
|
|
cat /tmp/sed.tmp >$remoteconf
|
2014-10-23 13:20:13 +00:00
|
|
|
fi
|
2014-10-22 11:42:42 +00:00
|
|
|
|
2014-10-23 13:20:13 +00:00
|
|
|
# add xCAT entries
|
|
|
|
echo "# xCAT settings" >> $remoteconf
|
|
|
|
echo "*.* @$master" >> $remoteconf
|
|
|
|
fi
|
|
|
|
# restart syslog ( could be service or systemctl call depending on the OS)
|
|
|
|
restartservice syslog
|
2014-10-22 11:42:42 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-05-09 02:20:19 +00:00
|
|
|
#echo "NTYPE=$NTYPE,OSVER=$OSVER,OSTYPE=$OSTYPE"
|
|
|
|
|
2013-12-19 12:26:24 +00:00
|
|
|
if [ "$NTYPE" = service ]; then
|
2008-05-09 02:20:19 +00:00
|
|
|
isSN=1
|
|
|
|
fi
|
|
|
|
|
2014-06-10 15:54:31 +00:00
|
|
|
#if [ -e /etc/systemd ]; then
|
|
|
|
# systemdEnabled=1
|
|
|
|
#fi
|
2014-01-03 07:50:47 +00:00
|
|
|
|
2014-10-22 11:42:42 +00:00
|
|
|
# check if this is rsyslog version 8, setup is different no matter what OS.
|
|
|
|
# We only update the /etc/rsyslog.d/remote.conf file to point to the xcatmaster.
|
|
|
|
# Do not even touch rsyslog.conf
|
|
|
|
# There is no /etc/sysconfig/rsyslog file, so we use rsyslogd -v to get the version
|
|
|
|
SYSLOGPROD=`rsyslogd -v | grep rsyslogd |awk {'print $1'}`
|
|
|
|
SYSLOGVER=`rsyslogd -v | grep rsyslogd |awk {'print $2'}`
|
|
|
|
if ( pmatch $SYSLOGPROD "*rsyslogd*" ) && ( pmatch $SYSLOGVER "8*" ); then
|
|
|
|
config_rsyslog_V8
|
|
|
|
#keep a record
|
|
|
|
logger -t xCAT -p local4.info "Install: rsyslog version 8 setup"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2011-09-06 02:43:12 +00:00
|
|
|
if [ "$(uname -s)" = "Linux" ]; then
|
2013-01-07 07:35:23 +00:00
|
|
|
if ( pmatch $OSVER "fedora*" ) || ( pmatch $OSVER "rhels5*" ) || ( pmatch $OSVER "rhel6*" ) || ( pmatch $OSVER "rhels6*" ) || [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ] || ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then
|
2008-05-09 02:20:19 +00:00
|
|
|
if [ -e /etc/rsyslog.conf ]; then
|
|
|
|
conf_file="/etc/rsyslog.conf"
|
|
|
|
sysconfig="/etc/sysconfig/rsyslog"
|
2014-06-10 15:54:31 +00:00
|
|
|
#init="/etc/init.d/rsyslog"
|
|
|
|
#if [ $systemdEnabled -eq 1 ]; then
|
|
|
|
# init="rsyslog"
|
|
|
|
#fi
|
2008-08-08 20:56:02 +00:00
|
|
|
isRsyslog=1
|
2013-01-07 07:35:23 +00:00
|
|
|
if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then
|
2012-04-16 19:40:18 +00:00
|
|
|
sysconfig="/etc/default/rsyslog"
|
|
|
|
fi
|
2008-05-09 02:20:19 +00:00
|
|
|
fi
|
|
|
|
else
|
2011-09-06 02:43:12 +00:00
|
|
|
if ( pmatch $OSVER "sles*" ) || ( pmatch $OSVER "suse*" ) || [ -f /etc/SuSE-release ]; then
|
2008-05-09 02:20:19 +00:00
|
|
|
#find out which syslog is used for SLES, syslog or syslog-ng
|
|
|
|
result=`grep "^SYSLOG_DAEMON=" $sysconfig 2>&1`
|
2011-09-06 02:43:12 +00:00
|
|
|
if ( pmatch $result "*syslog-ng*" ); then
|
2009-03-25 20:26:16 +00:00
|
|
|
conf_file="/etc/syslog-ng/syslog-ng.conf"
|
2008-05-09 02:20:19 +00:00
|
|
|
ng=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
sysconfig= #AIX does not have this file
|
|
|
|
isLinux=0;
|
|
|
|
fi
|
|
|
|
|
|
|
|
#echo "isSN=$isSN, isLinux=$isLinux, ng=$ng"
|
|
|
|
#echo "sysconfig=$sysconfig, confgile=$conf_file"
|
|
|
|
|
2008-08-08 20:56:02 +00:00
|
|
|
|
|
|
|
|
2014-10-22 11:42:42 +00:00
|
|
|
#handle sysconfig file to make remote logging possible
|
2011-09-06 02:43:12 +00:00
|
|
|
if [ $isLinux -eq 1 ] && [ -e $sysconfig ]; then
|
|
|
|
if [ ! -f "$sysconfig.XCATORIG" ]; then
|
2008-05-09 02:20:19 +00:00
|
|
|
cp -f $sysconfig $sysconfig.XCATORIG
|
|
|
|
fi
|
2008-08-08 20:56:02 +00:00
|
|
|
|
2014-10-22 11:42:42 +00:00
|
|
|
#check if it is ryslog version 3, it has totally different settings in /etc/syslog.conf
|
2008-08-08 20:56:02 +00:00
|
|
|
if [ $isRsyslog -eq 1 ]; then
|
2010-10-05 18:13:18 +00:00
|
|
|
grep "SYSLOGD_OPTIONS" $sysconfig | grep -e "[\-c 3|\-c3|\-c4|\-c 4]" 2>&1 1> /dev/null
|
2008-08-08 20:56:02 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
isC3=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
#no need to change anything for rsyslog version 3 for /etc/sysconf/rsyslog
|
|
|
|
if [ $isC3 -eq 0 ]; then
|
|
|
|
if [ -f /etc/xCATMN ]; then
|
|
|
|
#on MN: make the syslogd be able to receive remote logs
|
2009-03-25 20:26:16 +00:00
|
|
|
awk '{if($0 ~ /^SYSLOGD_OPTIONS=|^SYSLOGD_PARAMS=/) {
|
2010-03-02 13:31:04 +00:00
|
|
|
if ($0 !~ /-r/) {sub(/-/, "-r -", $0)}
|
|
|
|
if (($0 !~ /-m0/) && ($0 !~/-m 0/)) { sub(/-/, "-m 0 -", $0)}
|
2008-05-09 02:20:19 +00:00
|
|
|
print $0}
|
|
|
|
else { print $0}}' $sysconfig > $sysconfig.tmp
|
2008-08-08 20:56:02 +00:00
|
|
|
else
|
|
|
|
if [ $isSN -eq 1 ]; then
|
|
|
|
#on SN: make the syslog be able to receive and forward remote logs
|
2009-03-25 20:26:16 +00:00
|
|
|
awk '{if($0 ~ /^SYSLOGD_OPTIONS=|^SYSLOGD_PARAMS=/) {
|
2010-03-02 13:31:04 +00:00
|
|
|
if ($0 !~ /-r/) {sub(/-/, "-r -", $0)}
|
|
|
|
if ($0 !~ /-h/) {sub(/-/, "-h -", $0)}
|
|
|
|
if (($0 !~ /-m0/) && ($0 !~/-m 0/)) { sub(/-/, "-m 0 -", $0)}
|
2008-05-09 02:20:19 +00:00
|
|
|
print $0}
|
|
|
|
else { print $0}}' $sysconfig > $sysconfig.tmp
|
2008-08-08 20:56:02 +00:00
|
|
|
else
|
|
|
|
##turn off the time marker on all
|
2009-03-25 20:26:16 +00:00
|
|
|
awk '{if($0 ~ /^SYSLOGD_OPTIONS=|^SYSLOGD_PARAMS=/) {
|
2010-03-02 13:31:04 +00:00
|
|
|
if (($0 !~ /-m0/) && ($0 !~/-m 0/)) { sub(/-/, "-m 0 -", $0)}
|
2008-05-09 02:20:19 +00:00
|
|
|
print $0}
|
|
|
|
else {print $0}}' $sysconfig > $sysconfig.tmp
|
2008-08-08 20:56:02 +00:00
|
|
|
fi
|
2008-05-09 02:20:19 +00:00
|
|
|
fi
|
2008-08-08 20:56:02 +00:00
|
|
|
mv -f $sysconfig.tmp $sysconfig
|
2008-05-09 02:20:19 +00:00
|
|
|
fi
|
|
|
|
fi
|
2008-04-04 18:33:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
#syslog-ng has different way of enabling log forwarding
|
2009-03-25 20:26:16 +00:00
|
|
|
if [ $ng -eq 1 ]; then
|
|
|
|
if [ $isSN -eq 1 -o -f /etc/xCATMN ]; then
|
|
|
|
if [ ! -f $conf_file.XCATORIG ]; then
|
|
|
|
cp -f $conf_file $conf_file.XCATORIG
|
|
|
|
fi
|
2010-07-07 08:34:54 +00:00
|
|
|
sed 's/#udp(ip("0.0.0.0/udp(ip("0.0.0.0/' $conf_file >/tmp/sed.tmp
|
|
|
|
cat /tmp/sed.tmp >$conf_file
|
2008-05-09 02:20:19 +00:00
|
|
|
fi
|
|
|
|
fi
|
2008-04-04 18:33:40 +00:00
|
|
|
|
2008-08-08 20:56:02 +00:00
|
|
|
|
|
|
|
|
2008-04-04 18:33:40 +00:00
|
|
|
#now handling where the logs go
|
2008-05-09 02:20:19 +00:00
|
|
|
goLocal=0;
|
|
|
|
if [ -f /etc/xCATMN ]; then
|
|
|
|
goLocal=1
|
|
|
|
else
|
|
|
|
if [ $isSN -eq 1 ]; then
|
2012-03-01 09:03:55 +00:00
|
|
|
if [ -n "$SVLOGLOCAL" ] && [ $SVLOGLOCAL -eq 1 ]; then
|
2008-05-09 02:20:19 +00:00
|
|
|
goLocal=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2008-08-08 20:56:02 +00:00
|
|
|
if [ $isC3 -eq 1 ]; then
|
|
|
|
config_Rsyslog_C3 $goLocal $conf_file
|
|
|
|
else
|
|
|
|
if [ $goLocal -eq 1 ]; then
|
|
|
|
#making sure all the messages goes to /var/log/messages
|
|
|
|
touch /var/log/messages
|
|
|
|
if [ $ng -eq 0 ]; then
|
|
|
|
if [ ! -f $conf_file.XCATORIG ]; then
|
|
|
|
cp -f $conf_file $conf_file.XCATORIG
|
|
|
|
fi
|
2008-05-09 02:20:19 +00:00
|
|
|
|
2009-09-02 07:08:23 +00:00
|
|
|
grep "xCAT settings" $conf_file 2>&1 1> /dev/null
|
2010-06-30 19:20:15 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
2010-07-07 08:34:54 +00:00
|
|
|
sed "/# xCAT settings/,$ d" $conf_file >/tmp/sed.tmp
|
|
|
|
cat /tmp/sed.tmp >$conf_file
|
2010-06-30 19:20:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $isLinux -eq 0 ]; then # aix
|
2008-08-08 20:56:02 +00:00
|
|
|
echo "# xCAT settings" >> $conf_file
|
|
|
|
echo "*.debug /var/log/messages rotate 1024K files 5" >> $conf_file
|
2008-05-09 02:20:19 +00:00
|
|
|
fi
|
2013-05-29 12:14:13 +00:00
|
|
|
else
|
|
|
|
# enable the settings that will log to local files in syslog-ng
|
|
|
|
sed -i '/destination messages/s/^#*//' $conf_file
|
|
|
|
sed -i '/destination(messages)/s/^#*//' $conf_file
|
|
|
|
sed -i '/destination warn/s/^#*//' $conf_file
|
|
|
|
sed -i '/destination(warn)/s/^#*//' $conf_file
|
2008-05-09 02:20:19 +00:00
|
|
|
fi
|
2011-09-28 19:14:42 +00:00
|
|
|
|
|
|
|
#Ubuntu doesn't have sysconfig
|
|
|
|
# so configuring the MN to receive UDP connections here.
|
2013-01-07 07:35:23 +00:00
|
|
|
if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then
|
2011-09-28 19:14:42 +00:00
|
|
|
egrep \('^\$UDPServerRun 514'\|'^\$ModLoad imudp'\) $conf_file > /dev/null 2>&1;
|
|
|
|
if [ $? -eq 1 ]; then
|
|
|
|
echo "\$ModLoad imudp" >> $conf_file;
|
|
|
|
echo "\$UDPServerRun 514" >> $conf_file;
|
|
|
|
fi
|
|
|
|
fi
|
2008-05-09 02:20:19 +00:00
|
|
|
else
|
2008-08-08 20:56:02 +00:00
|
|
|
#now make the syslogd fowarding the messages to the the master
|
|
|
|
if [ $ng -eq 1 ]; then
|
|
|
|
if [ ! -f $conf_file.XCATORIG ]; then
|
|
|
|
cp -f $conf_file $conf_file.XCATORIG
|
|
|
|
fi
|
2009-09-02 07:08:23 +00:00
|
|
|
grep "xCAT settings" $conf_file 2>&1 1> /dev/null
|
2010-06-30 19:20:15 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
2010-07-07 08:34:54 +00:00
|
|
|
sed "/# xCAT settings/,$ d" $conf_file >/tmp/sed.tmp
|
2014-01-03 07:50:47 +00:00
|
|
|
cat /tmp/sed.tmp >$conf_file
|
2008-08-08 20:56:02 +00:00
|
|
|
fi
|
2010-06-30 19:20:15 +00:00
|
|
|
echo "# xCAT settings" >> $conf_file
|
|
|
|
echo "destination loghost { udp(\"$master\"); };" >> $conf_file
|
|
|
|
echo 'log { source(src); destination(loghost); };' >> $conf_file
|
2012-06-21 20:05:22 +00:00
|
|
|
|
|
|
|
# remove the settings that will log to local files
|
|
|
|
sed -i '/destination messages/s/^/#/' $conf_file
|
|
|
|
sed -i '/destination(messages)/s/^/#/' $conf_file
|
|
|
|
sed -i '/destination warn/s/^/#/' $conf_file
|
|
|
|
sed -i '/destination(warn)/s/^/#/' $conf_file
|
2008-05-09 02:20:19 +00:00
|
|
|
else
|
2008-08-08 20:56:02 +00:00
|
|
|
if [ -f $conf_file.XCATORIG ]; then
|
|
|
|
rm -f $conf_file
|
|
|
|
else
|
|
|
|
mv -f $conf_file $conf_file.XCATORIG
|
|
|
|
fi
|
|
|
|
echo "# xCAT settings" > $conf_file
|
|
|
|
if [ $isLinux -eq 0 ]; then
|
|
|
|
echo "*.debug @$master" >> $conf_file
|
|
|
|
else
|
2013-01-07 07:35:23 +00:00
|
|
|
if ( pmatch $OSVER "ubuntu*" ) || ( is_lsb_ubuntu ) || ( pmatch $OSVER "debian*" ); then
|
2011-09-28 19:14:42 +00:00
|
|
|
echo "\$ModLoad imuxsock" >> $conf_file
|
|
|
|
echo "*.* @$master" >> $conf_file
|
|
|
|
else
|
|
|
|
echo "*.* @$master" >> $conf_file
|
|
|
|
fi
|
2008-08-08 20:56:02 +00:00
|
|
|
fi
|
2008-06-27 16:07:41 +00:00
|
|
|
fi
|
2008-05-09 02:20:19 +00:00
|
|
|
fi
|
|
|
|
fi
|
2008-04-04 18:33:40 +00:00
|
|
|
|
|
|
|
#restart the syslog daemon to take the new conf file settings
|
2008-05-09 02:20:19 +00:00
|
|
|
if [ $isLinux -eq 0 ]; then
|
2008-10-08 15:24:04 +00:00
|
|
|
PARSE_SRC_STATE="-e1d;s/.* \([a-zA-Z0-9]*\)$/\1/"
|
|
|
|
state=$(LC_ALL=C lssrc -s syslogd | LC_ALL=C sed "$PARSE_SRC_STATE")
|
2011-09-06 02:43:12 +00:00
|
|
|
if [ -n "$state" ] && [ "$state" = "active" ]; then
|
2008-10-08 15:24:04 +00:00
|
|
|
stopsrc -s syslogd
|
|
|
|
fi
|
2008-11-22 04:03:24 +00:00
|
|
|
|
|
|
|
#wait for syslogd to fully started
|
|
|
|
RETRY_LIMIT=30 # number of 2 second retry intervals (60 second total)
|
2011-09-06 02:43:12 +00:00
|
|
|
i=$RETRY_LIMIT
|
2008-11-22 04:03:24 +00:00
|
|
|
while :
|
|
|
|
do
|
|
|
|
ret=`LC_ALL=C startsrc -s syslogd 2>&1`
|
2011-09-06 02:43:12 +00:00
|
|
|
if ( pmatch $ret "*PID*" ); then
|
2008-11-22 04:03:24 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
i=$((i - 1))
|
2011-09-06 02:43:12 +00:00
|
|
|
if [ $i -gt 0 ]; then
|
2008-11-22 04:03:24 +00:00
|
|
|
sleep 2
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2014-01-03 07:50:47 +00:00
|
|
|
else
|
2014-06-10 15:54:31 +00:00
|
|
|
#if [ $systemdEnabled -eq 1 ]; then
|
|
|
|
# systemctl restart $init.service
|
|
|
|
#else
|
|
|
|
# $init restart
|
|
|
|
#fi
|
|
|
|
restartservice syslog
|
2008-05-09 02:20:19 +00:00
|
|
|
fi
|
2008-04-04 18:33:40 +00:00
|
|
|
|
|
|
|
#keep a record
|
2012-05-15 03:41:53 +00:00
|
|
|
logger -t xCAT -p local4.info "Install: syslog setup"
|
2007-10-26 22:44:33 +00:00
|
|
|
exit 0
|