Accepting request 177928 from home:marc_schuetz:branches:Base:System
- Converted rc file to systemd unit file. - Fixed a bug where the accounting file wasn't reopened after logrotate, because force-reload isn't implemented. OBS-URL: https://build.opensuse.org/request/show/177928 OBS-URL: https://build.opensuse.org/package/show/Base:System/acct?expand=0&rev=28
This commit is contained in:
parent
3401375a1a
commit
194484d226
@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jun 6 14:53:49 UTC 2013 - schuetzm@gmx.net
|
||||||
|
|
||||||
|
- Converted rc file to systemd unit file.
|
||||||
|
- Fixed a bug where the accounting file wasn't reopened after
|
||||||
|
logrotate, because force-reload isn't implemented.
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Apr 26 08:06:16 UTC 2013 - mmeister@suse.com
|
Fri Apr 26 08:06:16 UTC 2013 - mmeister@suse.com
|
||||||
|
|
||||||
|
11
acct.service
Normal file
11
acct.service
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Process accounting
|
||||||
|
Documentation=man:accton(8)
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=true
|
||||||
|
ExecStartPre=/bin/sh -c 'test -e /var/account/pacct || touch /var/account/pacct'
|
||||||
|
ExecStart=/usr/sbin/accton /var/account/pacct
|
||||||
|
ExecStop=/usr/sbin/accton off
|
||||||
|
|
24
acct.spec
24
acct.spec
@ -21,12 +21,15 @@ PreReq: %insserv_prereq %fillup_prereq fileutils %install_info_prereq
|
|||||||
Version: 6.5.5
|
Version: 6.5.5
|
||||||
Release: 0
|
Release: 0
|
||||||
Source: %{name}-%{version}.tar.gz
|
Source: %{name}-%{version}.tar.gz
|
||||||
Source1: rc.acct
|
Source1: acct.service
|
||||||
Source2: logrotate.acct
|
Source2: logrotate.acct
|
||||||
BuildRequires: libtool
|
BuildRequires: libtool
|
||||||
|
BuildRequires: systemd
|
||||||
|
%{?systemd_requires}
|
||||||
%if %suse_version >= 1230
|
%if %suse_version >= 1230
|
||||||
BuildRequires: makeinfo
|
BuildRequires: makeinfo
|
||||||
%endif
|
%endif
|
||||||
|
Requires: logrotate
|
||||||
Patch: %{name}-hz.patch
|
Patch: %{name}-hz.patch
|
||||||
Patch2: %{name}-info.patch
|
Patch2: %{name}-info.patch
|
||||||
Patch3: %{name}-ac.patch
|
Patch3: %{name}-ac.patch
|
||||||
@ -61,31 +64,34 @@ make %{?_smp_mflags} CC="%{__cc}" CXX="%{__cxx}"
|
|||||||
|
|
||||||
%install
|
%install
|
||||||
make DESTDIR=$RPM_BUILD_ROOT install CC="%{__cc}" CXX="%{__cxx}"
|
make DESTDIR=$RPM_BUILD_ROOT install CC="%{__cc}" CXX="%{__cxx}"
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/etc/{init.d,logrotate.d}
|
install -d -m 755 $RPM_BUILD_ROOT/etc/logrotate.d
|
||||||
install -m 755 %{S:1} $RPM_BUILD_ROOT/etc/init.d/acct
|
install -d -m 755 $RPM_BUILD_ROOT/%{_unitdir}
|
||||||
|
install -m 644 %{S:1} $RPM_BUILD_ROOT/%{_unitdir}/acct.service
|
||||||
install -m 644 %{S:2} $RPM_BUILD_ROOT/etc/logrotate.d/acct
|
install -m 644 %{S:2} $RPM_BUILD_ROOT/etc/logrotate.d/acct
|
||||||
install -d -m 755 $RPM_BUILD_ROOT/var/account/
|
install -d -m 755 $RPM_BUILD_ROOT/var/account/
|
||||||
touch $RPM_BUILD_ROOT/var/account/pacct
|
touch $RPM_BUILD_ROOT/var/account/pacct
|
||||||
chmod 600 $RPM_BUILD_ROOT/var/account/pacct
|
chmod 600 $RPM_BUILD_ROOT/var/account/pacct
|
||||||
cd $RPM_BUILD_ROOT/usr/sbin/
|
cd $RPM_BUILD_ROOT/usr/sbin/
|
||||||
ln -sf ../../etc/init.d/acct rcacct
|
ln -sf service rcacct
|
||||||
rm -f $RPM_BUILD_ROOT/usr/bin/last
|
rm -f $RPM_BUILD_ROOT/usr/bin/last
|
||||||
rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/last.1*
|
rm -f $RPM_BUILD_ROOT/%{_mandir}/man1/last.1*
|
||||||
|
|
||||||
|
%pre
|
||||||
|
%service_add_pre acct.service
|
||||||
|
|
||||||
%post
|
%post
|
||||||
%{fillup_and_insserv acct}
|
|
||||||
echo "Creating /var/account/pacct"
|
echo "Creating /var/account/pacct"
|
||||||
touch var/account/pacct
|
touch var/account/pacct
|
||||||
chmod 600 var/account/pacct
|
chmod 600 var/account/pacct
|
||||||
%install_info --info-dir=%{_infodir} %{_infodir}/accounting.info.gz
|
%install_info --info-dir=%{_infodir} %{_infodir}/accounting.info.gz
|
||||||
|
%service_add_post acct.service
|
||||||
|
|
||||||
%preun
|
%preun
|
||||||
%stop_on_removal acct
|
%service_del_preun acct.service
|
||||||
|
|
||||||
%postun
|
%postun
|
||||||
%install_info_delete --info-dir=%{_infodir} %{_infodir}/accounting.info.gz
|
%install_info_delete --info-dir=%{_infodir} %{_infodir}/accounting.info.gz
|
||||||
%restart_on_update acct
|
%service_del_postun acct.service
|
||||||
%{insserv_cleanup}
|
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%defattr(-, root, root)
|
%defattr(-, root, root)
|
||||||
@ -97,9 +103,9 @@ chmod 600 var/account/pacct
|
|||||||
%dir /var/account
|
%dir /var/account
|
||||||
%attr(600, root, root) %ghost /var/account/pacct
|
%attr(600, root, root) %ghost /var/account/pacct
|
||||||
%config /etc/logrotate.d/acct
|
%config /etc/logrotate.d/acct
|
||||||
%config /etc/init.d/acct
|
|
||||||
/usr/bin/ac
|
/usr/bin/ac
|
||||||
/usr/bin/lastcomm
|
/usr/bin/lastcomm
|
||||||
/usr/sbin/*
|
/usr/sbin/*
|
||||||
|
%{_unitdir}/acct.service
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
missingok
|
missingok
|
||||||
create 640 root root
|
create 640 root root
|
||||||
postrotate
|
postrotate
|
||||||
/etc/init.d/acct force-reload
|
/usr/bin/systemctl restart acct.service
|
||||||
endscript
|
endscript
|
||||||
}
|
}
|
||||||
|
|
||||||
|
137
rc.acct
137
rc.acct
@ -1,137 +0,0 @@
|
|||||||
#! /bin/sh
|
|
||||||
# Copyright (c) 1995-2001 SuSE GmbH Nuernberg, Germany.
|
|
||||||
# Copyright (c) 2002 SuSE Linux AG, Nuernberg, Germany
|
|
||||||
#
|
|
||||||
# Author: Petr Blaha <pblaha@suse.cz>
|
|
||||||
#
|
|
||||||
# init.d/acct
|
|
||||||
#
|
|
||||||
# and symbolic its link
|
|
||||||
#
|
|
||||||
# /sbin/rcacct
|
|
||||||
#
|
|
||||||
# System startup script for process accounting
|
|
||||||
#
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: acct
|
|
||||||
# Required-Start: $syslog $local_fs
|
|
||||||
# Required-Stop: $syslog $local_fs
|
|
||||||
# Default-Start: 2 3 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Description: Process accounting
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
|
|
||||||
ACCT_BIN=/usr/sbin/accton
|
|
||||||
test -x $ACCT_BIN || exit 5
|
|
||||||
|
|
||||||
|
|
||||||
# Shell functions sourced from /etc/rc.status:
|
|
||||||
# rc_check check and set local and overall rc status
|
|
||||||
# rc_status check and set local and overall rc status
|
|
||||||
# rc_status -v ditto but be verbose in local rc status
|
|
||||||
# rc_status -v -r ditto and clear the local rc status
|
|
||||||
# rc_failed set local and overall rc status to failed
|
|
||||||
# rc_failed <num> set local and overall rc status to <num>
|
|
||||||
# rc_reset clear local rc status (overall remains)
|
|
||||||
# rc_exit exit appropriate to overall rc status
|
|
||||||
. /etc/rc.status
|
|
||||||
|
|
||||||
# First reset status of this service
|
|
||||||
rc_reset
|
|
||||||
|
|
||||||
# Return values acc. to LSB for all commands but status:
|
|
||||||
# 0 - success
|
|
||||||
# 1 - generic or unspecified error
|
|
||||||
# 2 - invalid or excess argument(s)
|
|
||||||
# 3 - unimplemented feature (e.g. "reload")
|
|
||||||
# 4 - insufficient privilege
|
|
||||||
# 5 - program is not installed
|
|
||||||
# 6 - program is not configured
|
|
||||||
# 7 - program is not running
|
|
||||||
#
|
|
||||||
# Note that starting an already running service, stopping
|
|
||||||
# or restarting a not-running service as well as the restart
|
|
||||||
# with force-reload (in case signalling is not supported) are
|
|
||||||
# considered a success.
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
echo -n "Starting process accounting"
|
|
||||||
test -e /var/account/pacct || touch /var/account/pacct
|
|
||||||
|
|
||||||
## Start process accounting
|
|
||||||
$ACCT_BIN /var/account/pacct && touch /var/run/accton
|
|
||||||
|
|
||||||
# Remember status and be verbose
|
|
||||||
rc_status -v
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
echo -n "Shutting down process accounting"
|
|
||||||
## Stop daemon with killproc(8) and if this fails
|
|
||||||
## set echo the echo return value.
|
|
||||||
$ACCT_BIN && rm -f /var/run/accton
|
|
||||||
|
|
||||||
# Remember status and be verbose
|
|
||||||
rc_status -v
|
|
||||||
;;
|
|
||||||
try-restart)
|
|
||||||
## Stop the service and if this succeeds (i.e. the
|
|
||||||
## service was running before), start it again.
|
|
||||||
## Note: try-restart is not (yet) part of LSB (as of 0.7.5)
|
|
||||||
$0 status > /dev/null
|
|
||||||
if test $? = 0; then
|
|
||||||
$0 restart
|
|
||||||
else
|
|
||||||
rc_reset
|
|
||||||
fi
|
|
||||||
# Remember status and be quiet
|
|
||||||
rc_status
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
## Stop the service and regardless of whether it was
|
|
||||||
## running or not, start it again.
|
|
||||||
$0 stop
|
|
||||||
$0 start
|
|
||||||
|
|
||||||
# Remember status and be quiet
|
|
||||||
rc_status
|
|
||||||
;;
|
|
||||||
force-reload)
|
|
||||||
## Signal the daemon to reload its config. Most daemons
|
|
||||||
## do this on signal 1 (SIGHUP).
|
|
||||||
## If it does not support it, restart.
|
|
||||||
$0 try-restart
|
|
||||||
|
|
||||||
# Remember status and be quiet
|
|
||||||
rc_status
|
|
||||||
;;
|
|
||||||
reload)
|
|
||||||
## Like force-reload, but if daemon does not support
|
|
||||||
## signalling, do nothing (!)
|
|
||||||
|
|
||||||
rc_failed 3
|
|
||||||
rc_status -v
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
echo -n "Status of process accounting: "
|
|
||||||
|
|
||||||
# Status has a slightly different for the status command:
|
|
||||||
# 0 - service running
|
|
||||||
# 1 - service dead, but /var/run/ pid file exists
|
|
||||||
# 2 - service dead, but /var/lock/ lock file exists
|
|
||||||
# 3 - service not running
|
|
||||||
|
|
||||||
if test -e /var/run/accton ; then echo "OK"
|
|
||||||
else
|
|
||||||
echo "No"
|
|
||||||
exit 3
|
|
||||||
fi
|
|
||||||
#rc_status
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
rc_exit
|
|
Loading…
Reference in New Issue
Block a user