Avoid calling a perl script for getting DNS-Servers from DHCP
Commit Message
This codes does the same as before but we do everythin in Bash now.
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
config/rootfiles/common/aarch64/initscripts | 1 -
config/rootfiles/common/armv5tel/initscripts | 1 -
config/rootfiles/common/i586/initscripts | 1 -
config/rootfiles/common/x86_64/initscripts | 1 -
src/initscripts/helper/getdnsfromdhcpc.pl | 47 ----------------------------
src/initscripts/networking/dhcpcd.exe | 16 ++++++++--
6 files changed, 14 insertions(+), 53 deletions(-)
delete mode 100644 src/initscripts/helper/getdnsfromdhcpc.pl
@@ -2,7 +2,6 @@ etc/init.d
#etc/rc.d
#etc/rc.d/helper
etc/rc.d/helper/aws-setup
-etc/rc.d/helper/getdnsfromdhcpc.pl
#etc/rc.d/init.d
etc/rc.d/init.d/acpid
etc/rc.d/init.d/apache
@@ -2,7 +2,6 @@ etc/init.d
#etc/rc.d
#etc/rc.d/helper
etc/rc.d/helper/aws-setup
-etc/rc.d/helper/getdnsfromdhcpc.pl
#etc/rc.d/init.d
etc/rc.d/init.d/acpid
etc/rc.d/init.d/apache
@@ -2,7 +2,6 @@ etc/init.d
#etc/rc.d
#etc/rc.d/helper
etc/rc.d/helper/aws-setup
-etc/rc.d/helper/getdnsfromdhcpc.pl
#etc/rc.d/init.d
etc/rc.d/init.d/acpid
etc/rc.d/init.d/apache
@@ -2,7 +2,6 @@ etc/init.d
#etc/rc.d
#etc/rc.d/helper
etc/rc.d/helper/aws-setup
-etc/rc.d/helper/getdnsfromdhcpc.pl
#etc/rc.d/init.d
etc/rc.d/init.d/acpid
etc/rc.d/init.d/apache
deleted file mode 100644
@@ -1,47 +0,0 @@
-#!/usr/bin/perl
-###############################################################################
-# #
-# IPFire.org - A linux based firewall #
-# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
-# #
-# This program is free software: you can redistribute it and/or modify #
-# it under the terms of the GNU General Public License as published by #
-# the Free Software Foundation, either version 3 of the License, or #
-# (at your option) any later version. #
-# #
-# This program is distributed in the hope that it will be useful, #
-# but WITHOUT ANY WARRANTY; without even the implied warranty of #
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
-# GNU General Public License for more details. #
-# #
-# You should have received a copy of the GNU General Public License #
-# along with this program. If not, see <http://www.gnu.org/licenses/>. #
-# #
-###############################################################################
-
-use strict;
-require '/var/ipfire/general-functions.pl';
-
-my $count = $ARGV[0];
-my ($dhcp, $dns, @alldns, %dhcpc);
-
-if ($count eq "" || $count < 1) {
- die "Bad DNS number given"; }
-
-if (open(FILE, "${General::swroot}/red/iface")) {
- my $iface = <FILE>;
- close FILE;
- chomp ($iface);
- if (!&General::readhash("${General::swroot}/dhcpc/dhcpcd-$iface.info", \%dhcpc)) {
- die "Could not open dhcpc info file";
- }
-} else {
- die "Could not open interface file";
-}
-
-
-$dns = $dhcpc{'domain_name_servers'};
-
-@alldns = split(' ', $dns);
-
-print "$alldns[$count - 1]\n";
@@ -49,8 +49,20 @@ dhcpcd_up()
echo -n ${DNS0} > /var/ipfire/red/dns1
echo -n ${DNS1} > /var/ipfire/red/dns2
else
- echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > /var/ipfire/red/dns1
- echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > /var/ipfire/red/dns2
+ # Check that we get DNS-Servers from our DHCP Server
+ if [ -n "${new_domain_name_servers}" ]; then
+ # Convert the string into an arry
+ dhcp_dns_servers=(${new_domain_name_servers})
+ # We need 2 DNS-Servers
+ if [ ${#dhcp_dns_servers[@]} -lt 2 ]; then
+ logger -p local0.error -t dhcpcd.exe[$$] "DHCP Server does provides less then two DNS-Servers"
+ else
+ echo -n "${dhcp_dns_servers[0]}" > /var/ipfire/red/dns1
+ echo -n "${dhcp_dns_servers[1]}" > /var/ipfire/red/dns2
+ fi
+ else
+ logger -p local0.error -t dhcpcd.exe[$$] "DHCP Servers does not provide any DNS-Servers."
+ fi
fi
#Get IP Address