OpenWrt‎ > ‎


Add Interface to firewall config file

    fw_configure_interface $network add $device

Post install scripts

Add a post-install part in your Makefile. Once you have that, you can script anything you wish, like adding users and setting ownerships. The package for Tor has a nice example of how to do this. I have pasted the relevant part of the Tor Makefile here, which I will comment on afterwards:

define Package/tor/postinst
# # check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
        # create copies of passwd and group, if we use squashfs
        rootfs=`mount |awk '/root/ { print $$5 }'`
        if [ "$$rootfs" = "squashfs" ]; then
                if [ -h /etc/group ]; then
                        rm /etc/group
                        cp /rom/etc/group /etc/group
                if [ -h /etc/passwd ]; then
                        rm /etc/passwd
                        cp /rom/etc/passwd /etc/passwd
echo ""
# add group if it doesn't exist
if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/group)" ]; then
        echo "adding group $$name to /etc/group"
        echo "$${name}:x:$${id}:" >> $${IPKG_INSTROOT}/etc/group
# add user if it doesn't exist
if [ -z "$$(grep ^\\$${name}: $${IPKG_INSTROOT}/etc/passwd)" ]; then
        echo "adding user $name to /etc/passwd"
        echo "$${name}:x:$${id}:$${id}:$${name}:/tmp/.$${name}:/bin/false" >> $${IPKG_INSTROOT}/etc/passwd

So, let's analyze this briefly:
  1. - A post install script is defined by "define Package/tor/postinst" and ends with "endef".
  2. - The text between these two delimiters is the actual script that will be run; notice the #!/bin/sh at the beginning of the script.
  3. - Very important: Postinst scripts can be executed twice; once during build time and a second time during installation on the OpenWRT device. This is somewhat logical because the build process is also an installation process; it installs the application you are compiling into a package. Because of this double execution, you have to make your script explicitly check in what phase it is in: Build or Install. This is what the "if [ -z "${IPKG_INSTROOT}" ]" part is for. It checks to see if the variable IPKG_INSTROOT is zero-length. If so, then it assumes that it is not in the build phase, but running on a 'real' system. Once this has been confirmed, you can run all sorts of actions, limited only by your imagination.
  4. - All variables in your script should have double-string characters ($) instead of a single. This is to tell "make" not to interpret the value as a variable, but to just ignore the string and replace the $ by a single $.
  5. - During the build process, the contents of the postinst section will be copied to build_dir/<architecture>/<package-name>/ipkg/<module-name>/CONTROL/postinst. This is good to know, because now you can check the postinst script after you have built your package. One of the things you can check for, is to see if you accidentally forgot to add double $ characters, for example. If so, then you know your script is broken.
  6. - The above rules also apply to preinst , prerm and postrm scripts.

Another way to get scripts run after first boot

place them in:


It will be evaluated once at firstboot and removed afterwards.  They're called in /etc/init.d/boot, after the rootfs has been mounted
but before modules and hotplug are loaded.

B43 driver

b43 now needs CONFIG_SSB_BLOCKIO=y

Managing Config files

A Common problem that usually arises in process of bumping working copy to the current HEAD is the task of keeping .config file up with the introduced changes. The correct procedure of "upgrading" config file to the newer SVN revision is to use the sequence like this:

# make clean
# svn update
# make oldconfig

make oldconfig drops out obsolete parameters and will ask you how to handle new ones (n/y/m). 
kernel-parameters are not part of the file - the equivalent call is make kernel_oldconfig 
(saved in target/linux/*/config-*).
However, usually - you would accept the kernel-config(s) OpenWrt provides - in that case the kernel configs for the supported targets are adjusted and maintained by OpenWrt so you don't have to worry about.

The feeds management system. is updated using the "feeds" script.

This script basically does three things:
  1. svn checkout/update for the feeds defined in feeds.conf when called with "update" as the second argument. This operation does not create/update any of the symlinks in the packages/feeds/*.
  2. List the packages in the checked out revision of the feed or search checked out feeds for a specified package (list/search as second argument).
  3. Create/remove symlinks in packages/feeds/* when called with install/uninstall as the second argument.
Thus, to correctly update and install all packages in all feeds the command sequence is:

# ./scripts/feeds uninstall -a
# ./scripts/feeds update -a
# ./scripts/feeds install -a

This will update the feeds from the corresponding repositories listed in feeds.conf / feeds.conf.default respectively.

then running make oldconfig will now drop obsolete entries and ask you what to do with new ones (=new packages).

View Wireless Traffic

tcpdump -i prism0 [-y PRISM_HEADER] -s0 -w dumpfile  ether host 01:0c:cc:0:0:0

tcpdump -i prism0 [-y PRISM_HEADER] -s0 -e -n ether host 01:0c:cc:0:0:0

UCI for Ubuntu

Anton <>
maintains a Ubuntu repository at:



define Package/qolyester
    TITLE:=OLSR implementation with QoS

The "DEPENDS" directive implies both an installation and a build time dependency
The "PKG_BUILD_DEPENDS" directive means that libnotimpl will not be selected, but it will be built before this package. 

Package debugging

To disable stripping of a package so that symbols are reserved fro debugging:
add a line:
RSTRIP := true
somewhere below the 'include' lines. in the Makefile
That should disable stripping for the entire package.

Makefile kernel version dependency

ifeq ($(KERNEL),2.4)
  do some stuff

Note: Current OpenWrt trunk no longer supports version 2.4 kernels