Upcoming Maintenance Alert:

The UBNT Community will be upgraded at 5pm MDT on April 25th. During this time the community forums will be set to read-only status.

Learn more

×
Reply
New Member
Posts: 20
Registered: ‎01-21-2014
Kudos: 6
Solutions: 1
Accepted Solution

script

Hello

I have made a script to disable and enable interface.

 

#!/bin/bash
run=/opt/vyatta/bin/vyatta-op-cmd-wrapper

if ping -c 10 192.168.100.254 &> /dev/null
then
echo "UP"
$run configure
delete interfaces ethernet eth2 disable
commit
else
echo "DOWN"
$run configure
set interfaces ethernet eth2 disable
commit
fi

But It doesn't work

 

Maybe, someone knows how to do it correct? 

 

Best regards


Accepted Solutions
Senior Member
Posts: 4,434
Registered: ‎03-24-2016
Kudos: 1224
Solutions: 513

Re: script

Try below:   (and add if then logic at will )

 

#!/bin/vbash
WR="/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper"


$WR begin
$WR set interfaces ethernet eth2 disable
$WR commit
$WR end

Also try executing as root

View solution in original post

New Member
Posts: 20
Registered: ‎01-21-2014
Kudos: 6
Solutions: 1

Re: script

#!/bin/bash
WR="/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper"

if ping -c 10 10.33.2.1 &> /dev/null
then
echo "UP"
$WR begin
$WR delete interfaces ethernet eth2 disable
$WR commit
$WR end
else
echo "DOWN"
$WR begin
$WR set interfaces ethernet eth2 disable
$WR commit
$WR end
fi

It works!

 

Thak you very much! Man Wink

 

View solution in original post


All Replies
Established Member
Posts: 1,487
Registered: ‎05-03-2016
Kudos: 497
Solutions: 144

Re: script

Try vbash instead of bash.

Put $run in front of all config commands set, delete, commit.

May want exit after commit but cannot remember for sure.
New Member
Posts: 20
Registered: ‎01-21-2014
Kudos: 6
Solutions: 1

Re: script

I have tried but still it doesn't work Man Sad 

Senior Member
Posts: 4,434
Registered: ‎03-24-2016
Kudos: 1224
Solutions: 513

Re: script

Try below:   (and add if then logic at will )

 

#!/bin/vbash
WR="/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper"


$WR begin
$WR set interfaces ethernet eth2 disable
$WR commit
$WR end

Also try executing as root

New Member
Posts: 20
Registered: ‎01-21-2014
Kudos: 6
Solutions: 1

Re: script

#!/bin/bash
WR="/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper"

if ping -c 10 10.33.2.1 &> /dev/null
then
echo "UP"
$WR begin
$WR delete interfaces ethernet eth2 disable
$WR commit
$WR end
else
echo "DOWN"
$WR begin
$WR set interfaces ethernet eth2 disable
$WR commit
$WR end
fi

It works!

 

Thak you very much! Man Wink

 

Reply