2021-08-16 18:56:17 +05:30
|
|
|
# The naxalnet systemd service
|
2021-07-26 15:58:50 +05:30
|
|
|
# See man:systemd.service(5) and man:systemd.unit(5)
|
|
|
|
# before editing this file.
|
2021-05-10 15:15:42 +05:30
|
|
|
[Unit]
|
2021-08-16 18:56:17 +05:30
|
|
|
Description=Setup mesh networks
|
2021-06-06 11:25:37 +05:30
|
|
|
Requires=systemd-networkd.service
|
|
|
|
Requires=iwd.service
|
|
|
|
Wants=systemd-resolved.service
|
|
|
|
After=iwd.service
|
|
|
|
# Stops NetworkManager and wpa_supplicant if already running
|
|
|
|
Conflicts=NetworkManager.service
|
|
|
|
Conflicts=wpa_supplicant.service
|
2021-08-16 21:29:27 +05:30
|
|
|
# This stops networkmanager and wpa_supplicant when naxalnet is enabled
|
2021-06-06 11:25:37 +05:30
|
|
|
After=NetworkManager.service
|
|
|
|
After=wpa_supplicant.service
|
2021-05-10 15:15:42 +05:30
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
RemainAfterExit=yes
|
2021-06-10 09:15:58 +05:30
|
|
|
Restart=on-failure
|
2021-07-26 15:58:50 +05:30
|
|
|
RestartSec=2sec
|
2021-06-15 14:00:48 +05:30
|
|
|
# IWD takes some time to find devices.
|
2021-08-15 15:02:28 +05:30
|
|
|
# If naxalnet is run before iwd finds devices,
|
2021-08-16 18:56:17 +05:30
|
|
|
# naxalnet cannot start a mesh network but exits without errors.
|
2021-08-16 21:29:27 +05:30
|
|
|
# So, we give a 2s delay.
|
2021-07-26 15:58:50 +05:30
|
|
|
ExecStartPre=/usr/bin/sleep 2
|
2021-05-22 15:14:16 +05:30
|
|
|
ExecStart=/usr/bin/naxalnet
|
2021-08-16 18:56:17 +05:30
|
|
|
# Reload systemd-networkd after naxalnet exits
|
2021-08-16 21:29:27 +05:30
|
|
|
ExecStartPost=/usr/bin/networkctl reload
|
2021-08-17 09:49:16 +05:30
|
|
|
# Delete all files in /run/systemd/network
|
|
|
|
ExecStop=/usr/bin/find /run/systemd/network -type f -delete
|
2021-08-18 17:33:46 +05:30
|
|
|
# Delete the interfaces created...
|
2021-08-16 18:56:17 +05:30
|
|
|
ExecStopPost=/usr/bin/networkctl delete bridge0 bat0
|
2021-08-18 17:33:46 +05:30
|
|
|
# ... and reload the configuration files.
|
|
|
|
ExecStopPost=/usr/bin/networkctl reload
|
2021-08-16 21:29:27 +05:30
|
|
|
# Make python flush messages instead of buffering.
|
|
|
|
# When reading the systemd journal, we need to see the messages
|
|
|
|
# in the exact order. There will suddenly be a lot of messages
|
|
|
|
# from naxalnet, networkd, iwd and resolved. When buffering is on,
|
|
|
|
# we won't see the messages from naxalnet in the order they were
|
|
|
|
# printed. This, among other problems, make it hard while debugging.
|
|
|
|
# This will no longer be needed when naxalnet sends its messages
|
|
|
|
# directly to the systtemd journal instead of stdout.
|
2021-08-16 18:56:17 +05:30
|
|
|
Environment=PYTHONUNBUFFERED=1
|
2021-05-10 15:15:42 +05:30
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|