OpenWRT Configuration Using CLI and Scripts - micahgrinnell/CC-Capstone-Project GitHub Wiki

Overview

This page is for users who want to configure OpenWrt without the use of the GUI. After doing much research on using scripts to configure OpenWrt, I strongly suggest using the web GUI. This is mainly because OpenWrt uses the ash shell rather than the bash shell, which is a considerably smaller and less complex shell. One can install a full version of Bash but it requires the set up of a USB drive in order to have enough storage.

In my opinion, writing scripts using the ash shell seems brutally unnecessary unless you are an OpenWrt package/firmware developer. The only non-development reason I can find for configuring your device using scripts is to edit configuration files. Therefore, I created a simple ash script that adds new firewall rules to the config file. It uses the UCI (Unified Configuration Interface) OpenWrt supplies to create new rules and set their options. It's dead simple, but it works and demonstrates how scripts can be used within OpenWrt. To download or look at the script click the 'firewall_rule.sh' link. There are additional resources available on the OpenWrt website for how scripting works within their system, which I will list below.

firewall_rule.sh

Resources

Write shell scripts in OpenWrt

Configuration in scripts

Init scripts

Network scripts

The UCI system