Revision 8e2ed2e8
b/daemons/daemon-util.in | ||
---|---|---|
1 | 1 |
#!/bin/bash |
2 | 2 |
# |
3 | 3 |
|
4 |
# Copyright (C) 2009 Google Inc. |
|
4 |
# Copyright (C) 2009, 2012 Google Inc.
|
|
5 | 5 |
# |
6 | 6 |
# This program is free software; you can redistribute it and/or modify |
7 | 7 |
# it under the terms of the GNU General Public License as published by |
... | ... | |
108 | 108 |
return 0 |
109 | 109 |
} |
110 | 110 |
|
111 |
# Prints path to PID file for a daemon. |
|
112 |
daemon_pidfile() { |
|
113 |
if [[ "$#" -lt 1 ]]; then |
|
114 |
echo 'Missing daemon name.' >&2 |
|
115 |
return 1 |
|
116 |
fi |
|
117 |
|
|
118 |
local name="$1"; shift |
|
119 |
|
|
120 |
_daemon_pidfile $name |
|
121 |
} |
|
122 |
|
|
123 |
# Prints path to daemon executable. |
|
124 |
daemon_executable() { |
|
125 |
if [[ "$#" -lt 1 ]]; then |
|
126 |
echo 'Missing daemon name.' >&2 |
|
127 |
return 1 |
|
128 |
fi |
|
129 |
|
|
130 |
local name="$1"; shift |
|
131 |
|
|
132 |
_daemon_executable $name |
|
133 |
} |
|
134 |
|
|
111 | 135 |
# Prints a list of all daemons in the order in which they should be started |
112 | 136 |
list_start_daemons() { |
113 | 137 |
local name |
b/doc/examples/ganeti.initd.in | ||
---|---|---|
75 | 75 |
done |
76 | 76 |
} |
77 | 77 |
|
78 |
status_all() { |
|
79 |
local daemons="$1" status ret |
|
80 |
|
|
81 |
if [ -z "$daemons" ]; then |
|
82 |
daemons=$($DAEMON_UTIL list-start-daemons) |
|
83 |
fi |
|
84 |
|
|
85 |
status=0 |
|
86 |
|
|
87 |
for i in $daemons; do |
|
88 |
if status_of_proc $($DAEMON_UTIL daemon-executable $i) $i; then |
|
89 |
ret=0 |
|
90 |
else |
|
91 |
ret=$? |
|
92 |
# Use exit code from first failed call |
|
93 |
if [ "$status" -eq 0 ]; then |
|
94 |
status=$ret |
|
95 |
fi |
|
96 |
fi |
|
97 |
done |
|
98 |
|
|
99 |
exit $status |
|
100 |
} |
|
101 |
|
|
78 | 102 |
if [ -n "$2" ] && ! errmsg=$($DAEMON_UTIL is-daemon-name "$2" 2>&1); then |
79 | 103 |
log_failure_msg "$errmsg" |
80 | 104 |
exit 1 |
... | ... | |
94 | 118 |
stop_all "$2" |
95 | 119 |
start_all "$2" |
96 | 120 |
;; |
121 |
status) |
|
122 |
status_all "$2" |
|
123 |
;; |
|
97 | 124 |
*) |
98 | 125 |
log_success_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart}" |
99 | 126 |
exit 1 |
Also available in: Unified diff