Dr. Werner Fink 2011-08-19 11:56:35 +00:00 committed by Git OBS Bridge
parent 31acae921d
commit f532ab9dc0
3 changed files with 81 additions and 67 deletions

View File

@ -6,34 +6,50 @@
#
# Description:
#
# Write out syslog.service and if required klogd.service depending
# on the configuration found in /etc/sysconfig/syslog. Also check
# if network target is required with this we do not required the
# earlysyslog hack anymore. Based on the /etc/init.d/syslog script
# as well as on the /etc/init.d/earlysyslog wrapper script.
# Write out syslog.core and if required enable klogd.service
# depending on the configuration found in /etc/sysconfig/syslog.
# Also check if network target is required with this we do not
# required the earlysyslog hack anymore.
# Based on the /etc/init.d/syslog SysV init boot script as well
# as on the /etc/init.d/earlysyslog wrapper script.
#
# Author: Werner Fink
# Please send feedback to http://www.suse.de/feedback
#
umask 0022
test -s /etc/sysconfig/syslog && . /etc/sysconfig/syslog
for pkg-config in /usr/bin/pkg-config /bin/pkg-config; do
test -x $pkg-config && break
pkg-config=
done
BINDIR=/sbin
RUN_PATH=/run/systemd/system
: ${SBINDIR:=/sbin}
: ${RUN_PATH:=/run/systemd}
: ${SYSUNITDIR:=/lib/systemd/system}
: ${SYSCONFDIR:=/etc/systemd/system}
if test -s /etc/sysconfig/syslog ; then
CORE=$RUN_PATH/syslog.core
test -s $CORE -a $CORE -nt /etc/sysconfig/syslog && exit 0
. /etc/sysconfig/syslog
else
SYSLOG_DAEMON=rsyslogd
fi
#
# Danger Robinson: do not touch anything if a System logger
# is running under the control of systemd its self!
#
if test -d /sys/fs/cgroup/systemd/system/syslog.service -o \
-d /sys/fs/cgroup/systemd/system/klogd.service
then
/bin/logger -i -p daemon.warn -t ${0##*/} \
'Stop syslog.service before reloading the daemons!'
exit 1
fi
#
# Update $SYSLOG_DAEMON if not up-to-date
#
if test -z "$SYSLOG_DAEMON" -o ! -x "$BINDIR/$SYSLOG_DAEMON" ; then
if test -z "$SYSLOG_DAEMON" -o ! -x "$SBINDIR/$SYSLOG_DAEMON" ; then
for SYSLOG_DAEMON in rsyslogd syslog-ng syslogd ; do
test -x "$BINDIR/$SYSLOG_DAEMON" && break
test -x "$SBINDIR/$SYSLOG_DAEMON" && break
done
fi
@ -133,8 +149,8 @@ rsyslogd)
params="$SYSLOGD_PARAMS"
esac
syslog_bin=${BINDIR}/$syslog
klog_bin=${BINDIR}/klogd
syslog_bin=${SBINDIR}/$syslog
klog_bin=${SBINDIR}/klogd
test -s ${config} || exit 1
test -x ${syslog_bin} || exit 1
@ -156,24 +172,22 @@ fi
test "$start_klogd" = no && klogd=
#
# Create a temporary file for syslog.service
# Create a temporary file for syslog.core
#
trap 'rm -f "$service"' EXIT
service=$(/bin/mktemp $RUN_PATH/syslog.XXXXXXXX) || exit 1
(/bin/cat > $service)<<-EOF
# Warning: Do not edit as this service file has been and will be
# autogenerated by $0
[Unit]
Description=System Logging Service
Requires=var-run.mount ${network:+$network }syslog.target${klogd:+ $klogd}
After=var-run.mount${network:+ $network}
Before=syslog.target${klogd:+ $klogd}
OnFailure=systemd-kmsg-syslogd.service
tmpcore=$(/bin/mktemp $RUN_PATH/syslog.XXXXXXXX) || exit 1
(/bin/cat > $tmpcore)<<-EOF
# Warning: Do not edit as this file has been and will be autogenerated
# by $0
${network:+Requires=$network}
${network:+After=$network}
${klogd:+Requires=$klogd}
${klogd:+Before=$klogd}
[Service]
Type=forking
Sockets=syslog.socket
PIDFile=/var/run/${syslog_bin##*/}.pid
Sockets=syslog.socket
StandardOutput=null
ExecStartPre=/bin/systemctl stop systemd-kmsg-syslogd.service
ExecStartPre=-$socksdir/addsockets
@ -233,8 +247,8 @@ syslog-ng)
done >> $socks
echo -n '"' >> $socks
EOF
echo "Environment=ADDITIONAL_SOCKET=" >>$service
echo "EnvironmentFile=-$socks" 1>>$service
echo "Environment=ADDITIONAL_SOCKET=" >>$tmpcore
echo "EnvironmentFile=-$socks" 1>>$tmpcore
params="${params:+$params }\$ADDITIONAL_SOCKET"
esac
chmod u+x ${socksdir#/var}/addsockets
@ -245,7 +259,7 @@ chmod u+x ${socksdir#/var}/addsockets
# messages back to systemd as the creator of the system logging socket
# and we would get a message loop.
#
exec 3>&1 1>>$service
exec 3>&1 1>>$tmpcore
echo "ExecStart=$syslog_bin $params"
if test "$start_klogd" != no ; then
echo "ExecReload=/bin/systemctl kill --signal=TSTP klogd.service"
@ -256,8 +270,6 @@ if test "$start_klogd" != no ; then
echo "ExecReload=/bin/systemctl kill --signal=USR2 klogd.service"
fi
echo
echo "[Install]"
echo "WantedBy=multi-user.target"
exec 1>&3 3>&-
#
@ -274,14 +286,32 @@ fi
#
# Now enable the service(s) for multi-user target
#
test -d $SYSCONFDIR/multi-user.target.wants/ || mkdir -p $SYSCONFDIR/multi-user.target.wants
/bin/mv $tmpcore $CORE
/bin/mv $service $RUN_PATH/syslog.service
/bin/ln -sf $RUN_PATH/syslog.service $SYSCONFDIR/multi-user.target.wants/
if test ! -d $SYSCONFDIR/multi-user.target.wants/ ; then
/bin/mkdir -p $SYSCONFDIR/multi-user.target.wants
fi
syslogserv=$SYSUNITDIR/syslog.service
enableserv=$SYSCONFDIR/multi-user.target.wants/syslog.service
if test ! -h $enableserv ; then
/bin/rm -f $enableserv
/bin/ln -sf $syslogserv $enableserv
fi
klogserv=$SYSUNITDIR/klogd.service
enableserv=$SYSCONFDIR/multi-user.target.wants/klogd.service
disablserv=$SYSCONFDIR/klogd.service
if test "$start_klogd" != no -a -x ${klog_bin} ; then
/bin/ln -sf $klogserv $SYSCONFDIR/multi-user.target.wants/
if test ! -h $enableserv ; then
/bin/rm -f $enableserv
/bin/ln -sf $klogserv $enableserv
fi
else
if test ! -h $disablserv ; then
/bin/rm -f $disablserv
/bin/ln -sf /dev/null $disablserv
fi
fi
#
@ -289,7 +319,7 @@ fi
#
for service in /etc/init.d/*.d/*syslog ; do
test -h $service || continue
rm -f $service
/bin/rm -f $service
done
#

View File

@ -14,36 +14,17 @@
[Unit]
Description=System Logging Service
Requires=var-run.mount syslog.target klogd.service
Requires=var-run.mount syslog.target
After=var-run.mount
Before=syslog.target klogd.service
Before=syslog.target
OnFailure=systemd-kmsg-syslogd.service
#
# Include further dependency rules with this symblic link.
# It will be automatically updated as well as the content
# of the file to which the link points to.
#
.include /etc/alternatives/syslog.depends
#
# Include now the Service section with this symblic link.
# It will be automatically updated as well as the content
# of the file to which the link points to.
# Now systemd include the further dependency rules and
# Service section. This include will be automatically
# updated depending on the configuration.
#
.include /etc/alternatives/syslog.service
[Service]
Type=forking
Sockets=syslog.socket
PIDFile=/var/run/syslog-ng.pid
StandardOutput=null
ExecStartPre=/bin/systemctl stop systemd-kmsg-syslogd.service
ExecStartPre=-/var/run/syslog-ng/addsockets
ExecStart=/sbin/syslog-ng
ExecReload=/bin/systemctl kill --signal=TSTP klogd.service
ExecReload=/sbin/killproc -p /var/run/syslog-ng.pid -HUP /sbin/syslog-ng
ExecReload=/bin/systemctl kill --signal=CONT klogd.service
ExecReload=/bin/systemctl kill --signal=USR2 klogd.service
.include /run/systemd/syslog.core
[Install]
WantedBy=multi-user.target

View File

@ -39,6 +39,7 @@ Source5: syslog.xml
Source6: syslog.8
Source7: syslog-service-generator
Source8: klogd.service
Source9: syslog.service
Patch0: sysklogd-1.4.1.dif
Patch1: sysklogd-1.4.1-dgram.patch
Patch2: sysklogd-1.4.1-sparc.patch
@ -152,7 +153,7 @@ mv sample-s390.conf sample.conf
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
mkdir -p $RPM_BUILD_ROOT/%{_mandir}/man{5,8}
mkdir -p $RPM_BUILD_ROOT/var/adm/fillup-templates
mkdir -p $RPM_BUILD_ROOT%{sysdsysunitdir}-generator
mkdir -p $RPM_BUILD_ROOT%{sysdsysunitdir}-generators
mkdir -p $RPM_BUILD_ROOT%{sysdsysunitdir}
mkdir -p -m 0755 $RPM_BUILD_ROOT/var/run/rsyslog
mkdir -p -m 0755 $RPM_BUILD_ROOT/var/run/syslog-ng
@ -165,8 +166,9 @@ mv sample-s390.conf sample.conf
install -d $RPM_BUILD_ROOT/%{omc_svcdir}/
install -m 600 %{SOURCE5} $RPM_BUILD_ROOT/%{omc_svcdir}/
install -m 644 %{SOURCE6} $RPM_BUILD_ROOT/%{_mandir}/man8/syslog.8
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT%{sysdsysunitdir}-generator/
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT%{sysdsysunitdir}-generators/
install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{sysdsysunitdir}/
install -m 644 %{SOURCE9} $RPM_BUILD_ROOT%{sysdsysunitdir}/
%ifarch s390 s390x
sed 's/^KERNEL_LOGLEVEL=1/KERNEL_LOGLEVEL=7/' %{SOURCE2} \
> $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.syslog
@ -251,12 +253,13 @@ fi
%config /etc/init.d/syslog
%config /etc/init.d/earlysyslog
%config %{sysdsysunitdir}/klogd.service
%config %{sysdsysunitdir}/syslog.service
%doc %{_mandir}/man8/klogd.8.gz
%doc %{_mandir}/man8/sysklogd.8.gz
%doc %{_mandir}/man8/syslog.8.gz
/sbin/klogd
/sbin/rcsyslog
%attr(0744,root,root) %{sysdsysunitdir}-generator/syslog-service-generator
%attr(0744,root,root) %{sysdsysunitdir}-generators/syslog-service-generator
%attr(0755,root,root) %dir %ghost /var/run/rsyslog/
%attr(0755,root,root) %dir %ghost /var/run/syslog-ng/
%{omc_svcdir}/syslog.xml