1 |
#!/usr/bin/env bash |
2 |
# Spectre 2 |
3 |
# |
4 |
# Douglas Thrift |
5 |
# |
6 |
# $Id$ |
7 |
|
8 |
command="$1" |
9 |
|
10 |
shift |
11 |
|
12 |
function check() |
13 |
{ |
14 |
pid="$(< spectre.pid)" |
15 |
} |
16 |
|
17 |
function usage() |
18 |
{ |
19 |
echo "Usage: $(basename $0) start|stop|restart|reload|status [...]" |
20 |
} |
21 |
|
22 |
function start_() |
23 |
{ |
24 |
echo -n "Starting Spectre daemon ... " |
25 |
$(dirname $0)/Spectre2 -fork $@ |
26 |
echo "started." |
27 |
} |
28 |
|
29 |
function stop_() |
30 |
{ |
31 |
echo -n "Stopping Spectre daemon ... " |
32 |
# try |
33 |
# { |
34 |
# pid_t id(process()); |
35 |
# |
36 |
# api::Posix::CheckError(::kill(id, SIGTERM)); |
37 |
# |
38 |
# // XXX: somehow wait for it to terminate |
39 |
# |
40 |
# api::Cout << "stopped." << ios::NewLine; |
41 |
# } |
42 |
# catch (ext::Exception) { api::Cout << "failed." << ios::NewLine; } |
43 |
} |
44 |
|
45 |
function reload_() |
46 |
{ |
47 |
echo -n "Reloading Spectre daemon ... " |
48 |
# api::Cout << "Reloading Spectre daemon ... " << ios::Flush; |
49 |
# |
50 |
# try |
51 |
# { |
52 |
# api::Posix::CheckError(::kill(process(), SIGUSR1)); |
53 |
# |
54 |
# api::Cout << "reloaded." << ios::NewLine; |
55 |
# } |
56 |
# catch (ext::Exception) { api::Cout << "failed." << ios::NewLine; } |
57 |
} |
58 |
|
59 |
function status_() |
60 |
{ |
61 |
echo "STUB: status_()" |
62 |
} |
63 |
|
64 |
case $command in |
65 |
start) |
66 |
start_ $@ |
67 |
;; |
68 |
stop) |
69 |
stop_ |
70 |
;; |
71 |
restart) |
72 |
restart_ $@ |
73 |
;; |
74 |
reload) |
75 |
reload_ |
76 |
;; |
77 |
status) |
78 |
status_ |
79 |
;; |
80 |
*) |
81 |
usage |
82 |
;; |
83 |
esac |