info fixes
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
e227235f46
commit
0dd00077a5
61
ssm
61
ssm
|
@ -493,37 +493,41 @@ stop() {
|
|||
}
|
||||
|
||||
info() {
|
||||
declare _status_label _status _type _info_items
|
||||
var _status_label = 'Running'
|
||||
var _status = 'no'
|
||||
var _type = 'daemon'
|
||||
var _info_items
|
||||
declare -a _info_items
|
||||
declare _status_code _status
|
||||
var _info_items _status_code _status
|
||||
|
||||
_info_items = 'Name' "$service_name"
|
||||
|
||||
if service_oneshot; then
|
||||
_status_label = 'Enabled'
|
||||
service_enabled && _status = 'yes'
|
||||
else
|
||||
service_running && _status = 'yes'
|
||||
_info_items += 'Oneshot' 'yes'
|
||||
fi
|
||||
|
||||
_info_items = \
|
||||
"Name" "$service_name" \
|
||||
"Type" "$_type" \
|
||||
"$_status_label" "$_status" \
|
||||
status; _status_code = "$?"
|
||||
case $_status_code in
|
||||
(0)
|
||||
_status = 'running'
|
||||
_info_items += 'PID' "$service_pid"
|
||||
_info_items += 'PIDFile' "$service_pidfile"
|
||||
;;
|
||||
(2) _status = 'success';;
|
||||
(7) _status = 'stopped';;
|
||||
(9) _status = "failed: $service_exit_last";;
|
||||
(11) _status = "exited: $service_exit_last";;
|
||||
(*) _status = 'unknown';;
|
||||
esac
|
||||
|
||||
_info_items += 'Status' "$_status"
|
||||
|
||||
_info_items += \
|
||||
"Exec" "${service_command[*]}" \
|
||||
"Respawn" "$service_respawn" \
|
||||
"Config path" "$service_config" \
|
||||
"Output log" "$service_logfile_out"
|
||||
|
||||
service_logfile_out == "$service_logfile_err" || {
|
||||
_info_items+=( "Error log" "$service_logfile_err" )
|
||||
}
|
||||
|
||||
if _status == 'yes'; then
|
||||
_info_items += \
|
||||
"PIDfile" "${service_pidfile:-none}" \
|
||||
"PID" "${service_pid:-none}"
|
||||
fi
|
||||
# Logs
|
||||
_info_items += 'Output log' "$service_logfile_out"
|
||||
service_logfile_out == "$service_logfile_err" || \
|
||||
_info_items += "Error log" "$service_logfile_err"
|
||||
|
||||
# Show the cgroup
|
||||
if cgroups; then
|
||||
|
@ -554,11 +558,17 @@ logs() {
|
|||
status() {
|
||||
service_running && return 0
|
||||
service_enabled && return 2
|
||||
|
||||
service_stopped && return 7
|
||||
|
||||
service_failed && return 9
|
||||
service_exit_last is empty || return 11
|
||||
|
||||
return 1
|
||||
if service_oneshot; then
|
||||
return 13
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
## For use in scripts
|
||||
|
@ -930,7 +940,8 @@ case "$2" in
|
|||
1 "$service_name is not running" \
|
||||
7 "$service_name was stopped" \
|
||||
9 "$service_name has failed with code: $service_exit_last" \
|
||||
11 "$service_name has exited with code: $service_exit_last"
|
||||
11 "$service_name has exited with code: $service_exit_last" \
|
||||
13 "$service_name is not enabled"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user