From 4243f0ca924c40cce34638727fe7ad23581bc78f Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sun, 17 Jul 2011 14:51:50 +0200 Subject: [PATCH] hostapd should be monitored by systemd. --- functions.service | 19 +++++++++++++++++++ functions.wireless | 10 ++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/functions.service b/functions.service index b1a9cd83..9d995174 100644 --- a/functions.service +++ b/functions.service @@ -26,6 +26,15 @@ function service_start() { assert isset name systemctl start ${name}.service + + # Check, if the service was successfully started and + # return a proper exit code. + service_is_active ${name} + local ret=$? + + log INFO "Started service '${name}.service', code=${ret}." + + return ${ret} } function service_stop() { @@ -69,3 +78,13 @@ function service_status() { systemctl status ${name}.service >/dev/null 2>&1 return $? } + +function service_is_active() { + local name=${1} + shift + + assert isset name + + systemctl is-active ${name}.service >/dev/null 2>&1 + return $? +} diff --git a/functions.wireless b/functions.wireless index 114e217a..6353d0d7 100644 --- a/functions.wireless +++ b/functions.wireless @@ -230,7 +230,7 @@ function hostapd_start() { local config_file=${config_dir}/config hostapd_config_write ${device} $@ > ${config_file} - hostapd -dd -B -P ${config_dir}/pid ${config_file} + service_start hostapd@${device} local ret=$? case "${ret}" in @@ -257,13 +257,7 @@ function hostapd_stop() { assert isset device - local pid=$(hostapd_get_pid ${device}) - - if isset pid; then - process_kill ${pid} - else - warning_log "Could not find pid file for hostapd process running for ${device}." - fi + service_stop hostapd@${device} rm -rf $(hostapd_config_dir ${device}) } -- 2.39.2