Based on the init scripts from Void Linux
WARNING: This is only an experiment for now. Please do not take it too seriously. Also it might cripple your computer, eat your data, etc.
I like runit. Let us experiment and see how hard it would be to completely initialize FreeBSD with it and what it is like in daily usage.
Please see runit-faster(7).
It is recommended to disable
/etc/rc.d/netif managed network
interfaces completely and use one of the dhclient services or do
manual network setup instead.
Also make sure to remove or comment out any
ifconfig_X="... DHCP ..." lines in
/etc/rc.conf to prevent
devd(8) from autostarting
Here we setup
re0 as master interface and
backup interface. We use the
dhclient-lagg0 runit service that will
attempt to run
lagg0. It is under supervision by
runit and the service will be restarted when
dhclient(8) exits. For
this to work we have to make that sure that the interfaces are
destroyed first should they already exist.
It is assumed that
/etc/wpa_supplicant.conf is already setup.
$ cat <<EOF > /usr/local/etc/sv/dhclient-lagg0/conf set -e ifconfig wlan0 destroy > /dev/null 2>&1 || true ifconfig lagg0 destroy > /dev/null 2>&1 || true ifconfig wlan0 create wlandev iwm0 country DE ifconfig wlan0 inet6 -ifdisabled accept_rtadv up ifconfig re0 inet6 -ifdisabled accept_rtadv up ifconfig lagg0 create laggproto failover laggport re0 laggport wlan0 up EOF $ ln -s /usr/local/etc/sv/wpa_supplicant /var/service $ ln -s /usr/local/etc/sv/dhclient-lagg0 /var/service $ ln -s /usr/local/etc/sv/rtsold /var/service
If it not clear that an interface is available yet e.g. because of using an USB ethernet device or similar, it can be polled for like this:
# Wait for ue0 ifconfig ue0 > /dev/null 2>&1 || exit 1
$ cat <<EOF > /usr/local/etc/runit/local #!/bin/sh ifconfig re0 inet 192.168.0.2/24 up route add default 192.168.0.1 EOF $ chmod +x /usr/local/etc/runit/local
To keep using the normal FreeBSD rc.conf-based networking setup:
$ cat <<EOF > /usr/local/etc/runit/local #!/bin/sh service netif quietstart service routing quietstart # or simply use /etc/netstart to run every networking related # rc.d script in the right order. EOF $ chmod +x /usr/local/etc/runit/local
Enable D-Bus, DSBMD, xdm:
$ ln -s /usr/local/etc/sv/dbus /var/service $ ln -s /usr/local/etc/sv/dsbmd /var/service $ ln -s /usr/local/etc/sv/xdm /var/service
For bash/oksh/sh add this to
if [ -z "$DISPLAY" ] && [ "$(tty)" == "/dev/ttyv0" ]; then exec startxfce4 fi
Create an autologin entry in
Then setup getty to use it:
echo "TYPE=al.Pctobias" > /usr/local/etc/sv/getty-ttyv0/conf
Make sure to enable and/or restart
As services start concurrently it might be a good idea to check for
service availability e.g. a running D-Bus and DSBMD before starting
your X session to prevent situations where the daemons start after
your X session. Append this to
sv check dbus > /dev/null || exit 1 sv check dsbmd > /dev/null || exit 1
set init_path=/rescue/initat the loader prompt.