summaryrefslogtreecommitdiffstats
path: root/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
diff options
context:
space:
mode:
authorSimon Rettberg2021-08-11 15:58:09 +0200
committerSimon Rettberg2021-08-11 15:58:09 +0200
commit6995afb6f1b01938e4a3ca0daf375dfe276181d5 (patch)
tree3b8883351554bc4f7f949495c8164a99d0403be5 /core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
parent[redsocks] Upper- and lowercase proxy env (diff)
downloadmltk-6995afb6f1b01938e4a3ca0daf375dfe276181d5.tar.gz
mltk-6995afb6f1b01938e4a3ca0daf375dfe276181d5.tar.xz
mltk-6995afb6f1b01938e4a3ca0daf375dfe276181d5.zip
Implement blocking network.target and network-online.target
Add two services that will delay reaching the according targets, until conditions we consider reasonable are reached. For network.target that is finishing DHCP for the primary interface, for network-online.target we want to see a default gateway or a proxy server configured. Both have a timeout of about 10 seconds for now; this might be increased later on, if necessary.
Diffstat (limited to 'core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx')
-rwxr-xr-xcore/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx37
1 files changed, 9 insertions, 28 deletions
diff --git a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
index 05cded10..3e30da55 100755
--- a/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
+++ b/core/modules/dhcpc-busybox/data/opt/openslx/scripts/udhcpc-openslx
@@ -24,6 +24,7 @@ declare -rg primary="${SLX_BRIDGE:-br0}"
declare -rg RESOLV_CONF="/opt/openslx/resolv.conf"
declare -rg THIS_RESOLV="/run/network/${interface}.resolv"
+declare -rg flag="/run/network/primary-dhcp.flag"
shopt -s extglob
@@ -94,15 +95,6 @@ check_env() {
fi
}
-if [ ! -d /run ]; then
- echo -n "Waiting for /run." >&2
- while [ ! -d /run ]; do
- echo -n "." >&2
- usleep 500000
- done
- echo "" >&2
-fi
-
mkdir -p "/run/network"
case "$1" in
@@ -190,34 +182,31 @@ case "$1" in
fi
# Only if network is not ready yet
- if ! [ -e "/run/network/network-ready" ] || ! [ -e "/etc/hostname" ] || grep -q '^noname-' "/etc/hostname"; then
+ if ! [ -e "$flag" ]; then
# Update hostname
if [ -z "$dns_fqdn" ] && [ -n "$domain" ] && [ -n "$hostname" ]; then
# fallback to what the dhcp told us
dns_fqdn="${hostname}.${domain}"
fi
- if [ -z "$dns_fqdn" ]; then
- # only if there is no /etc/hostname, we fall back (far back, that is)
- [ ! -s "/etc/hostname" ] && dns_fqdn="slx-client"
+ if [ -z "$dns_fqdn" ] && ! [ -s "/etc/hostname" ]; then
+ dns_fqdn="noname-${ip//./-}"
fi
# finally, if dns_fqdn was set to anything, apply it
if [ -n "$dns_fqdn" ]; then
dns_short="${dns_fqdn%%.*}"
echo "$dns_short" > "/proc/sys/kernel/hostname"
echo "$dns_short" > "/etc/hostname"
- if grep '^SLX_HOSTNAME=' /opt/openslx/config 2>/dev/null; then
- sed -i "s/^\(SLX_HOSTNAME=\).*$/\1'$dns_short'/" /opt/openslx/config
- else
+ if [ -z "$SLX_HOSTNAME" ]; then
echo "# Config written by openslx-dhcp-script (1)" >> /opt/openslx/config
echo "SLX_HOSTNAME='$dns_short'" >> /opt/openslx/config
+ elif [ "$SLX_HOSTNAME" != "$dns_short" ]; then
+ sed -i "s/^\(SLX_HOSTNAME=\).*$/\1'$dns_short'/" /opt/openslx/config
fi
fi
# Update /etc/issue for proper spacing
/opt/openslx/scripts/openslx-create_issue
- touch "/run/network/network-ready"
- # Mark network target as reached
- systemctl start network.target &
+ touch "$flag"
fi # end "network not ready yet"
# Remove any stray addresses; we expect the primary interface to only have one
# address supplied via DHCP. We do this after adding the new one, obviously.
@@ -253,18 +242,10 @@ case "$1" in
# Get rid of orphaned lines in /etc/hosts
sed -i -r '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/d' /etc/hosts
- # "dns ready" target
- if [ -n "$dns" ] && [ ! -e "/run/network/dns-ready" ]; then
- touch "/run/network/dns-ready"
+ if [ -n "$dns" ] && [ -z "$SLX_DNS" ]; then
# Write to openslx-config
echo "# Config written by openslx-dhcp-script (2)" >> /opt/openslx/config
echo "SLX_DNS='$dns'" >> /opt/openslx/config
- systemctl start network-dns.target &
- fi
- # "default route exists" target
- if [ -n "$router" ] && [ ! -e "/run/network/gateway-ready" ]; then
- touch "/run/network/gateway-ready"
- systemctl start network-gateway.target &
fi
;;