The officially official Devuan Forum!

You are not logged in.

#1 2024-10-08 13:03:07

Alverstone
Member
Registered: 2024-10-06
Posts: 7  

[SOLVED] runit: a suggestion for dhcpcd5 run file

#!/bin/sh

# symlink this run file to your dhcpcd[-<interface>] directory
# or symlink the entire service directory to get the Manager mode

[ -f ./conf ] && . ./conf
iface="$(pwd -L)"
iface="${iface##/*/}"
case "$iface" in
	*"-"*) iface="${iface#*-}";;
	*) iface="";;
esac

if [ -n "$iface" ]; then
	# don't use -M here in DHCPCD_ARGS, probably not what you want
	exec dhcpcd -B ${DHCPCD_ARGS} "$iface" 2>&1 || exit 1
fi

# otherwise interface specific instances get screwed
for srv in /etc/service/dhcpcd-*; do
	sv start "$srv" || exit 1
done
DHCPCD_IGNORE=""
for pf in /run/dhcpcd/*.pid; do
	iface="${pf##/*/}"
	iface="${iface%.pid}"
	DHCPCD_IGNORE="${DHCPCD_IGNORE}${DHCPCD_IGNORE:+" "}-Z $iface"
done

# -M might be redundant
exec dhcpcd -B ${DHCPCD_ARGS:--M} $DHCPCD_IGNORE 2>&1

Create /etc/sv/dhcpcd, put the run file there. Create /etc/sv/dhcpcd-eth0 directory, symlink the run file inside. Symlink both directories into /etc/service. One will start an interface specific instance, the other will start in management mode for all interfaces, except those, which are handled by interface specific instances.

There is a serious problem here, which I don't know how to fix properly: sysvinit's dhcpcd service. If you only put interface specific instances in /etc/service, then sysvinit's dhcpcd service will start in management mode for all interfaces and screw all your interface specific instances. Maybe put a dummy dhcpcd service in /etc/service which just sleeps forever. Maybe use no.emulate.sysv. Maybe there's a better solution. I use no.emulate.sysv.

Last edited by Alverstone (2024-10-08 13:26:47)

Offline

#2 2024-10-09 17:58:16

Alverstone
Member
Registered: 2024-10-06
Posts: 7  

Re: [SOLVED] runit: a suggestion for dhcpcd5 run file

This script is broken. If main dhcpcd starts sooner, interface specific instances just relay their job to the main daemon and exit.

Offline

Board footer