OpenWRT Management Tools

Collection of tools for managing OpenWRT infrastructure.

Included tools:

  • bin/deploy
    • Uploads configuration generated from templates
  • bin/list
    • Prints a table of information on the OpenWRT devices
  • bin/scan
    • Prints a table of nearby OpenWRT wifi networks
  • bin/generate-connect-scripts
    • Generate scripts to connect to OpenWRT networks with wpa_supplicant
    • Generated scripts will be in bin/connect
  • bin/disconnect
    • Kills all running wpa_supplicant and flushes wifi interface ip
  • bin/current
    • Prints the current OpenWRT network you're connected to

Installation

Required software

  • python3
  • virtualenv
  • iwlist (for scanning)
  • wpa_supplicant (for connecting)
  • ip (for disconnecting)

Gitlab account

Make an account on the gitlab server and get access to the openwrt-tools repository.

Install steps

git clone git@fringecup:ocfit/tools/openwrt-tools.git && cd openwrt-tools
virtualenv venv && ./venv/bin/pip install -r requirements

Configuration

Local configuration

Local configuration is used to configure the username/password to log into the devices and the interface name of the local wifi card (for scanning, connecting, etc).

The file config/local.yml must be created before using the tools. There is an example config/local.yml.example to copy as a starting point, for example:

cp config/local.yml.example config/local.yml

Host configuration

Hosts are automatically detected from files created in config/host. The name of the file corresponds with the DNS name of the host. The host files can contain yaml, which gets passed into every template as variables before being copied to the host.

The file host_base.yml must be created before using the tools. There is an example host_base.yml.example config to copy as a starting point, for example:

cp config/host_base.yml.example config/host_base.yml

Specific configuration can also be applied to the rap and lap host groups in config/host_groups.yml. The order of configuration is applied as follows:

base file + group (rap/lap only) file + host specific file

Tools

Tools are located in the `bin` folder.

Scanning for nodes

To scan for nodes nearby:

./bin/scan

Connecting to nodes

NOTE You must kill all NetworkManager related processes. You must have wpa_supplicant installed.

To generate binaries used to connect, run:

./bin/generate-connect-scripts

Aftewards, you will have binaries in bin/wpa_supplicant that match the network names. For example:

./bin/connect/OCFnet_Vendors_wb

If you would like to also have the script try to get an IP via DHCP, simply pass the argument ip to the script:

./bin/connect/OCFnet_Vendors_wb ip

To print a table summary of the current OpenWRT hosts:

./bin/list

Deploy configuration

Templates are automatically detected and loaded from the config/templates directory. Templates can be any kind of file and do not have to use variables. For more information on how to use templating, please refer to the Jinja2 documentation.

For command information:

./bin/deploy -h

To create all the config files in a folder called dry, but not upload:

./bin/deploy -d

To deploy the configuration to all hosts:

./bin/deploy -v

To limit the deployment of configuration to specific hosts:

./bin/deploy -v -l rap1,rap2

This topic: OCF > WebHome > OCFIT > OpenWRT_Tools
Topic revision: 2019 Jul 15, spectralsun
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback