#!/bin/bash # ----------------------------------------------------------------------------- # # Copyright (c) 2011 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING # # If you have any feedback please consult http://openslx.org/feedback and # send your suggestions, praise, or complaints to feedback@openslx.org # # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # # Mini-Linux Toolkit # # ----------------------------------------------------------------------------- RESOLV_CONF="/etc/resolv.conf" IP_CONF="/tmp/udhcpc_ip_config" export PATH=$PATH:/openslx/sbin:/openslx/bin case $1 in bound|renew) [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast" [ -n "$subnet" ] && NETMASK="netmask $subnet" ip addr add $ip/$(ipcalc -s -p $ip $subnet|sed s/.*=//) dev $interface ip route add default via $router echo "ip=$ip" > $IP_CONF echo "subnet=$subnet" >> $IP_CONF echo "broadcast=$broadcast" >> $IP_CONF echo "gateway=$router" >> $IP_CONF # Update resolver configuration file R="" [ -n "$domain" ] && R="domain $domain " count=1; for i in $dns; do echo "$0: Adding DNS $i" R="${R}nameserver $i " count=$((count+1)); done if [ -x /sbin/resolvconf ]; then echo -n "$R" | resolvconf -a "${interface}.udhcpc" else echo -n "$R" > "$RESOLV_CONF" fi # TODO i.e. event trigger systemctl start nfs-mount.service ;; deconfig) ;; leasefail) echo "$0: Lease failed: $message" ;; nak) echo "$0: Received a NAK: $message" ;; *) echo "$0: Unknown udhcpc command: $1"; exit 1; ;; esac