![Joseph Kogut](/assets/img/avatar_default.png)
EarlyOOM daemon for triggering Linux OOM killer before running out of memory, avoiding situations where the machine becomes unresponsive from out of control swapping. Some desktop distributions are installing and enabling this daemon by default to prevent unresponsive machines in OOM scenarios. https://fedoraproject.org/wiki/Changes/EnableEarlyoom Signed-off-by: Joseph Kogut <joseph.kogut@gmail.com> [yann.morin.1998@free.fr: two spaces in hash file] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
50 lines
729 B
Bash
50 lines
729 B
Bash
#!/bin/sh
|
|
|
|
DAEMON="earlyoom"
|
|
PIDFILE="/var/run/$DAEMON.pid"
|
|
|
|
EARLYOOM_ARGS=""
|
|
|
|
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
|
|
|
|
start() {
|
|
printf() 'Starting %s: ' "$DAEMON"
|
|
start-stop-daemon -b -m -S -q -p "$PIDFILE" -x "/bin/$DAEMON" \
|
|
-- $EARLYOOM_ARGS
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
stop() {
|
|
printf 'Stopping %s: ' "$DAEMON"
|
|
start-stop-daemon -K -q -p "$PIDFILE"
|
|
status=$?
|
|
if [ "$status" -eq 0 ]; then
|
|
rm -f "$PIDFILE"
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
return "$status"
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
start
|
|
}
|
|
|
|
case "$1" in
|
|
start|stop|restart)
|
|
"$1";;
|
|
reload)
|
|
restart;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|reload}"
|
|
exit 1
|
|
esac
|