EdgeRouter - How can I use scripts to change the configuration?

Answer


Here is an example script to change a tunnel IP address. 

ubnt@ubnt:~$ cat change_tun_ip
#!/bin/vbash if [ $# == 0 ]; then echo usage: $0 exit 1 fi new_ip=$1; source /opt/vyatta/etc/functions/script-template configure set interfaces tunnel tun0 local-ip $new_ip commit
save exit

Here's an example script to enable/disable PoE on an interface of EdgeRouter PoE:

#!/bin/vbash
if [ $# -ne 2 ]; then
   echo "usage: $0  [24v|48v|off]";
   exit 1;
fi
intf=$1
val=$2
     
poe=`/usr/sbin/ubnt-hal-e hasPoeE`
if [ "$poe" != 1 ]; then
   echo This platform does not support PoE;
   exit 1;
fi
source /opt/vyatta/etc/functions/script-template
     
configure
set interfaces ethernet $intf poe output $val
commit
save
exit

 

There is also some good info on the shell-API at Vyatta's CLI shell API page.

UBNT-Stig

Powered by Zendesk