shaky, abort
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
a47b00f665
commit
a0ef06810c
46
ssm
46
ssm
|
@ -5,26 +5,6 @@ shopt -s nullglob
|
||||||
is_function() [[ "$(type -t "$1" 2>/dev/null)" == 'function' ]]
|
is_function() [[ "$(type -t "$1" 2>/dev/null)" == 'function' ]]
|
||||||
readonly -f is_function
|
readonly -f is_function
|
||||||
|
|
||||||
command_not_found_handle() {
|
|
||||||
declare f=$1; shift; declare argv=( "$@" )
|
|
||||||
|
|
||||||
# Skip the special name 'source'.
|
|
||||||
# Don't call your functions 'source'.
|
|
||||||
declare i
|
|
||||||
for i in "${FUNCNAME[@]:1}"; do
|
|
||||||
[[ $i == 'source' ]] && continue
|
|
||||||
f="${i}${f}"
|
|
||||||
break
|
|
||||||
done
|
|
||||||
|
|
||||||
is_function "$f" || {
|
|
||||||
printf '%s: line %s: %s: command not found\n' "$0" "${BASH_LINENO[0]}" "$f" >&2
|
|
||||||
return 127
|
|
||||||
}
|
|
||||||
|
|
||||||
"$f" "${argv[@]}"
|
|
||||||
}; readonly command_not_found_handle;
|
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<- EOF
|
cat <<- EOF
|
||||||
Usage: ssm <service> <function>
|
Usage: ssm <service> <function>
|
||||||
|
@ -506,11 +486,11 @@ info() {
|
||||||
declare _status_code _status _show_pid
|
declare _status_code _status _show_pid
|
||||||
var _info_items _status_code _status _show_pid
|
var _info_items _status_code _status _show_pid
|
||||||
|
|
||||||
.item Name "$service_name"
|
info.item Name "$service_name"
|
||||||
|
|
||||||
status; _status_code = "$?"
|
status; _status_code = "$?"
|
||||||
if service_oneshot; then
|
if service_oneshot; then
|
||||||
.item Oneshot 'yes'
|
infoinfo.item Oneshot 'yes'
|
||||||
|
|
||||||
case $_status_code in
|
case $_status_code in
|
||||||
(0) _status = 'success';;
|
(0) _status = 'success';;
|
||||||
|
@ -519,7 +499,7 @@ info() {
|
||||||
(*) _status = 'unknown';;
|
(*) _status = 'unknown';;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
.item Restart "$service_respawn"
|
info.item Restart "$service_respawn"
|
||||||
|
|
||||||
case $_status_code in
|
case $_status_code in
|
||||||
(0) _status = 'running';;
|
(0) _status = 'running';;
|
||||||
|
@ -531,23 +511,23 @@ info() {
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
.item Status "$_status"
|
info.item Status "$_status"
|
||||||
|
|
||||||
.item Exec "${service_command[*]}"
|
info.item Exec "${service_command[*]}"
|
||||||
.item Config "$service_config"
|
info.item Config "$service_config"
|
||||||
.item Workdir "$service_workdir"
|
info.item Workdir "$service_workdir"
|
||||||
|
|
||||||
.item 'Output log' "$service_logfile_out"
|
info.item 'Output log' "$service_logfile_out"
|
||||||
service_logfile_out == "$service_logfile_err" || \
|
service_logfile_out == "$service_logfile_err" || \
|
||||||
.item 'Error log' "$service_logfile_err"
|
info.item 'Error log' "$service_logfile_err"
|
||||||
|
|
||||||
if service_running; then
|
if service_running; then
|
||||||
.item PID "$service_pid"
|
info.item PID "$service_pid"
|
||||||
.item PIDFile "$service_pidfile"
|
info.item PIDFile "$service_pidfile"
|
||||||
|
|
||||||
cgroups && {
|
cgroups && {
|
||||||
.item Cgroup "$cgroup_home/$service_cgroup_name"
|
info.item Cgroup "$cgroup_home/$service_cgroup_name"
|
||||||
.item 'Cgroup procs' "${#service_cgroup_procs[@]}"
|
info.item 'Cgroup procs' "${#service_cgroup_procs[@]}"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user