Some ideas were dumb
Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
parent
924324aa10
commit
7afeb29bf2
49
ssm
49
ssm
|
@ -410,6 +410,7 @@ result() {
|
||||||
## Start the service, write down the svc pid
|
## Start the service, write down the svc pid
|
||||||
start() {
|
start() {
|
||||||
service_running && return 3
|
service_running && return 3
|
||||||
|
service_enabled && return 19
|
||||||
service_command is file || return 9
|
service_command is file || return 9
|
||||||
|
|
||||||
# Preform cgroup checks
|
# Preform cgroup checks
|
||||||
|
@ -459,7 +460,6 @@ reload() {
|
||||||
## 3: Service is not running.
|
## 3: Service is not running.
|
||||||
stop() {
|
stop() {
|
||||||
if service_oneshot; then
|
if service_oneshot; then
|
||||||
service_enabled || return 3
|
|
||||||
return 7
|
return 7
|
||||||
else
|
else
|
||||||
service_running || return 3
|
service_running || return 3
|
||||||
|
@ -499,23 +499,29 @@ info() {
|
||||||
|
|
||||||
info::item() { printf "%16s: %s\n" "$1" "$2"; }
|
info::item() { printf "%16s: %s\n" "$1" "$2"; }
|
||||||
|
|
||||||
|
info::item Name "$service_name"
|
||||||
|
|
||||||
status; _status_code = "$?"
|
status; _status_code = "$?"
|
||||||
|
if service_oneshot; then
|
||||||
|
info::item Oneshot 'yes'
|
||||||
|
|
||||||
|
case $_status_code in
|
||||||
|
(0) _status = 'success';;
|
||||||
|
(1) _status = 'not enabled';;
|
||||||
|
(9) _status = 'failed';;
|
||||||
|
(*) _status = 'unknown';;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
info::item Restart "$service_respawn"
|
||||||
|
|
||||||
case $_status_code in
|
case $_status_code in
|
||||||
(0) _status = 'running';;
|
(0) _status = 'running';;
|
||||||
(1) _status = 'down';;
|
(1) _status = 'down';;
|
||||||
(2) _status = 'success';;
|
|
||||||
(7) _status = 'stopped';;
|
(7) _status = 'stopped';;
|
||||||
(9) _status = "failed: $service_exit_last";;
|
(9) _status = "failed: $service_exit_last";;
|
||||||
(11) _status = "exited: $service_exit_last";;
|
(11) _status = "exited: $service_exit_last";;
|
||||||
(*) _status = 'unknown';;
|
(*) _status = 'unknown';;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
info::item Name "$service_name"
|
|
||||||
|
|
||||||
if service_oneshot; then
|
|
||||||
info::item Oneshot 'yes'
|
|
||||||
else
|
|
||||||
info::item Restart "$service_respawn"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info::item Status "$_status"
|
info::item Status "$_status"
|
||||||
|
@ -559,18 +565,14 @@ logs() {
|
||||||
## Status is a bit of a special case. It's talkative.
|
## Status is a bit of a special case. It's talkative.
|
||||||
status() {
|
status() {
|
||||||
service_running && return 0
|
service_running && return 0
|
||||||
service_enabled && return 2
|
service_enabled && return 0
|
||||||
|
|
||||||
service_stopped && return 7
|
service_stopped && return 7
|
||||||
|
|
||||||
service_failed && return 9
|
service_failed && return 9
|
||||||
service_exit_last is empty || return 11
|
service_exit_last is empty || return 11
|
||||||
|
|
||||||
if service_oneshot; then
|
|
||||||
return 13
|
|
||||||
else
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## For use in scripts
|
## For use in scripts
|
||||||
|
@ -614,7 +616,8 @@ var service_pid \
|
||||||
rundir \
|
rundir \
|
||||||
logdir \
|
logdir \
|
||||||
action \
|
action \
|
||||||
_self
|
_self \
|
||||||
|
res
|
||||||
|
|
||||||
## Internal defaults
|
## Internal defaults
|
||||||
var flag_list_services = 0
|
var flag_list_services = 0
|
||||||
|
@ -953,7 +956,7 @@ service_workdir && {
|
||||||
run_service_action "pre_$action" || die 13 "pre_$action failed!"
|
run_service_action "pre_$action" || die 13 "pre_$action failed!"
|
||||||
|
|
||||||
# Run the main action
|
# Run the main action
|
||||||
run_service_action "$action"; res=$?
|
run_service_action "$action"; res = "$?"
|
||||||
|
|
||||||
case "$action" in
|
case "$action" in
|
||||||
stop)
|
stop)
|
||||||
|
@ -973,7 +976,8 @@ case "$action" in
|
||||||
9 "service_command does not exist: ${service_command[0]}" \
|
9 "service_command does not exist: ${service_command[0]}" \
|
||||||
13 "Failed to create temporary files for $service_name" \
|
13 "Failed to create temporary files for $service_name" \
|
||||||
15 "Refusing to start $service_name: the service cgroup is not empty and \$service_cgroup_exclusive is set" \
|
15 "Refusing to start $service_name: the service cgroup is not empty and \$service_cgroup_exclusive is set" \
|
||||||
17 "$service_name failed"
|
17 "$service_name failed" \
|
||||||
|
19 "$service_name is already enabled"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
reload)
|
reload)
|
||||||
|
@ -982,14 +986,19 @@ case "$action" in
|
||||||
;;
|
;;
|
||||||
|
|
||||||
status)
|
status)
|
||||||
|
if service_oneshot; then
|
||||||
|
result "$res" \
|
||||||
|
0 "$service_name was successful" \
|
||||||
|
1 "$service_name is not enabled" \
|
||||||
|
9 "$service_name has failed ($service_exit_last)"
|
||||||
|
else
|
||||||
result "$res" \
|
result "$res" \
|
||||||
0 "$service_name is running" \
|
0 "$service_name is running" \
|
||||||
2 "$service_name was successful" \
|
|
||||||
1 "$service_name is not running" \
|
1 "$service_name is not running" \
|
||||||
7 "$service_name was stopped" \
|
7 "$service_name was stopped" \
|
||||||
9 "$service_name has failed with code: $service_exit_last" \
|
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"
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user