From: Alyssa Ross <hi@alyssa.is> Not all VMs will even have networking! So it makes more sense to put waiting for the network in the application-specific part. The "listen" and "wait" scripts are copied from the host system. Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com> --- This patch comes from before I started working on this at Unikie, hence the non-Unikie author email. img/app/Makefile | 2 ++ img/app/etc/mdev/iface | 2 +- img/app/etc/mdev/listen | 12 ++++++++++++ img/app/etc/mdev/wait | 15 +++++++++++++++ img/app/etc/s6-rc/ok-all/contents | 1 + vm/app/catgirl.nix | 1 + vm/app/lynx.nix | 1 + 7 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 img/app/etc/mdev/listen create mode 100755 img/app/etc/mdev/wait diff --git a/img/app/Makefile b/img/app/Makefile index c5a4684..a3fefc3 100644 --- a/img/app/Makefile +++ b/img/app/Makefile @@ -47,6 +47,8 @@ VM_FILES = \ etc/init \ etc/mdev.conf \ etc/mdev/iface \ + etc/mdev/listen \ + etc/mdev/wait \ etc/passwd \ etc/resolv.conf \ etc/s6-linux-init/scripts/rc.init diff --git a/img/app/etc/mdev/iface b/img/app/etc/mdev/iface index d8ceda5..4cdc112 100755 --- a/img/app/etc/mdev/iface +++ b/img/app/etc/mdev/iface @@ -33,4 +33,4 @@ foreground { } } -s6-rc -u change app +/etc/mdev/listen network-online diff --git a/img/app/etc/mdev/listen b/img/app/etc/mdev/listen new file mode 100755 index 0000000..6bc6f2c --- /dev/null +++ b/img/app/etc/mdev/listen @@ -0,0 +1,12 @@ +#!/bin/execlineb -s1 +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is> + +foreground { + redirfd -w 2 /dev/null + foreground { mkdir /run/wait } + mkfifo /run/wait/${1} +} + +redirfd -w 1 /run/wait/${1} +echo diff --git a/img/app/etc/mdev/wait b/img/app/etc/mdev/wait new file mode 100755 index 0000000..3b85de8 --- /dev/null +++ b/img/app/etc/mdev/wait @@ -0,0 +1,15 @@ +#!/bin/execlineb -s1 +# SPDX-License-Identifier: EUPL-1.2+ +# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is> + +foreground { + redirfd -w 2 /dev/null + foreground { mkdir /run/wait } + mkfifo /run/wait/${1} +} + +foreground { + redirfd -w 1 /dev/null + head -1 /run/wait/${1} +} +rm /run/wait/${1} diff --git a/img/app/etc/s6-rc/ok-all/contents b/img/app/etc/s6-rc/ok-all/contents index c4ea84f..92f3ef1 100644 --- a/img/app/etc/s6-rc/ok-all/contents +++ b/img/app/etc/s6-rc/ok-all/contents @@ -2,3 +2,4 @@ # SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is> # mdevd-coldplug +app diff --git a/vm/app/catgirl.nix b/vm/app/catgirl.nix index 107ff82..79c5d8b 100644 --- a/vm/app/catgirl.nix +++ b/vm/app/catgirl.nix @@ -10,6 +10,7 @@ import ../../vm-lib/make-vm.nix { inherit config; } { { writeScript, catgirl }: writeScript "run-catgirl" '' #!/bin/execlineb -P + if { /etc/mdev/wait network-online } foreground { printf "IRC nick (to join #spectrum): " } backtick -E nick { head -1 } ${catgirl}/bin/catgirl -h irc.libera.chat -j "#spectrum" -n $nick diff --git a/vm/app/lynx.nix b/vm/app/lynx.nix index 8fc3bd6..6abaf9b 100644 --- a/vm/app/lynx.nix +++ b/vm/app/lynx.nix @@ -10,6 +10,7 @@ import ../../vm-lib/make-vm.nix { inherit config; } { { writeScript, lynx }: writeScript "run-lynx" '' #!/bin/execlineb -P + if { /etc/mdev/wait network-online } ${lynx}/bin/lynx https://spectrum-os.org '' ) { }; -- 2.37.1