Compare commits
11 Commits
openwrt-18
...
openwrt-19
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a3ae89b20 | ||
|
|
0d4d33409e | ||
|
|
836235e656 | ||
|
|
ab6816284f | ||
|
|
725caf2919 | ||
|
|
63806ccfe5 | ||
|
|
527bbf214c | ||
|
|
74b2a4d989 | ||
|
|
7a39ab9adc | ||
|
|
f9cdbd39ef | ||
|
|
75b8e35aa7 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,2 @@
|
|||||||
notes.txt
|
notes.txt
|
||||||
authorized_keys
|
build/
|
||||||
|
|||||||
64
README.md
64
README.md
@@ -1,12 +1,13 @@
|
|||||||
# What
|
# What
|
||||||
|
|
||||||
It's a script to build a customized OpenWRT firmware image on a Linux x86_64 host
|
It's a script to build a customized
|
||||||
(basic familiarity with [OpenWRT](https://wiki.openwrt.org/doc/howto/user.beginner)
|
[OpenWRT](https://openwrt.org/docs/guide-user/start)
|
||||||
is assumed).
|
firmware image using
|
||||||
|
[ImageBuilder](https://openwrt.org/docs/guide-user/additional-software/imagebuilder).
|
||||||
|
|
||||||
If the generated image is flashed on a device it will try to automatically
|
If the generated image is flashed on a device it will try to automatically set up
|
||||||
set up [extroot](http://wiki.openwrt.org/doc/howto/extroot) on **any
|
[extroot](https://openwrt.org/docs/guide-user/additional-software/extroot_configuration)
|
||||||
(!)** storage device plugged into the USB port (`/dev/sda`). Keep in
|
on **any (!)** storage device plugged into the USB port (`/dev/sda`). Keep in
|
||||||
mind that **this will erase any inserted storage device while the
|
mind that **this will erase any inserted storage device while the
|
||||||
router is in the initial setup phase**! Unfortunately there's little
|
router is in the initial setup phase**! Unfortunately there's little
|
||||||
that can be done at that point to ask the user for confirmation.
|
that can be done at that point to ask the user for confirmation.
|
||||||
@@ -21,16 +22,30 @@ I've extracted the generic parts from the above mentioned auto-provision
|
|||||||
project because I thought it's useful enough for making it public.
|
project because I thought it's useful enough for making it public.
|
||||||
|
|
||||||
# How
|
# How
|
||||||
|
|
||||||
|
You can read more about the underlying technology on the OpenWRT wiki: see e.g. the
|
||||||
|
[ImageBuilder](https://openwrt.org/docs/guide-user/additional-software/imagebuilder)
|
||||||
|
page, or the page that lists some other
|
||||||
|
[ImageBuilder frontends](https://openwrt.org/docs/guide-developer/imagebuilder_frontends).
|
||||||
|
|
||||||
|
As for the actual mechanism: custom scripts are baked into the boot process of the
|
||||||
|
flashed firmware. If the extroot overlay is properly set up, then these scripts get hidden by it;
|
||||||
|
i.e. they will only run when the extroot has failed to mount early in the boot.
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
|
|
||||||
To build it, issue the following command: `./build.sh architecture variant device-profile`, e.g.:
|
OpenWRT's ImageBuilder only works on Linux x86_64. To build a firmware, issue the following command:
|
||||||
* `./build.sh ar71xx generic tl-wr1043nd-v2`
|
`./build.sh architecture variant device-profile`, e.g.:
|
||||||
|
|
||||||
|
* `./build.sh ar71xx generic tplink_tl-wr1043nd-v1`
|
||||||
|
* `./build.sh ath79 generic tplink_archer-c6-v2`
|
||||||
|
|
||||||
Results will be under `build/openwrt-imagebuilder-${release}-${architecture}-${variant}.Linux-x86_64/bin/`.
|
Results will be under `build/openwrt-imagebuilder-${release}-${architecture}-${variant}.Linux-x86_64/bin/`.
|
||||||
|
|
||||||
To see a list of available targets, run `make info` in the ImageBuilder dir.
|
To see a list of available targets, run `make info` in the ImageBuilder dir.
|
||||||
|
|
||||||
If you want to change which OpenWRT version is used, then edit the relevant variable(s) in `build.sh`.
|
If you want to change which OpenWRT version is used, then edit the relevant variable(s)
|
||||||
|
in `build.sh`.
|
||||||
|
|
||||||
### Setup stages
|
### Setup stages
|
||||||
|
|
||||||
@@ -46,9 +61,14 @@ space), and then reboot.
|
|||||||
|
|
||||||
#### Stage 2: download and install some packages from the internet
|
#### Stage 2: download and install some packages from the internet
|
||||||
|
|
||||||
Once it booted into the new extroot, it will continuously attempt to install
|
Once it rebooted into the new extroot, it will continuously keep trying to install
|
||||||
some OpenWRT packages until an internet connection is set up on the router
|
some OpenWRT packages until an internet connection is set up on the router. You
|
||||||
(either by using ssh or the web UI (LuCI)).
|
need to do that manually either by using ssh or the web UI (LuCI).
|
||||||
|
|
||||||
|
#### Stage 3, optional
|
||||||
|
|
||||||
|
We also have a 3rd stage, written in Python, but it's commented out here.
|
||||||
|
Search for `autoprovision-stage3.py` to see how it's done.
|
||||||
|
|
||||||
### Login
|
### Login
|
||||||
|
|
||||||
@@ -66,26 +86,26 @@ Once connected, you can read the log with `logread -f`.
|
|||||||
|
|
||||||
# Status
|
# Status
|
||||||
|
|
||||||
This is more of a template than something standalone. You most
|
This is more of a template than something standalone, but I use it for
|
||||||
|
my home routers as is. You most
|
||||||
probably want to customize this script here and there; search for
|
probably want to customize this script here and there; search for
|
||||||
`CUSTOMIZE` for places of interest.
|
`CUSTOMIZE` for places of interest.
|
||||||
|
|
||||||
Most importantly, **set up a password and maybe an ssh key**.
|
Most importantly, **set up a password and maybe an ssh key**.
|
||||||
|
|
||||||
At the time of writing it only supports a few `ar71xx` routers out of the box,
|
At the time of writing it only supports a few `ar71xx` routers out of the box,
|
||||||
but it's easy to extend it.
|
but it's easy to extend it. Support for a new router entails looking up
|
||||||
|
some led names for setLedAttribute for the user feedback through the blinking of
|
||||||
## Tested with
|
the leds. It should work fine without that, but it will be less convenient to
|
||||||
|
interact with your router in the initial setup phase.
|
||||||
[OpenWRT 17.01.4](https://downloads.openwrt.org/releases/)
|
|
||||||
on a TP-Link WR-1043nd-v2.
|
|
||||||
|
|
||||||
# Troubleshooting
|
# Troubleshooting
|
||||||
|
|
||||||
## Which file should I flash?
|
## Which file should I flash?
|
||||||
|
|
||||||
You should consult the [OpenWRT documentation](https://wiki.openwrt.org/doc/howto/user.beginner).
|
You should consult the [OpenWRT documentation](https://openwrt.org/docs/guide-user/start).
|
||||||
The produced firmware files should be somewhere around ```build/openwrt-imagebuilder-17.01.4-ar71xx-generic.Linux-x86_64/bin/ar71xx```.
|
The produced firmware files should be somewhere around
|
||||||
|
```build/openwrt-imagebuilder-17.01.4-ar71xx-generic.Linux-x86_64/bin/ar71xx```.
|
||||||
|
|
||||||
In short:
|
In short:
|
||||||
|
|
||||||
@@ -94,7 +114,7 @@ In short:
|
|||||||
OpenWRT.
|
OpenWRT.
|
||||||
|
|
||||||
* You must carefully pick the proper firmware file for your **hardware version**! I advise you
|
* You must carefully pick the proper firmware file for your **hardware version**! I advise you
|
||||||
to look up the wiki page for your hardware on the [OpenWRT wiki](https://wiki.openwrt.org),
|
to look up the wiki page for your hardware on the [OpenWRT wiki](https://openwrt.org),
|
||||||
because most of them have a table of the released hardware versions with comments on their
|
because most of them have a table of the released hardware versions with comments on their
|
||||||
status (sometimes new hardware revisions are only supported by the latest OpenWRT, which is
|
status (sometimes new hardware revisions are only supported by the latest OpenWRT, which is
|
||||||
not released yet).
|
not released yet).
|
||||||
|
|||||||
29
build.sh
29
build.sh
@@ -1,43 +1,33 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
absolutize ()
|
|
||||||
{
|
|
||||||
if [ ! -d "$1" ]; then
|
|
||||||
echo
|
|
||||||
echo "ERROR: '$1' doesn't exist or not a directory!"
|
|
||||||
kill -INT $$
|
|
||||||
fi
|
|
||||||
|
|
||||||
pushd "$1" >/dev/null
|
|
||||||
echo `pwd`
|
|
||||||
popd >/dev/null
|
|
||||||
}
|
|
||||||
|
|
||||||
TARGET_ARCHITECTURE=$1
|
TARGET_ARCHITECTURE=$1
|
||||||
TARGET_VARIANT=$2
|
TARGET_VARIANT=$2
|
||||||
TARGET_DEVICE=$3
|
TARGET_DEVICE=$3
|
||||||
|
|
||||||
BUILD=`dirname "$0"`"/build/"
|
BUILD=`dirname "$0"`"/build/"
|
||||||
BUILD=`absolutize $BUILD`
|
BUILD=`readlink -f $BUILD`
|
||||||
|
|
||||||
###
|
###
|
||||||
### chose a release
|
### chose a release
|
||||||
###
|
###
|
||||||
RELEASE="18.06.1"
|
RELEASE="19.07.9"
|
||||||
|
|
||||||
IMGBUILDER_NAME="openwrt-imagebuilder-${RELEASE}-${TARGET_ARCHITECTURE}-${TARGET_VARIANT}.Linux-x86_64"
|
IMGBUILDER_NAME="openwrt-imagebuilder-${RELEASE}-${TARGET_ARCHITECTURE}-${TARGET_VARIANT}.Linux-x86_64"
|
||||||
IMGBUILDER_DIR="${BUILD}/${IMGBUILDER_NAME}"
|
IMGBUILDER_DIR="${BUILD}/${IMGBUILDER_NAME}"
|
||||||
IMGBUILDER_ARCHIVE="${IMGBUILDER_NAME}.tar.xz"
|
IMGBUILDER_ARCHIVE="${IMGBUILDER_NAME}.tar.xz"
|
||||||
|
|
||||||
IMGTEMPDIR="${BUILD}/image-extras"
|
IMGTEMPDIR="${BUILD}/image-extras"
|
||||||
|
# see this feature request:
|
||||||
|
# FS#1670 - consistent naming convention for the imagebuilder.tar.xz URL
|
||||||
|
# https://bugs.openwrt.org/index.php?do=details&task_id=1670
|
||||||
IMGBUILDERURL="https://downloads.openwrt.org/releases/${RELEASE}/targets/${TARGET_ARCHITECTURE}/${TARGET_VARIANT}/${IMGBUILDER_ARCHIVE}"
|
IMGBUILDERURL="https://downloads.openwrt.org/releases/${RELEASE}/targets/${TARGET_ARCHITECTURE}/${TARGET_VARIANT}/${IMGBUILDER_ARCHIVE}"
|
||||||
|
|
||||||
if [ -z ${TARGET_DEVICE} ]; then
|
if [ -z ${TARGET_DEVICE} ]; then
|
||||||
echo "Usage: $0 architecture variant device-profile"
|
echo "Usage: $0 architecture variant device-profile"
|
||||||
echo " e.g.: $0 ar71xx generic tl-wr1043nd-v2"
|
echo " e.g.: $0 ar71xx generic tplink_tl-wr1043nd-v1"
|
||||||
echo " $0 ramips mt7621 zbt-wg3526"
|
echo " $0 ath79 generic tplink_archer-c6-v2"
|
||||||
echo " $0 bcm53xx generic dlink-dir-885l"
|
echo " $0 bcm53xx generic dlink-dir-885l"
|
||||||
echo " (this last one will not work without editing build.sh, details: https://github.com/attila-lendvai/openwrt-auto-extroot/pull/15#issuecomment-405847440)"
|
echo " (this last one will not work without editing build.sh, details: https://github.com/attila-lendvai/openwrt-auto-extroot/pull/15#issuecomment-405847440)"
|
||||||
echo " to get a list of supported devices issue a 'make info' in the OpenWRT image builder directory:"
|
echo " to get a list of supported devices issue a 'make info' in the OpenWRT image builder directory:"
|
||||||
@@ -80,6 +70,9 @@ fi
|
|||||||
|
|
||||||
pushd ${IMGBUILDER_DIR}
|
pushd ${IMGBUILDER_DIR}
|
||||||
|
|
||||||
|
# Without this the image builder fails.
|
||||||
|
export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD)
|
||||||
|
|
||||||
make image PROFILE=${TARGET_DEVICE} PACKAGES="${PREINSTALLED_PACKAGES}" FILES=${IMGTEMPDIR}
|
make image PROFILE=${TARGET_DEVICE} PACKAGES="${PREINSTALLED_PACKAGES}" FILES=${IMGTEMPDIR}
|
||||||
|
|
||||||
pushd bin/targets/${TARGET_ARCHITECTURE}/
|
pushd bin/targets/${TARGET_ARCHITECTURE}/
|
||||||
|
|||||||
4
build/.gitignore
vendored
4
build/.gitignore
vendored
@@ -1,4 +0,0 @@
|
|||||||
# Ignore everything in this directory
|
|
||||||
*
|
|
||||||
# Except this file
|
|
||||||
!.gitignore
|
|
||||||
19
default.nix
Normal file
19
default.nix
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> {} }:
|
||||||
|
|
||||||
|
pkgs.mkShell {
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
coreutils posix_man_pages bash-completion less
|
||||||
|
gitFull diffutils
|
||||||
|
gnumake which
|
||||||
|
ncurses perl python2 python3
|
||||||
|
|
||||||
|
# keep this line if you use bash
|
||||||
|
bashInteractive
|
||||||
|
];
|
||||||
|
|
||||||
|
shellHook =
|
||||||
|
''
|
||||||
|
alias ..='cd ..'
|
||||||
|
alias ...='cd ../..'
|
||||||
|
'';
|
||||||
|
}
|
||||||
3
image-extras/common/etc/dropbear/.gitignore
vendored
Normal file
3
image-extras/common/etc/dropbear/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# you can put your ssh public key into authorized_keys,
|
||||||
|
# but we don't ever want it to be committed to the repo
|
||||||
|
authorized_keys
|
||||||
@@ -1 +0,0 @@
|
|||||||
# this file may contain ssh public keys for passwordless ssh root login
|
|
||||||
@@ -34,7 +34,7 @@ hasBigEnoughPendrive()
|
|||||||
setupPendrivePartitions()
|
setupPendrivePartitions()
|
||||||
{
|
{
|
||||||
# erase partition table
|
# erase partition table
|
||||||
dd if=/dev/zero of=/dev/sda bs=1M count=1
|
dd if=/dev/zero of=/dev/sda bs=1k count=256
|
||||||
|
|
||||||
# sda1 is 'swap'
|
# sda1 is 'swap'
|
||||||
# sda2 is 'root'
|
# sda2 is 'root'
|
||||||
|
|||||||
26
manifest.scm
Normal file
26
manifest.scm
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
;; This is the complete list of Guix packages necessary for building.
|
||||||
|
;;
|
||||||
|
;; The following shell command will run the tests:
|
||||||
|
;;
|
||||||
|
;; guix shell -m manifest.scm --pure -- ./build.sh ath79 generic tplink_tl-wdr4300-v1
|
||||||
|
;;
|
||||||
|
;; TODO ...ideally. some dependencies are not listed, and it fails when using --pure
|
||||||
|
|
||||||
|
;;
|
||||||
|
;; Quircks on Guix: the check for git fails, must edit
|
||||||
|
;; build/openwrt-imagebuilder-19.07.9-ath79-generic.Linux-x86_64/include/prereq-build.mk
|
||||||
|
;; and comment out the git check.
|
||||||
|
;;
|
||||||
|
|
||||||
|
(specifications->manifest
|
||||||
|
'("coreutils"
|
||||||
|
"bash"
|
||||||
|
"make"
|
||||||
|
"perl"
|
||||||
|
"python2"
|
||||||
|
"gcc-toolchain"
|
||||||
|
"git"
|
||||||
|
"git:gui"
|
||||||
|
;; "man-pages"
|
||||||
|
"less"
|
||||||
|
"time"))
|
||||||
Reference in New Issue
Block a user