aboutsummaryrefslogtreecommitdiff
path: root/sh
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-04-18 00:09:03 +0000
committerRoy Marples <roy@marples.name>2009-04-18 00:09:03 +0000
commitc9e24a0494dc499728e5131d15a8a16d3fd97c5d (patch)
treecdc7677c88a18556968feb34aa368e445146e9f2 /sh
parentd4c71415a9514c3d478e6ed110cba72a0d80a378 (diff)
Move status to runscript.sh so init scripts can override it, #159
Return 32 if crashed, #163
Diffstat (limited to 'sh')
-rw-r--r--sh/runscript.sh.in27
1 files changed, 26 insertions, 1 deletions
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index f48d0f8d..aaac4330 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -45,6 +45,31 @@ describe()
done
}
+# Report status
+status()
+{
+ if service_stopping; then
+ ewarn "status: stopping"
+ return 4
+ elif service_starting; then
+ ewarn "status: starting"
+ return 8
+ elif service_inactive; then
+ ewarn "status: inactive"
+ return 16
+ elif service_started; then
+ if service_crashed; then
+ eerror "status: crashed"
+ return 32
+ fi
+ einfo "status: started"
+ return 0
+ else
+ einfo "status: stopped"
+ return 1
+ fi
+}
+
# Template start / stop functions
start()
{
@@ -134,7 +159,7 @@ unset _f
while [ -n "$1" ]; do
# See if we have the required function and run it
- for _cmd in describe start stop ${extra_commands:-${opts}} \
+ for _cmd in describe start stop status ${extra_commands:-${opts}} \
${extra_started_commands}; do
if [ "${_cmd}" = "$1" ]; then
if [ "$(command -v "$1")" = "$1" ]; then