diff options
author | Charadon <charadon@localhost.localdomain> | 2022-10-20 15:02:45 -0400 |
---|---|---|
committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2022-10-22 02:51:15 +0700 |
commit | b6ed48582e6ac490d618ee54776465e79413bdd9 (patch) | |
tree | 44c5ee26e36bd6cf25bba53ee390369febd2128b /system | |
parent | 6c434f8da0b053e4bef283e952fb28d377519f93 (diff) | |
download | slackbuilds-b6ed48582e6ac490d618ee54776465e79413bdd9.tar.gz |
system/earlyoom: Fixed rc script outputting cat and ps errors.
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'system')
-rw-r--r-- | system/earlyoom/rc.earlyoom | 67 |
1 files changed, 46 insertions, 21 deletions
diff --git a/system/earlyoom/rc.earlyoom b/system/earlyoom/rc.earlyoom index 277050fefd..033a8e5392 100644 --- a/system/earlyoom/rc.earlyoom +++ b/system/earlyoom/rc.earlyoom @@ -4,34 +4,46 @@ set -eu . /etc/default/earlyoom do_start() { - if ps -p "$(cat /var/run/earlyoom.pid)" > /dev/null + if [ -f /var/run/earlyoom.pid ]; then - echo "earlyoom is already running." - else - echo "Starting earlyoom..." - nohup /usr/bin/earlyoom $EARLYOOM_ARGS > /var/log/earlyoom.log 2>&1 & - echo "$!" > /var/run/earlyoom.pid + if ps -p "$(cat /var/run/earlyoom.pid)" > /dev/null 2>&1 + then + echo "earlyoom is already running." + exit 0 + fi fi + echo "Starting earlyoom..." + # shellcheck disable=2086 + nohup /usr/bin/earlyoom $EARLYOOM_ARGS > /var/log/earlyoom.log 2>&1 & + echo "$!" > /var/run/earlyoom.pid + exit 0 } do_stop() { - if ps -p "$(cat /var/run/earlyoom.pid)" > /dev/null + if [ -f /var/run/earlyoom.pid ]; then - echo "Stopping earlyoom..." - kill -15 "$(cat /var/run/earlyoom.pid)" - else - echo "earlyoom is not running." + if ps -p "$(cat /var/run/earlyoom.pid)" > /dev/null 2>&1 + then + echo "Stopping earlyoom..." + kill -15 "$(cat /var/run/earlyoom.pid)" > /dev/null 2>&1 + exit 0 + fi fi + echo "earlyoom is not running..." } do_force_stop() { - if ps -p "$(cat /var/run/earlyoom.pid)" > /dev/null + if [ -f /var/run/earlyoom.pid ]; then - echo "Killing earlyoom..." - kill -9 "$(cat /var/run/earlyoom.pid)" - else - echo "earlyoom appears to not be running." + if ps -p "$(cat /var/run/earlyoom.pid)" > /dev/null 2>&1 + then + echo "Killing earlyoom..." + kill -9 "$(cat /var/run/earlyoom.pid)" > /dev/null 2>&1 + exit 0 + fi fi + echo "earlyoom appears to not be running." + exit 0 } do_restart() { @@ -40,14 +52,27 @@ do_restart() { } do_status() { - if ps -p "$(cat /var/run/earlyoom.pid)" > /dev/null + if [ -f /var/run/earlyoom.pid ]; then - echo "earlyoom is running with pid $(cat /var/run/earlyoom.pid)." - else - echo "earlyoom is not running." + if ps -p "$(cat /var/run/earlyoom.pid)" > /dev/null 2>&1 + then + echo "earlyoom is running with pid $(cat /var/run/earlyoom.pid)." + exit 0 + fi fi + echo "earlyoom is not running." } +do_help() { + echo "USAGE: rc.earlyoom (start|stop|force-stop|restart|status)" + exit 0 +} + +if [ -z "${1-}" ]; +then + do_help +fi + case $1 in start) do_start @@ -65,6 +90,6 @@ case $1 in do_status ;; *) - echo "USAGE: rc.earlyoom (start|stop|force-stop|restart|status)" + do_help ;; esac |