shaky, abort

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2020-02-11 03:00:24 +03:00
parent a47b00f665
commit a0ef06810c

46
ssm
View File

@ -5,26 +5,6 @@ shopt -s nullglob
is_function() [[ "$(type -t "$1" 2>/dev/null)" == '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() {
cat <<- EOF
Usage: ssm <service> <function>
@ -506,11 +486,11 @@ info() {
declare _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 = "$?"
if service_oneshot; then
.item Oneshot 'yes'
infoinfo.item Oneshot 'yes'
case $_status_code in
(0) _status = 'success';;
@ -519,7 +499,7 @@ info() {
(*) _status = 'unknown';;
esac
else
.item Restart "$service_respawn"
info.item Restart "$service_respawn"
case $_status_code in
(0) _status = 'running';;
@ -531,23 +511,23 @@ info() {
esac
fi
.item Status "$_status"
info.item Status "$_status"
.item Exec "${service_command[*]}"
.item Config "$service_config"
.item Workdir "$service_workdir"
info.item Exec "${service_command[*]}"
info.item Config "$service_config"
info.item Workdir "$service_workdir"
.item 'Output log' "$service_logfile_out"
info.item 'Output log' "$service_logfile_out"
service_logfile_out == "$service_logfile_err" || \
.item 'Error log' "$service_logfile_err"
info.item 'Error log' "$service_logfile_err"
if service_running; then
.item PID "$service_pid"
.item PIDFile "$service_pidfile"
info.item PID "$service_pid"
info.item PIDFile "$service_pidfile"
cgroups && {
.item Cgroup "$cgroup_home/$service_cgroup_name"
.item 'Cgroup procs' "${#service_cgroup_procs[@]}"
info.item Cgroup "$cgroup_home/$service_cgroup_name"
info.item 'Cgroup procs' "${#service_cgroup_procs[@]}"
}
fi