summaryrefslogtreecommitdiff
path: root/scripts/vyatta-update-static-route.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/vyatta-update-static-route.pl')
-rwxr-xr-xscripts/vyatta-update-static-route.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/vyatta-update-static-route.pl b/scripts/vyatta-update-static-route.pl
new file mode 100755
index 00000000..5ac98fcd
--- /dev/null
+++ b/scripts/vyatta-update-static-route.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use Getopt::Long;
+use strict;
+use lib "/opt/vyatta/share/perl5";
+use Vyatta::Config;
+
+my ($iface, $route, $table, $option);
+GetOptions("interface=s" => \$iface,
+ "route=s" => \$route,
+ "table=s" => \$table,
+ "option=s" => \$option
+ );
+my $hash = `echo $iface $route $table | md5sum | cut -c1-10`;
+my $FILE_DHCP_HOOK = "/etc/dhcp3/dhclient-exit-hooks.d/static-route-$hash";
+my $dhcp_hook = '';
+if ($option eq 'create') {
+ $dhcp_hook =<<EOS;
+#!/bin/sh
+/opt/vyatta/bin/sudo-users/vyatta-static-dhcp.pl --interface=\"\$interface\" --dhcp=\"$iface\" --route=\"$route\" --table=\"$table\" --new_routers=\"\$new_routers\" --old_routers=\"\$old_routers\" --reason=\"\$reason\"
+EOS
+}
+
+open my $dhcp_hook_file, '>', $FILE_DHCP_HOOK
+ or die "cannot open $FILE_DHCP_HOOK";
+print ${dhcp_hook_file} $dhcp_hook;
+close $dhcp_hook_file;
+exit 0;
+