2 # Bumblebee daemon handler script. Distro-independent script to start/stop
3 # daemon. Should be runnable in any distro but won't give any feedback.
9 BIN
='/usr/bin/bumblebeed'
10 PIDFILE
=/var
/run
/$NAME.pid
12 # returns 0 if running, non-zero otherwise
15 # program is not running
16 [ -s "$PIDFILE" ] ||
return 3
18 pid
="$(cat "$PIDFILE" 2>/dev/null)"
20 # process is not running, pid file not properly cleared
21 kill -0 "$pid" 2>/dev
/null ||
return 1
28 # program is not installed
29 [ -x "$BIN" ] ||
return 5
31 # return if already started
32 status
&& return 0 || true
33 "$BIN" --daemon 2>/dev
/null
34 status
&& return 0 ||
return 1
39 local pid
="$(cat "$PIDFILE" 2>/dev/null)"
41 # not running, we're done
44 # first ask the daemon nicely to quit
46 # and check whether it listened
47 while [ $retries -gt 0 ]; do
48 retries
=$
((retries
- 1))
50 # process has gone, return success
52 # wait for half a minut before polling again
55 # failed to stop or timeout
65 stat_busy
"Starting Bumblebee"
74 stat_busy
"Stopping Bumblebee"
83 stat_busy
"Stopping Bumblebee"
91 stat_busy
"Starting Bumblebee"
100 echo "Usage: $0 {start|stop|restart|status}"