summarylogtreecommitdiffstats
path: root/cachefilesd
blob: 4624369c9e51e5b763e8639ccb3a9a1e56715f47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

pidfile="/run/cachefilesd.pid"

get_pid() {
    if [ -r "${pid_file}" ]; then
        cat "${pid_file}"
    else
        pgrep -f /sbin/cachefilesd
    fi
}

PID=$(get_pid)

case "$1" in
  start)
    stat_busy "Starting cachefilesd"
    modprobe cachefiles 2>/dev/null
    [[ -z "$PID" ]] && /sbin/cachefilesd -p "$pidfile"
    if (( $? > 0 )); then
      stat_fail
    else
      add_daemon cachefilesd
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping cachefilesd"
    [[ ! -z "$PID" ]] && kill $PID &> /dev/null
    if (( $? > 0 )); then
      stat_fail
    else
      rm -f "$pidfile"
      rm_daemon cachefilesd
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 0.5
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"  
esac
exit 0