commit 68be68b530f959ca5af1f1d7c2709fe0ff5f6de9 Author: Arkadiusz MiĆkiewicz <ar...@maven.pl> Date: Fri Dec 8 10:47:42 2023 +0100
Rel 1 earlyoom.init | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ earlyoom.spec | 28 ++++++++++++++++--- 2 files changed, 111 insertions(+), 3 deletions(-) --- diff --git a/earlyoom.spec b/earlyoom.spec index 9b12998..45513e3 100644 --- a/earlyoom.spec +++ b/earlyoom.spec @@ -1,12 +1,17 @@ Summary: Early OOM Daemon for Linux Name: earlyoom Version: 1.7 -Release: 0.1 +Release: 1 License: MIT URL: https://github.com/rfjakob/earlyoom Source0: https://github.com/rfjakob/earlyoom/archive/v%{version}/%{name}-%{version}.tar.gz # Source0-md5: 9c567930c60b2ccdc536951b005d413d Source1: %{name}.conf +Source2: %{name}.init +BuildRequires: pandoc +Requires(post,preun): /sbin/chkconfig +Requires: systemd-units +BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) %description User-space OOM killer daemon that can avoid the system going into the @@ -19,11 +24,13 @@ Percentages are configured through the configuration file. %prep %setup -q cp -f %{SOURCE1} %{name}.default -sed -e '/systemctl/d' -i Makefile +sed -i -e '/systemctl/d' Makefile +sed -i -e 's#/default/#/sysconfig/#g' Makefile earlyoom.service.in %build %{__make} \ VERSION=%{version} \ + BINDIR=/bin \ PREFIX=%{_prefix} \ SYSCONFDIR=%{_sysconfdir} \ SYSTEMDUNITDIR=%{systemdunitdir} @@ -31,16 +38,30 @@ sed -e '/systemctl/d' -i Makefile %install rm -rf $RPM_BUILD_ROOT +install -d $RPM_BUILD_ROOT/etc/rc.d/init.d + %{__make} install \ + PREFIX=%{_prefix} \ + BINDIR=/bin \ + SYSCONFDIR=%{_sysconfdir} \ + SYSTEMDUNITDIR=%{systemdunitdir} \ DESTDIR=$RPM_BUILD_ROOT +cp -a %{SOURCE2} $RPM_BUILD_ROOT/etc/rc.d/init.d/%{name} + %clean rm -rf $RPM_BUILD_ROOT %post +/sbin/chkconfig --add %{name} +%service %{name} restart %systemd_post %{name}.service %preun +if [ "$1" = "0" ]; then + %service %{name} stop + /sbin/chkconfig --del %{name} +fi %systemd_preun %{name}.service %postun @@ -49,8 +70,9 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(644,root,root,755) %doc README.md +%attr(754,root,root) /etc/rc.d/init.d/%{name} %attr(755,root,root) %{_bindir}/%{name} %{systemdunitdir}/%{name}.service %{_mandir}/man1/%{name}.* -%config(noreplace) %{_sysconfdir}/default/%{name} +%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/%{name} diff --git a/earlyoom.init b/earlyoom.init new file mode 100644 index 0000000..d594a3d --- /dev/null +++ b/earlyoom.init @@ -0,0 +1,86 @@ +#!/bin/sh +# +# earlyoom earlyoom Early OOM Killer +# +# chkconfig: 2345 10 90 +# +# description: earlyoom A userspace service that will kill the largest process (by VmRSS residential size) when free RAM drops below 10%. +# +# processname: earlyoom +# config: /etc/sysconfig/earlyoom +# pidfile: /var/run/earlyoom.pid +# + +# Source function library +. /etc/rc.d/init.d/functions + +# Get service config - may override defaults +[ -f /etc/sysconfig/earlyoom ] && . /etc/sysconfig/earlyoom + +pidfile="/var/run/earlyoom.pid" + +start() { + # Check if the service is already running? + if [ -f /var/lock/subsys/earlyoom ]; then + msg_already_running "earlyoom" + return + fi + + msg_starting "earlyoom" + daemon --fork --makepid /usr/bin/earlyoom $EARLYOOM_ARGS + RETVAL=$? + [ $RETVAL -eq 0 ] && touch /var/lock/subsys/earlyoom +} + +stop() { + if [ ! -f /var/lock/subsys/earlyoom ]; then + msg_not_running "earlyoom" + return + fi + + # Stop daemons. + msg_stopping "earlyoom" + killproc earlyoom + rm -f /var/lock/subsys/earlyoom +} + +condrestart() { + if [ ! -f /var/lock/subsys/earlyoom ]; then + msg_not_running "earlyoom" + RETVAL=$1 + return + fi + + stop + start +} + +RETVAL=0 +# See how we were called. +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + try-restart) + condrestart 0 + ;; + force-reload) + condrestart 7 + ;; + status) + status earlyoom + RETVAL=$? + ;; + *) + msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" + exit 3 +esac + +exit $RETVAL ================================================================ ---- gitweb: http://git.pld-linux.org/gitweb.cgi/packages/earlyoom.git/commitdiff/68be68b530f959ca5af1f1d7c2709fe0ff5f6de9 _______________________________________________ pld-cvs-commit mailing list pld-cvs-commit@lists.pld-linux.org http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit