diff options
author | Christian Rößler | 2013-07-02 16:49:59 +0200 |
---|---|---|
committer | Christian Rößler | 2013-07-02 16:49:59 +0200 |
commit | 83723407009b641d0700aaca213650d7f8345c6f (patch) | |
tree | df202c6fe63505558ca94535179c07cda9bad395 /remote/rootfs | |
parent | + X localization libs (diff) | |
parent | add nscd link to stage32-opensuse (diff) | |
download | tm-scripts-83723407009b641d0700aaca213650d7f8345c6f.tar.gz tm-scripts-83723407009b641d0700aaca213650d7f8345c6f.tar.xz tm-scripts-83723407009b641d0700aaca213650d7f8345c6f.zip |
Merge branch 'master' of git.openslx.org:openslx-ng/tm-scripts
Diffstat (limited to 'remote/rootfs')
-rw-r--r-- | remote/rootfs/rootfs-stage32/data/etc/hosts | 8 | ||||
-rwxr-xr-x | remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script | 36 |
2 files changed, 43 insertions, 1 deletions
diff --git a/remote/rootfs/rootfs-stage32/data/etc/hosts b/remote/rootfs/rootfs-stage32/data/etc/hosts new file mode 100644 index 00000000..631cf753 --- /dev/null +++ b/remote/rootfs/rootfs-stage32/data/etc/hosts @@ -0,0 +1,8 @@ +127.0.0.1 localhost + +# The following lines are desirable for IPv6 capable hosts +::1 ip6-localhost ip6-loopback +fe00::0 ip6-localnet +ff00::0 ip6-mcastprefix +ff02::1 ip6-allnodes +ff02::2 ip6-allrouters diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script index 08d59eba..1bbf6e80 100755 --- a/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script +++ b/remote/rootfs/rootfs-stage32/data/opt/openslx/bin/udhcpc.openslx.script @@ -29,6 +29,14 @@ rebuild_resolv_conf () { sort -u /run/udhcpc/*.resolv > "$RESOLV_CONF" } +escape_search() { + echo "$@" | sed -e 's/[]\/()$*.^|[]/\\&/g' +} + +escape_replace() { + echo "$@" | sed -e 's/[\/&]/\\&/g' +} + case "$1" in bound|renew) ip addr add "$ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//)" dev "$interface" @@ -39,7 +47,7 @@ case "$1" in # Update resolver configuration file CONF="" if [ -n "$domain" ]; then - printf -v CONF "domain $domain\n" + printf -v CONF "domain $domain\nsearch $domain\n" elif [ -n "$SLX_NET_DOMAIN" ]; then printf -v CONF "domain $SLX_NET_DOMAIN\nsearch $SLX_NET_DOMAIN\n" fi @@ -81,6 +89,32 @@ case "$1" in fi fi + # Hostname in /etc/hosts + touch /etc/hosts + if [ -n "$dns_host" ]; then + short="${dns_host%%.*}" + [ "x$short" = "x$dns_host" ] && short="" + sed -i -r "s/\s$(escape_search "$dns_host")(\s|$)/ /g" /etc/hosts + [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts + if grep -q -E "^$ip\s" /etc/hosts; then + sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $dns_host $short ")/g" /etc/hosts + else + echo "$ip $dns_host $short" >> /etc/hosts + fi + fi + if [ -n "$hostname" -a "x$hostname" != "x$dns_host" ]; then + short="${hostname%%.*}" + [ "x$short" = "x$hostname" ] && short="" + sed -i -r "s/\s$(escape_search "$hostname")(\s|$)/ /g" /etc/hosts + [ -n "$short" ] && sed -i -r "s/\s$(escape_search "$short")(\s|$)/ /g" /etc/hosts + if grep -q -E "^$ip\s" /etc/hosts; then + sed -i "s/^$(escape_search "$ip")\s/$(escape_replace "$ip $hostname $short ")/g" /etc/hosts + else + echo "$ip $hostname $short" >> /etc/hosts + fi + fi + sed -i -r '/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/d' /etc/hosts + # We consider the network setup to be complete if an interface is being configured that # has a default route and some dns servers set. if [ -n "$router" ] && [ -n "$dns" ] && [ ! -e "/run/udhcpc/network-ready" ]; then |