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 CLIENT
="$(which optirun)"
11 PIDFILE
=/var
/run
/$NAME.pid
14 # Start the daemon only if there is not another instance running
15 stat_busy
"Starting Bumblebee"
16 local pid
="$(cat "$PIDFILE" 2>/dev/null)"
17 kill -0 $pid >/dev
/null
2>&1
19 0) ;; # already running
21 "$BIN" --daemon >/dev
/null
32 # Stop the daemon only if there is an instance running
33 stat_busy
"Stopping Bumblebee"
34 local pid
="$(cat "$PIDFILE" 2>/dev/null)"
35 kill -0 $pid >/dev
/null
2>&1
37 0) # Alive and running
38 local pid
="$(cat "$PIDFILE" 2>/dev/null)"
39 kill -TERM $pid >/dev
/null
40 # give it time to end gracefully...
42 while [ $retries -gt 0 ]; do
43 retries
=$
(expr $retries - 1)
44 kill -0 $pid >/dev
/null
2>&1
49 *) # no need for polling anymore
54 # ... otherwhise just terminate it.
55 kill -0 $pid >/dev
/null
2>&1
57 0) # still alive > Kill
58 kill -KILL $pid >/dev
/null
89 echo "Usage: $0 {start|stop|restart|status}"