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

View File

@ -14,36 +14,17 @@
[Unit] [Unit]
Description=System Logging Service Description=System Logging Service
Requires=var-run.mount syslog.target klogd.service Requires=var-run.mount syslog.target
After=var-run.mount After=var-run.mount
Before=syslog.target klogd.service Before=syslog.target
OnFailure=systemd-kmsg-syslogd.service 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. # Now systemd include the further dependency rules and
# It will be automatically updated as well as the content # Service section. This include will be automatically
# of the file to which the link points to. # updated depending on the configuration.
# #
.include /etc/alternatives/syslog.service .include /run/systemd/syslog.core
[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
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View File

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