solana/net/scripts/install-earlyoom.sh

33 lines
773 B
Bash
Raw Normal View History

#!/usr/bin/env bash
set -ex
2018-08-07 16:16:11 -07:00
#
# Install EarlyOOM
#
[[ $(uname) = Linux ]] || exit 1
[[ $USER = root ]] || exit 1
2018-08-07 16:16:11 -07:00
2019-11-08 15:40:38 -08:00
# earlyoom specifically needs "SysRq 64 - enable signalling of processes (term, kill, oom-kill)"
# but for simplicity just enable all SysRq
sysctl -w kernel.sysrq=1
echo kernel.sysrq=1 >> /etc/sysctl.conf
2018-08-07 16:16:11 -07:00
if command -v earlyoom; then
systemctl status earlyoom
else
2018-11-10 15:56:17 -08:00
wget -r -l1 -np http://ftp.us.debian.org/debian/pool/main/e/earlyoom/ -A 'earlyoom_1.2-*_amd64.deb' -e robots=off -nd
apt install --quiet --yes ./earlyoom_1.2-*_amd64.deb
2018-08-07 16:16:11 -07:00
cat > earlyoom <<OOM
# trigger at 20% available RAM,
EARLYOOM_ARGS="-m 20"
2018-08-07 16:16:11 -07:00
OOM
cp earlyoom /etc/default/
rm earlyoom
2018-08-07 16:16:11 -07:00
systemctl stop earlyoom
systemctl enable earlyoom
systemctl start earlyoom
fi
2018-08-07 16:16:11 -07:00