/[packages]/cauldron/dhcp/current/SOURCES/update_dhcp.pl
ViewVC logotype

Contents of /cauldron/dhcp/current/SOURCES/update_dhcp.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 16733 - (show annotations) (download)
Thu Jan 13 23:42:18 2011 UTC (10 years, 5 months ago) by dmorgan
File MIME type: text/plain
File size: 1809 byte(s)
imported package dhcp
1 #!/usr/bin/perl -W
2
3 #----------------------------------------------------------------------
4 # copyright (C) 2001 Florin Grad
5 #
6 # This is a really silly program that is supposed to allow an update of
7 # a dhcp-2* server to a dhcp-3* server
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #------------------------------------------------------------------------
22
23 #search for a ddns-update-style entry in /etc/dhcpd.conf file
24 my $conf_file = "/etc/dhcpd.conf"; #$ARGV[0];
25 my $conf_file_orig = "/etc/dhcpd.conf.orig";
26 my $i=0;
27 open (DHCPCONF, "< $conf_file") or die "Can't open the $conf_file file for reading";
28 while (<DHCPCONF>) {
29 if (/ddns-update-style/) {
30 $i++;
31 };
32 };
33 close (DHCPCONF);
34
35 if ($i == 0) { #we are on a dhcp-2
36 rename("$conf_file","$conf_file_orig") || die "Can't rename $conf_file: $!";
37 open (DHCPCONF, "> $conf_file") or die "Can't open the $conf_file file for writing";
38 print DHCPCONF "ddns-update-style none;\n";
39 open (DHCPCONF_ORIG, "< $conf_file_orig") or die "Can't open the $conf_file_orig file for reading";
40 while (<DHCPCONF_ORIG>) {
41 print DHCPCONF "$_";
42 };
43 close (DHCPCONF_ORIG);
44 close (DHCPCONF);
45 }

  ViewVC Help
Powered by ViewVC 1.1.28