Skip to content

Commit

Permalink
Add systemd scripts for cluster mode
Browse files Browse the repository at this point in the history
  • Loading branch information
svpcom committed Oct 2, 2024
1 parent cd9153c commit 0d683a1
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 5 deletions.
2 changes: 2 additions & 0 deletions debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
systemctl daemon-reload
5 changes: 5 additions & 0 deletions debian/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
if [ "$1" == "remove" ]
then
systemctl daemon-reload
fi
6 changes: 6 additions & 0 deletions debian/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
if [ "$1" == "remove" ]
then
systemctl stop wifibroadcast
systemctl stop wfb-cluster
fi
17 changes: 17 additions & 0 deletions scripts/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=WFB-ng cluster manager, profile %i
Requires=wfb-cluster.service
ReloadPropagatedFrom=wfb-cluster.service

[Service]
Type=simple
ExecStart=/bin/bash -c "exec /usr/bin/wfb-server --profiles $(echo %i | tr : ' ') --cluster manual"
TimeoutStopSec=5s
KillMode=mixed
Restart=on-failure
RestartSec=5s
# Set logging to file in wifibroadcast.cfg
StandardError=inherit

[Install]
WantedBy=wfb-cluster.service
16 changes: 16 additions & 0 deletions scripts/wfb-cluster-node.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=WFB-ng cluster node
Requires=wfb-cluster.service
ReloadPropagatedFrom=wfb-cluster.service

[Service]
Type=simple
ExecStart=/usr/sbin/wfb-ng.sh
TimeoutStopSec=5s
Restart=on-failure
KillMode=mixed
RestartSec=5s
StandardError=inherit

[Install]
WantedBy=wfb-cluster.service
17 changes: 17 additions & 0 deletions scripts/wfb-cluster.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This is a mostly empty service, but allows commands like stop, start, reload
# to propagate to all wfb-cluster services instances.

[Unit]
Description=WFB-ng cluster
After=network.target
Conflicts=wifibroadcast.service


[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecReload=/bin/true

[Install]
WantedBy=multi-user.target
3 changes: 2 additions & 1 deletion scripts/wifibroadcast.service
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# to propagate to all wifibroadcast@ service instances.

[Unit]
Description=Wifibroadcast server
Description=WFB-ng standalone server
After=network.target
Conflicts=wfb-cluster.service
#After=network.target sys-subsystem-net-devices-wlx00c0caa578a9.device
#Requires=sys-subsystem-net-devices-wlx00c0caa578a9.device

Expand Down
7 changes: 4 additions & 3 deletions scripts/[email protected]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Unit]
Description=WFB profile %i
PartOf=wifibroadcast.service
Description=WFB-ng standalone server, profile %i
Requires=wifibroadcast.service
ReloadPropagatedFrom=wifibroadcast.service

[Service]
Expand All @@ -10,10 +10,11 @@ EnvironmentFile=/etc/default/wifibroadcast
# per-profile environment
EnvironmentFile=-/etc/default/wifibroadcast.%i
ExecStart=/bin/bash -c "exec /usr/bin/wfb-server --profiles $(echo %i | tr : ' ') --wlans ${WFB_NICS}"
KillMode=mixed
TimeoutStopSec=5s
Restart=on-failure
RestartSec=5s
# Set logging to file in wifibroadcast.cfg
# Set logging to file in /etc/wifibroadcast.cfg
StandardError=inherit

[Install]
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def _long_description():
package_data={'wfb_ng.conf': ['master.cfg', 'site.cfg']},
data_files = [('/usr/bin', ['wfb_tx', 'wfb_rx', 'wfb_keygen', 'wfb_tx_cmd', 'scripts/wfb-cli-x11']),
('/lib/systemd/system', ['scripts/wifibroadcast.service',
'scripts/[email protected]']),
'scripts/[email protected]',
'scripts/wfb-cluster.service',
'scripts/wfb-cluster-node.service',
'scripts/[email protected]']),
('/etc/default', ['scripts/default/wifibroadcast']),
('/etc/sysctl.d', ['scripts/98-wifibroadcast.conf']),
('/etc/logrotate.d', ['scripts/wifibroadcast'])] if install_data_files else [],
Expand Down

0 comments on commit 0d683a1

Please sign in to comment.