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() {
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 $?
+}
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
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})
}