EdgeRouter - Add Commands to EdgeOS
Overview
Readers will learn how to add custom commands to the EdgeOS command line interface.
Adding Custom Commands
In this example, an Operational Mode command is added to the command line that resets the console session (clear screen).
When first running the reset command, a single option exists:
ubnt@edgerouter:~$ reset ?
Possible completions:
openvpn Reset OpenVPN
1. Log in as the root user.
sudo su
2. Navigate to the /opt/vyatta/share/vyatta-op/templates/reset directory.
cd /opt/vyatta/share/vyatta-op/templates/reset
3. Create a new directory named console.
mkdir console
4. Navigate to the newly created console directory.
cd console
5. Create a new file named node.def in the console directory and add the following contents (note the empty line at the bottom).
cat > node.def
help: Reset the Console
run: /usr/bin/reset
6. Use CTRL+D to exit out and save the script.
7. Exit back to the EdgeOS command line.
exit
Verify the configuration by trying out the new command:
ubnt@edgerouter:~$ reset ?
Possible completions:
console Reset the Console
openvpn Reset OpenVPN
ubnt@edgerouter:~$ reset console
Related Articles
EdgeRouter - Configuration and Operational Mode
EdgeRouter - Run Operational Mode Command from Scripts
Intro to Networking - How to Establish a Connection Using SSH