# OpenWrtScripts turns a router into something you can measure, label and hand over

> OpenWrtScripts is a collection of shell scripts for OpenWrt routers that report configuration, restore packages after a sysupgrade, print a physical label with credentials, and measure idle line latency. It suits a home lab operator with a pile of secondhand routers, and it is a set of scripts you copy onto the device rather than a package you install.

**richb-hanover/OpenWrtScripts** — A set of scripts for maintaining and testing OpenWrt

- Repository: https://github.com/richb-hanover/OpenWrtScripts
- Stars: 634 · Forks: 110
- Language: Shell
- License: GPL-2.0
- Published: 2026-10-21 · Updated: 2026-10-21 · Language: en
- Canonical page: https://hysenlabs.com/projects/richb-hanover-openwrtscripts

## The collection is a pile of router admin jobs, not a framework

The framing in the documentation is unusual and honest. These are scripts, sometimes also called Openscripts, that report, configure and measure, and improve, latency in home routers, and they work for OpenWrt. The repository layout shows a flat collection of individual shell scripts at the top level, getstats.sh, opkgscript.sh, config-openwrt.sh, config-spare-router.sh, print-router-label.sh, betterspeedtest.sh, netperfrunner.sh, idlelatency.sh and tunnelbroker.sh, plus a lib directory, a tests directory, a TestScripts directory and a printable-label directory that packages one of the ideas as a proper OpenWrt package. The audience is therefore a person with a home lab and a drawer of routers, not a developer building a product. The scripts share nothing more than a subject, which is why they are worth reading one by one rather than as a single tool.

## getstats.sh collects the output you would otherwise ask for by hand

The diagnostic script is the most immediately useful one, and its purpose is stated plainly. The getstats.sh script helps diagnose problems with OpenWrt, and if you report a problem it is always helpful to include the output of this script. The mechanism is straightforward: it executes a built-in set of commands and writes the collected output to /tmp/openwrtstats.txt, it also executes commands passed as arguments on the command line, and it also displays a list of user-installed opkg packages, meaning those not installed by default. The usage is `sh getstats.sh "ls /usr/lib" "ls -al /etc/config"`, which in the example produces the standard set of command results plus the two additional arguments. The script is self-contained and can be placed in any directory, and the top of the getstats.sh file carries a simple procedure for using it. A sample output file is included in the repository under sample_output, which is a reasonable way to see what you get before running it on a live device.

## opkgscript.sh is deprecated, and OpenWrt has a better answer now

One script in the collection has been overtaken by the distribution itself, and the documentation says so rather than quietly leaving it in place. The opkgscript.sh script is marked deprecated. It still works, but the note explains that when upgrading to a new OpenWrt release, a far easier option is to use Attended Sysupgrade in recent versions of OpenWrt. What the script did was save the list of installed packages, so they could be restored after a sysupgrade or a clean install of either LEDE or OpenWrt. By default the write command saves that list to /etc/config/opkg.installed, where it will be preserved across sysupgrades, and the install command reads the file back to restore the set. The three commands are `sh opkgscript.sh write` before the upgrade, `sh opkgscript.sh install` after a successful one, and `sh opkgscript.sh help` for the full help. The script was cloned from an original by Malte Forkel, which is worth knowing if you are comparing behaviour.

## config-spare-router.sh gives a secondhand router a known state

This script is the one that explains the collection. The problem it addresses is spelled out in the documentation: many of us have a pile of routers that might be passed along to friends, family or neighbours, but they are in an unknown state, and it is a hassle to figure out the current configuration to reuse them. The script configures an OpenWrt router to a known state, and it also prints a label that can be taped to the outside of the router so the next person to touch it can log in easily. The recommended procedure is to install the latest OpenWrt firmware when taking a router out of service, then run the script, then print and tape the label. The idea generalises beyond routers, since it is a handover procedure: known configuration plus a physical record. A companion document in the repository explains the reasoning in more detail under the title Why You Should Make A Spare Router.

## Printing the admin password on paper is the point, and the risk

The label script is worth reading twice because of the trade-off it makes explicit. The print-router-label.sh script retrieves values from an OpenWrt router to create a label containing the LAN address and important credentials, and the instruction is to tape it to the side of the router so the next person to encounter it can access it. The script works on any OpenWrt router, and the documentation notes that the Printable Label package prints a nicer label. The security assessment in the documentation is admirably brief: the label is reasonably secure, because if the bad guy can read the label, they can also factory-reset the router, or steal your TV or your silverware. The sample label shows the model, flash and RAM sizes, the OpenWrt version string, the LAN address, the user, the login password, the wifi SSID and password, and a configured date. Anyone deploying this on a router in a shared building should think about who can reach the label.

## Latency measurement comes in three flavours, one of them quiet

