default can do arrays now

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2017-12-08 14:39:50 +03:00
parent b13b47d1c0
commit 253fd1f094

34
ssm
View File

@ -4,11 +4,13 @@ shopt -s nullglob
# Utility functions # Utility functions
## Make setting default values a bit less awkward ## Make setting default values a bit less awkward
default() { default() {
declare -n _p=$1 declare -n _p=$1; shift
if ! [[ "$_p" ]]; then [[ "$_p" ]] || {
_p=$2 for v in "$@"; do
fi _p+=( "$v" )
done
}
} }
## Die. Why not? ## Die. Why not?
@ -407,18 +409,16 @@ main() {
fi fi
# Service-level defaults # Service-level defaults
default service_pidfile "$svc_pidfile" default service_pidfile "$svc_pidfile"
default service_logfile "$logdir/$service_name.log" default service_logfile "$logdir/$service_name.log"
default service_stop_timeout 30 default service_ready_flag "$rundir/$service_name.ready"
default service_ready_timeout 15 default service_enabled_flag "$rundir/$service_name.enabled"
default service_stop_signal 15 default service_stopped_flag "$rundir/$service_name.stopped"
default service_reload_signal 1 default service_stop_timeout 30
default service_ready_flag "$rundir/$service_name.ready" default service_ready_timeout 15
default service_enabled_flag "$rundir/$service_name.enabled" default service_stop_signal 15
default service_stopped_flag "$rundir/$service_name.stopped" default service_reload_signal 1
default service_signals 1 10 12
# default does not support arrays
[[ "$service_signals" ]] || service_signals=( 1 10 12 )
# Let's see if there's a PID # Let's see if there's a PID
if [[ -f "$service_pidfile" ]]; then if [[ -f "$service_pidfile" ]]; then