Add OpenRC init files, and move to init-scripts. Update README accordingly.

This commit is contained in:
Scott Ellis 2021-06-18 11:02:21 -07:00
parent 7f30407401
commit 3f6a02dce6
4 changed files with 47 additions and 3 deletions

View File

@ -7,7 +7,7 @@ This is a daemon which listens for wake-on-LAN ("WOL") packets, and upon spottin
One use-case (my use case) is to have a gaming VM that doesn't need to be running all the time. NVIDIA Gamestream and Moonlight both have the ability to send WOL packets in an attempt to wake an associated system. For "real" hardware, this works great. Unfortunately, for VMs it doesn't really do anything since there's no physical NIC snooping for the WOL packet. This daemon attempts to solve that.
## Mechanics
When started, this daemon will use `libpcap` to make a listener on the specified network interface, listening for packets that look like they might be wake-on-lan. Due to how `pcap` works, the current filter is for UDP sent to the broadcast address with a length of 144 bytes. This seems to generate very low false-positives, doesn't require the NIC to be in promiscuous mode, and overall seems like a decent filter.
When started, this daemon will use `libpcap` to make a listener on the specified network interface, listening for packets that look like they might be wake-on-lan. Due to how `pcap` works, the current filter is for UDP sent to the broadcast address with a length of 234 bytes (the size of a WOL packet w/security). This seems to generate very low false-positives, doesn't require the NIC to be in promiscuous mode, and overall seems like a decent filter.
Upon receipt of a (probable) WOL packet, the daemon extracts the first MAC address (WOL packets are supposed to repeat the target machine MAC a few times).
@ -20,5 +20,14 @@ The daemon will keep running until killed with a SIGINT (`^c`).
Because this daemon, and wake-on-LAN, operate by MAC addresses, any VMs that are a candidate to be woken must have a hard-coded MAC in their machine configuration.
## systemd example service
There's a systemd service template example in virtwold@.service that should make it easy to configure for any interfaces that you need to run on
## System Integration
### systemd example service
There's a systemd service template example in `init-scripts/virtwold@.service` that should make it easy to configure for any interfaces that you need to run on
## OpenRC example init script
Systems which use openrc can find an example init script and associated conf file in `init-scripts/openrc`. The interface should be adjusted to match your particular needs (e.g., swap `eth0` for `enp44s0` or something like that).
## Gentoo ebuild
An ebuild for Gentoo systems is available in [here](https://github.com/ScottESanDiego/scotterepo/tree/main/app-emulation/virtwold), although it only installs OpenRC init files (since that's what I use).

View File

@ -0,0 +1,4 @@
# /etc/conf.d/virtwold
#
# Specify the interface to be used
VIRTWOLD_INTERFACE="eth0"

View File

@ -0,0 +1,31 @@
#!/sbin/openrc-run
# Copyright 2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
name="virtwold daemon"
description="Virtual Wake-on-LAN Daemon"
command=/usr/bin/virtwold
command_args="--interface ${VIRTWOLD_INTERFACE}"
PIDFILE=/run/virtwold.pid
depend() {
need net
}
start() {
start-stop-daemon \
--start \
--exec ${command} \
--background \
--stdout-logger /usr/bin/logger \
--make-pidfile \
--pidfile "${PIDFILE}" \
-- ${command_args}
}
stop() {
start-stop-daemon \
--stop \
--pidfile "${PIDFILE}"
}