The measurement scripts are the part of the collection aimed at people chasing a network problem rather than a documentation task. There are three of them and the difference between them matters. The betterspeedtest.sh and netperfrunner.sh scripts measure the performance of your router or offer load to the network for testing, so they generate traffic. The idlelatency.sh script measures the latency of an idle line without any additional traffic generation from the script, which is the useful one when you suspect that something else on the network is the problem. The tunnelbroker.sh script is a different job entirely, setting up an IPv6 6-in-4 tunnel to TunnelBroker.net. The collection therefore spans measurement, configuration, reporting and a specific network service, which is why the documentation notes that some of these scripts have instructions for running from /tmp, which is the writable directory on many OpenWrt installations.

## Getting the scripts onto the router is a git clone over ssh

There is no package for the scripts themselves. The documentation says they can be saved in the /usr/lib/OpenWrtScripts directory, and the easiest way to do that is to ssh into the router and run these commands.

```bash
opkg update
opkg install netperf git git-http
cd /usr/lib
git clone https://github.com/richb-hanover/OpenWrtScripts.git
```

The opkg install line is not incidental, since netperf is what the performance scripts need and git and git-http are what make the clone possible on the device. One detail is worth noticing, because it is the kind of thing that trips people up. The prose describes the scripts living in /usr/lib/OpenWrtScripts, while the documented clone command puts the repository in /usr/lib, so the scripts end up one directory deeper than the prose suggests, and you either move them or invoke them by the path that actually exists. The README does not spell that out, so check where the files landed before you write your own wrapper around them.

## Where this collection is the wrong answer

The first wrong case is a router on a recent OpenWrt release where the platform already does the job. The deprecation note on opkgscript.sh is the clearest example, since attended sysupgrade replaced the package restore script in recent versions of OpenWrt, and using the script there is extra work for an older result. The second wrong case is a device you do not own, where printing credentials and normalising configuration is not a helpful act. The third is anyone expecting a supported package. These are scripts in a repository, not an OpenWrt feed package, so there is no update mechanism, no dependency resolution and no upstream to file a bug against, apart from the repository itself, and the only entry in the release list is for the printable-label package, which is a different thing. The fourth is a latency question that needs real measurement discipline, because a script that generates load and a script that measures an idle line answer different questions, and picking the wrong one produces a number that looks precise and means very little.

## Conclusion

Home lab operators and volunteers who look after several OpenWrt routers, and who want a known configuration plus a paper record of the credentials, are the people this collection is for, and the config-spare-router.sh script is the clearest example of the idea it embodies. It is the wrong tool for a router running current OpenWrt where the built-in attended sysupgrade already restores your package set, since opkgscript.sh is marked deprecated for exactly that reason, and it is the wrong tool for anyone who does not want their router admin password written on a label. Check three things before you rely on it: that the scripts you need still match the OpenWrt release on the device, that you have the netperf, git and git-http packages available through opkg on the router, and that the directory you clone into matches the one the scripts expect, since the documented procedure clones into /usr/lib while the text describes the scripts living in /usr/lib/OpenWrtScripts. The licence is GPL-2.0, the last push was on 2026-07-26, and the newest tagged releases belong to the printable-label package rather than to the scripts themselves.

## FAQ

### How do I get the OpenWrtScripts onto an OpenWrt router?

The documented method is to ssh into the router, run opkg update, install netperf, git and git-http with opkg, change to /usr/lib and clone the repository with git clone. The prose describes the scripts as living in /usr/lib/OpenWrtScripts, so check where the clone actually put them.

### What does getstats.sh do?

It executes a built-in set of commands, writes the collected output to /tmp/openwrtstats.txt, executes any commands passed as arguments on the command line, and lists the user-installed opkg packages. The documentation says the output is helpful to include when reporting a problem.

### Is opkgscript.sh still worth using?

The documentation marks it as deprecated. It still works and restores the package set saved to /etc/config/opkg.installed, but the note points to Attended Sysupgrade in recent versions of OpenWrt as the easier option.

### What is the difference between idlelatency.sh and betterspeedtest.sh?

idlelatency.sh measures the latency of an idle line without any additional traffic generation from the script. betterspeedtest.sh and netperfrunner.sh measure the performance of the router or offer load to the network for testing, so they do generate traffic.

### Is it safe to print my router credentials on a label?

The documentation argues the label is reasonably secure, on the grounds that anyone who can read the label can also factory-reset the router. It still puts the root user, the login password and the wifi password in plain text, so who can physically reach the router is the question to ask yourself.

## Sources

- [Issues](https://github.com/richb-hanover/OpenWrtScripts/issues)
- [License: GPL-2.0](https://github.com/richb-hanover/OpenWrtScripts/blob/main/LICENSE)
- [README](https://github.com/richb-hanover/OpenWrtScripts/blob/main/README.md)
- [Releases](https://github.com/richb-hanover/OpenWrtScripts/releases)
- [richb-hanover/OpenWrtScripts on GitHub](https://github.com/richb-hanover/OpenWrtScripts)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/richb-hanover-openwrtscripts
