Make sur resolvconf is populated before SSH key fetch

This commit is contained in:
fnux 2020-01-24 10:27:54 +01:00
parent 5f87c22ece
commit ceb657d237
3 changed files with 26 additions and 3 deletions

View File

@ -107,13 +107,37 @@ up_network_interfaces () {
done done
} }
# XXX: fail after N iterations?
wait_for_resolvconf () {
# Check if RDNSSD daemon is running.
if ! pgrep rdnssd; then
echo "RDNSSD does not seems to be running!" >&2
# XXX: start rdnssd?
fi
echo "Waiting for resolv.conf to be populated..."
if [ ! -f '/etc/resolv.conf' ]; then
if [ "$(wc -l < resolv.conf)" = "0" ]; then
sleep 1
wait_for_resolvconf
else
return
fi
else
touch '/etc/resolv.conf'
sleep 1
wait_for_resolvconf
fi
}
### ###
# Entrypoint. # Entrypoint.
if [ "$ENABLE_NETWORKING" = '1' ]; then if [ "$ENABLE_NETWORKING" = '1' ]; then
routine='up main network interface' routine='setting up networking'
echo "--- RUNNING $routine..." echo "--- RUNNING $routine..."
up_network_interfaces up_network_interfaces
wait_for_resolvconf
echo "--- DONE with $routine." echo "--- DONE with $routine."
fi fi

View File

@ -6,7 +6,7 @@
name="$RC_SVCNAME" name="$RC_SVCNAME"
depend() { depend() {
use net logger rdnssd use net logger
before sshd before sshd
} }

View File

@ -1,6 +1,5 @@
[Unit] [Unit]
Description=Initialize an Uncloud virtual machine Description=Initialize an Uncloud virtual machine
After=rdnssd.service
Before=network.target Before=network.target
Requires=network.target Requires=network.target