Avoid syntax error in dhcpd.conf if values for DNS and Gateway
authorMichael Prokop <mika@grml.org>
Wed, 22 Nov 2006 10:17:58 +0000 (11:17 +0100)
committerMichael Prokop <mika@grml.org>
Wed, 22 Nov 2006 10:17:58 +0000 (11:17 +0100)
are empty, thanks for the patch - Wolfgang Karall!

debian/changelog
templates/dhcpd_config

index 7a3bf35..48f2d55 100644 (file)
@@ -1,3 +1,10 @@
+grml-terminalserver (0.77) unstable; urgency=low
+
+  * Avoid syntax error in dhcpd.conf if values for DNS and Gateway
+    are empty, thanks for the patch - Wolfgang Karall!
+
+ -- Michael Prokop <mika@grml.org>  Wed, 22 Nov 2006 11:16:46 +0100
+
 grml-terminalserver (0.76) unstable; urgency=low
 
   * Support bootoption dhcp_iface via /linuxrc for selection of
index 2b847c7..824b42e 100644 (file)
 date_=`execute date warn`
 
 # insert commas when having multiple nameservers
-DNS_=$(echo "$NAMESERVERS_" | sed -e 's/\([0-9]\) \([0-9]\)/\1, \2/g')
+if [ -n "$NAMESERVERS_" ]; then
+       DNS_LINE_="option domain-name-servers $(echo "$NAMESERVERS_" | sed -e 's/\([0-9]\) \([0-9]\)/\1, \2/g');"
+fi
 # note: we don't support multiple routers options
+if [ -n "$GW_" ]; then
+       ROUTERS_LINE_="option routers $GW_;"
+fi
 
 cat >"$DHCPD_CONFIG_FILE_" <<EOT
 # ${DHCPD_CONFIG_FILE_##/*/} for GRML terminalserver
@@ -51,8 +56,8 @@ subnet $NETWORK_ netmask $NETMASK_ {
   else { filename "pxelinux.0"; }
 #  option subnet-mask $NETMASK_;
   range $IPRANGE_FROM_ $IPRANGE_TO_;
-  option routers $GW_;
-  option domain-name-servers $DNS_;
+  $ROUTERS_LINE_
+  $DNS_LINE_
 #  option T150 "/menu.lst";
 #  option option-150 "(nd)/menu.lst";
 }