| Line 68... |
Line 68... |
| 68 |
my $appDir = dirname(abs_path(__FILE__)) . '/';
|
68 |
my $appDir = dirname(abs_path(__FILE__)) . '/';
|
| 69 |
|
69 |
|
| 70 |
my $statusFile = $appDir . 'updatedns.status'; # stores current status of known entries
|
70 |
my $statusFile = $appDir . 'updatedns.status'; # stores current status of known entries
|
| 71 |
my $template = $appDir . 'updatedns.template'; # a template used for commands to nsupdate
|
71 |
my $template = $appDir . 'updatedns.template'; # a template used for commands to nsupdate
|
| 72 |
# If local set, use -l parameter, otherwise, use the key file
|
72 |
# If local set, use -l parameter, otherwise, use the key file
|
| 73 |
my $nsupdate = '/usr/bin/nsupdate ' . ( $configuration{'local'} ? '-l ' : " -k $configuration{keyfile} " );
|
73 |
my $nsupdate = `which nsupdate`; chomp $nsupdate;
|
| 74 |
my $configFile = $appDir . 'updatedns.conf';
|
74 |
my $configFile = $appDir . 'updatedns.conf';
|
| 75 |
|
75 |
|
| 76 |
my $hostname;
|
76 |
my $hostname;
|
| 77 |
my $realIP;
|
77 |
my $realIP;
|
| 78 |
my %entries;
|
78 |
my %entries;
|
| 79 |
|
79 |
|
| 80 |
# prepend 'server ' to the server command if it exists and we are not local
|
- |
|
| 81 |
$configuration{'server'} = "server $configuration{'server'}" if $configuration{'server'} and not $configuration{'local'};
|
- |
|
| 82 |
|
- |
|
| 83 |
# this reads an INI type file in the form
|
80 |
# this reads an INI type file in the form
|
| 84 |
# key:value
|
81 |
# key:value
|
| 85 |
# where : is any delimiter
|
82 |
# where : is any delimiter
|
| 86 |
# it then merges it into %$hash, overwriting anything with the same
|
83 |
# it then merges it into %$hash, overwriting anything with the same
|
| 87 |
# key with a new value
|
84 |
# key with a new value
|
| Line 123... |
Line 120... |
| 123 |
return `$nsupdate $nsupdateFileName`;
|
120 |
return `$nsupdate $nsupdateFileName`;
|
| 124 |
}
|
121 |
}
|
| 125 |
|
122 |
|
| 126 |
&readFile( $configFile, \%configuration, '=' );
|
123 |
&readFile( $configFile, \%configuration, '=' );
|
| 127 |
|
124 |
|
| - |
|
125 |
# prepend 'server ' to the server command if it exists and we are not local
|
| - |
|
126 |
$configuration{'server'} = "server $configuration{server}" if $configuration{'server'} and not $configuration{'local'};
|
| - |
|
127 |
# and set nsupdate for local or remote
|
| - |
|
128 |
$nsupdate .= $configuration{'local'} ? ' -l ' : " -k $configuration{keyfile} ";
|
| - |
|
129 |
|
| - |
|
130 |
|
| 128 |
#foreach my $key ( sort keys %configuration ) {
|
131 |
#foreach my $key ( sort keys %configuration ) {
|
| 129 |
# print "$key\t$configuration{$key}\n";
|
132 |
# print "$key\t$configuration{$key}\n";
|
| 130 |
#}
|
133 |
#}
|
| 131 |
#die;
|
134 |
# die;
|
| 132 |
|
135 |
|
| 133 |
# user should send hostname as a parameter on the command
|
136 |
# user should send hostname as a parameter on the command
|
| 134 |
# user may also send the IP
|
137 |
# user may also send the IP
|
| 135 |
|
138 |
|
| 136 |
if ( defined $ENV{'SSH_ORIGINAL_COMMAND'} ) {
|
139 |
if ( defined $ENV{'SSH_ORIGINAL_COMMAND'} ) {
|