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
}
# 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.
if [ "$ENABLE_NETWORKING" = '1' ]; then
routine='up main network interface'
routine='setting up networking'
echo "--- RUNNING $routine..."
up_network_interfaces
wait_for_resolvconf
echo "--- DONE with $routine."
fi

View file

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

View file

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