stop.sh 503 Bytes
Newer Older
Kolbjørn Barmen's avatar
Kolbjørn Barmen committed
1
#! /bin/sh
Olav Kvittem's avatar
Olav Kvittem committed
2

Kolbjørn Barmen's avatar
Kolbjørn Barmen committed
3 4
set -e

5
. /etc/mp-rude/start.conf
Olav Kvittem's avatar
Olav Kvittem committed
6

Kolbjørn Barmen's avatar
Kolbjørn Barmen committed
7 8 9
pidfile=${pidfile:-/run/mp-rude.pids}

if [ ! -e "${pidfile}" ]
10
  then
Kolbjørn Barmen's avatar
Kolbjørn Barmen committed
11
    echo "Pid file does not exist: ${pidfile}"
Olav Kvittem's avatar
Olav Kvittem committed
12 13 14
    exit
fi

15 16 17
if test $1. != .
  then
    sleep $1  # wait a few seconds closer to midnight
Olav Kvittem's avatar
Olav Kvittem committed
18 19
fi

20 21 22 23 24 25 26
for pid in $(cat "${pidfile}")
  do
    if [ -d /proc/"${pid}" ]
      then
        grep -q trace.sh /proc/"${pid}"/cmdline && kill ${pid}
    fi
  done
Olav Kvittem's avatar
Olav Kvittem committed
27

Kolbjørn Barmen's avatar
Kolbjørn Barmen committed
28
rm -f "${pidfile}"
29

Kolbjørn Barmen's avatar
Kolbjørn Barmen committed
30
# remove empty directories
31
find  "${logpath}" -type d -empty -delete