Собственно имеется скрипт syslog-ng, в нем есть команды:
echo "# Start the next generation system logger." >> /etc/rc.d/rc.M
echo "if [ -x /etc/rc.d/rc.syslog-ng ]; then" >> /etc/rc.d/rc.M
echo " . /etc/rc.d/rc.syslog-ng start " >> /etc/rc.d/rc.M
echo "fi" >> /etc/rc.d/rc.Mкоторые добавляются в скрипт rc.M.
Как сделать так, чтобы в случае неоднократного выполнении скрипта syslog-ng, он не добавлял лишний раз вышеописанные команды, если в скрипте rc.M уже имеется строка 'next generation system logger' ?
Сам скрипт приведен ниже
#! /bin/sh
# Install some packages
installpkg ./eventlog-0.2.7-i486-1gufo.tgz
installpkg ./syslog-ng-3.0.2-i486-1gufo.tgz
# Getting IP on eth0
IP=`ifconfig | grep 'inet ' | cut -f 2 -d ":" | cut -f 1 -d " " |grep '' -m 1`;
# Generating /etc/syslog-ng/syslog-ng.conf
cat << EOF > /etc/syslog-ng/syslog-ng.conf
@version:3.0
options { long_hostnames(off); flush_lines(0); };
source src { unix-stream("/dev/log"); internal(); };
source from_all { udp (ip($IP) port(514)); };
destination to_all { file ( "/var/log/HOSTS/\$HOST/\$HOST.log" perm(0666) dir_perm(0755) create_dirs(yes) ); };
destination authlog { file("/var/log/auth.log"); };
destination cron { file("/var/log/cron.log"); };
destination daemon { file("/var/log/daemon.log"); };
destination kern { file("/var/log/kern.log"); };
destination lpr { file("/var/log/lpr.log"); };
destination user { file("/var/log/user.log"); };
destination uucp { file("/var/log/uucp.log"); };
destination ppp { file("/var/log/ppp.log"); };
destination iptables { file("/var/log/iptables.log"); };
destination debug { file("/var/log/debug"); };
destination messages { file("/var/log/messages"); };
destination console { usertty("root"); };
destination console_all { file("/dev/tty12"); };
#destination loghost { udp("loghost" port(999)); };
destination xconsole { pipe("/dev/xconsole"); };
filter f_auth { facility(auth); };
filter f_authpriv { facility(auth, authpriv); };
filter f_syslog { not facility(authpriv, mail); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon); };
filter f_kern { facility(kern); };
filter f_lpr { facility(lpr); };
filter f_user { facility(user); };
filter f_uucp { facility(cron); };
filter f_ppp { facility(local2); };
filter f_debug { not facility(auth, authpriv, news, mail); };
filter f_messages { level(info..warn) and not facility(auth, authpriv, mail, news); };
filter f_emergency { level(emerg); };
filter f_info { level(info); };
filter f_notice { level(notice); };
filter f_warn { level(warn); };
filter f_crit { level(crit); };
filter f_err { level(err); };
filter iptables { level(debug); };
log { source(from_all); destination(to_all); };
log { source(src); filter(f_authpriv); destination(authlog); };
log { source(src); filter(f_cron); destination(cron); };
log { source(src); filter(f_daemon); destination(daemon); };
log { source(src); filter(f_kern); destination(kern); };
log { source(src); filter(f_lpr); destination(lpr); };
log { source(src); filter(f_user); destination(user); };
log { source(src); filter(f_uucp); destination(uucp); };
log { source(src); filter(f_debug); destination(debug); };
log { source(src); filter(f_messages); destination(messages); };
log { source(src); filter(f_emergency); destination(console); };
log { source(src); filter(f_ppp); destination(ppp); };
log { source(src); filter(iptables); destination(iptables); };
log { source(src); destination(console_all); };
EOF
cp ./rc.syslog-ng /etc/rc.d/rc.syslog-ng
chmod 755 /etc/rc.d/rc.syslog-ng
chmod 644 /etc/rc.d/rc.syslog
#cp ./rc.M /etc/rc.d/rc.M
#if cat /etc/rc.d/rc.M | grep 'next generation system logger'; then
echo "# Start the next generation system logger." >> /etc/rc.d/rc.M
echo "if [ -x /etc/rc.d/rc.syslog-ng -a -x /usr/sbin/syslog-ng -a -d /var/log ]; then" >> /etc/rc.d/rc.M
echo " . /etc/rc.d/rc.syslog-ng start " >> /etc/rc.d/rc.M
echo "fi" >> /etc/rc.d/rc.M
#fi
killall syslogd
killall syslog-ng
syslog-ng
#tar -zxvf ./Python-3.1.3.tgz
#cd ./Python-3.1.3
#./configure
