From d39b2edb17fec053702c0247c9529b99de7754e0 Mon Sep 17 00:00:00 2001 From: jonas Date: Fri, 5 Nov 2021 13:58:12 +0100 Subject: [PATCH] Rewrite systemd unit for hostapd fixes: #2 --- salt/states/hostapd/files/hostapd.service.jinja | 11 +++++++++++ salt/states/hostapd/init.sls | 15 +++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 salt/states/hostapd/files/hostapd.service.jinja diff --git a/salt/states/hostapd/files/hostapd.service.jinja b/salt/states/hostapd/files/hostapd.service.jinja new file mode 100644 index 0000000..7d0d76d --- /dev/null +++ b/salt/states/hostapd/files/hostapd.service.jinja @@ -0,0 +1,11 @@ +[Unit] +Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator +BindsTo=sys-subsystem-net-devices-{{ pillar['network']['wireless'] }}.device +After=sys-subsystem-net-devices-{{ pillar['network']['wireless'] }}.device + +[Service] +ExecStart=/usr/sbin/hostapd /etc/hostapd.conf +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/salt/states/hostapd/init.sls b/salt/states/hostapd/init.sls index ae64f9a..edabace 100644 --- a/salt/states/hostapd/init.sls +++ b/salt/states/hostapd/init.sls @@ -28,6 +28,21 @@ Configure hostapd: - group: root - mode: "0600" +Create hostapd service unit file: + file.managed: + - name: /etc/systemd/system/hostapd.service + - source: salt://hostapd/files/hostapd.service.jinja + - template: jinja + - user: root + - group: root + - mode: "0644" + +Reload systemd daemon: + cmd.run: + - name: systemctl daemon-reload + - onchanges: + - file: Create hostapd service unit file + Start hostapd: service.running: - name: hostapd