#!/usr/bin/perl
#
# This code is distributed under the terms of the GPL
#
# (c) 2012 An NGUYEN http://www.vyatta.vn
#
# $Id: install-SLA,v 1.0 2012/01/01 00:00:00 Vyatta Vietnam Exp $
#

use Cwd;
use File::Path;
use File::Copy;

print "==================Create Temporary files=================\n"; 
$tarfile = "inf-bnd.tar.gz";
$currentdir = cwd;
$tempdir = $currentdir . "/tmp";
if (!(-d "$tempdir")) { mkdir("$tempdir") };
system("/bin/tar -C $tempdir -xzvf $currentdir/$tarfile");

print "==================Update the bonding for OpenVPN connections=========\n";
$destdir = "/opt/vyatta/share/vyatta-cfg/templates/interfaces/openvpn/node.tag/bond-group";
if (!(-d "$destdir")) { mkdir("$destdir") };
$sourcedir = $tempdir . "/openvpn-bond-group/*";
system("rm -rf $destdir/*"); 
system("cp -pr $sourcedir $destdir ");

print "==================Update the bonding for Tunnel connections=========\n";
$destdir = "/opt/vyatta/share/vyatta-cfg/templates/interfaces/tunnel/node.tag/bond-group";
if (!(-d "$destdir")) { mkdir("$destdir") };
$sourcedir = $tempdir . "/tunnel-bond-group/*";
system("rm -rf $destdir/*"); 
system("cp -pr $sourcedir $destdir ");

print "===================clean temporary files==================\n";
system("rm -fr $tempdir ");

print "The Upgrading for interface bonding was patched successfully in this system.";


#system("init 6");

print "\n";

print "\n";

