diff --git a/ssm b/ssm index f17b60f..8db0ceb 100755 --- a/ssm +++ b/ssm @@ -29,7 +29,7 @@ svc() { pid_wait "$job_pid" && { rm -f "$svc_pidfile" "$service_ready_flag" } - } + }; trap 'svc::cleanup' TERM "$@" & job_pid=$! @@ -386,7 +386,7 @@ main() { } # Get the service config - source "$service_config" || die 7 "Failed to read the service config: $cfgdir/init.d/$service_name" + source -- "$service_config" "${@:3}" || die 7 "Failed to read the service config: $cfgdir/init.d/$service_name" # Legacy [[ "$service_args" ]] && service_command=( "${service_command[@]}" "${service_args[@]}" ) @@ -442,10 +442,10 @@ main() { fi # Run the function + "$2"; res=$? + case "$2" in stop) - stop; res=$? - result "$res" \ 0 "Stopped $service_name" \ 3 "$service_name is not running" \ @@ -453,8 +453,6 @@ main() { ;; start) - start; res=$? - result "$res" \ 0 "Started $service_name" \ 3 "$service_name is already running" \ @@ -465,15 +463,11 @@ main() { ;; reload) - reload; res=$? - result "$res" \ 0 "Reloaded $service_name" ;; status) - status; res=$? - if (( service_oneshot )); then result "$res" \ 0 "$service_name is enabled" \ @@ -484,9 +478,6 @@ main() { 1 "$service_name is not running" fi ;; - - *) - "$2"; res=$?;; esac (( res )) && return "$res"