]> git.ipfire.org Git - network.git/commitdiff
hostapd should be monitored by systemd.
authorStefan Schantl <stefan.schantl@ipfire.org>
Sun, 17 Jul 2011 12:51:50 +0000 (14:51 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Sun, 17 Jul 2011 12:51:50 +0000 (14:51 +0200)
functions.service
functions.wireless

index b1a9cd83fc08cde2f8c6ab0a9385f79921409740..9d9951748f48f609837358243884e236001d3c7d 100644 (file)
@@ -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 $?
+}
index 114e217af4b060ffb4da38ac62243b030438a717..6353d0d70a008cb7eb99cdfc9e5d411f9ac3ca57 100644 (file)
@@ -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})
 }