Skip to content

Commit 1086e1b

Browse files
committed
Add support for desktop & full variants among other tweaks
1 parent 1531ba5 commit 1086e1b

File tree

5 files changed

+306
-197
lines changed

5 files changed

+306
-197
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,10 @@ jobs:
3232
echo ::set-env name=SRC_URL::"$URL"
3333
echo ::set-env name=SRC_FILE::"$(basename "$URL")"
3434
35-
36-
- name: Build Docker image
37-
if: env.VERSION != ''
38-
run: docker build -t builder .
39-
4035
- name: Modify Raspberry Pi OS image
4136
if: env.VERSION != ''
4237
run: |
43-
mkdir images/
44-
docker run --rm --privileged -v="$(pwd)/images/:/raspios/" builder
45-
38+
./modify-image-in-docker.sh
4639
echo ::set-env name=FILE::"$(cd images && ls *-firstboot.zip)"
4740
4841
- name: Create Github Release

Dockerfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ RUN apt-get update && \
99
wget \
1010
zip
1111

12-
ADD modify-image.sh /usr/local/bin/modify-image
13-
RUN chmod +x /usr/local/bin/modify-image
12+
RUN mkdir -p /mnt/raspios/ /data/
13+
ADD ./firstboot*.service /data/
1414

15-
RUN mkdir -p /mnt/raspios/ /data/
16-
ADD firstboot.service firstboot-script.service /data/
15+
VOLUME /images/
16+
WORKDIR /
1717

18-
VOLUME /raspios/
19-
WORKDIR /raspios/
18+
ADD modify-image.sh /usr/local/bin/modify-image
19+
RUN chmod +x /usr/local/bin/modify-image
2020

2121
ENTRYPOINT ["/usr/local/bin/modify-image"]
22-
CMD ["create", "/raspios/"]
22+
CMD ["create"]

README.md

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,82 @@
11
Raspberry Pi OS
22
================
33

4-
Literally just pure Raspberry Pi OS Lite, but with added the ability to run a script on the first boot by putting it onto `/boot/` as either:
4+
Official Raspberry Pi OS Lite minimally **modified** with the ability to run a script on the first boot.
55

6-
* `/boot/firstboot.sh` - Run provided script directly
7-
* `/boot/firstboot-script.sh` - Run via [`script(1)`][script] for complete session recording, that can be later played back using [`scriptreplay(1)`][replay]
6+
Supported script filenames:
7+
8+
* `/boot/firstboot.sh` - Just run the script on the first boot
9+
* `/boot/firstboot-script.sh` - Same as above, **except** _script_ is run with [`script(1)`][script] for complete session recording, that can be later played back using [`scriptreplay(1)`][replay]
810

911
[script]: http://man7.org/linux/man-pages/man1/script.1.html
1012
[replay]: http://man7.org/linux/man-pages/man1/scriptreplay.1.html
1113

1214
Repo is inspired by https://github.com/nmcclain/raspberian-firstboot, but has been automated, Dockerized, and fully scripted.
1315

14-
There are 4 ways to get the image:
16+
> **NOTE:** If `firstboot-script.sh` is used, recording of script run is saved as `/boot/firstboot-script-log.out` (timing file alongside as `firstboot-script-log.tm`)
17+
18+
## Usage
19+
20+
1. Download [latest image][latest]
21+
<details><summary><b>Alternatives?</b></summary>
22+
23+
If downloading images built by other people is not your thing, you can also:
24+
25+
1. Modify images yourself using provided scripts (in [Docker], or [not]), or even
26+
1. [Manually] apply all necessary modifications
27+
</details>
28+
29+
[latest]: #1-releases
30+
[docker]: #2-docker
31+
[not]: #3-script
32+
[manually]: #4-manual
33+
1. Burn it into a MicroSD Card
34+
<details><summary><b>How?</b></summary>
35+
36+
1. Probably the easiest is to use [Etcher]
37+
1. Another way is [using `dd`][dd] on Linux:
38+
```shell script
39+
dd bs=4M if=path/to/downloaded/file.img of=/dev/sdX conv=fsync
40+
```
41+
1. Or MacOS:
42+
```shell script
43+
dd bs=4M if=path/to/downloaded/file.img of=/dev/diskX conv=fsync
44+
```
45+
46+
**NOTE:** `boot` partition will usually get mounted as `/Volumes/boot/` on MacOS, and _probably_ `/mnt/boot/` on Linux.
47+
</details>
48+
49+
[Etcher]: https://www.balena.io/etcher/
50+
[dd]: https://www.raspberrypi.org/documentation/installation/installing-images/linux.md
51+
1. Mount it
52+
<details><summary><b>How?</b></summary>
53+
54+
1. **\[MacOS\]** Simply re-inserting the card should do the trick, if not then `diskutil`, or `Disk Utility` should help
55+
1. **\[Linux\]** Hard to say exactly, but sth like:
56+
```sh
57+
mkdir -p /mnt/boot/
58+
sudo mount /dev/sdX /mnt/boot/
59+
```
60+
</details>
61+
62+
1. Add your script & mark it as executable
63+
```sh
64+
# MacOS example:
65+
cd /Volumes/boot/
66+
67+
cat <<EOF > firstboot-script.sh
68+
#!/bin/sh -e
69+
70+
echo "Hello World!"
71+
EOF
72+
73+
chmod +x firstboot-script.sh
74+
```
75+
1. Safely eject, move the card into Raspberry Pi, and power it on
76+
77+
## Download
1578
79+
There are 4 possible ways, numbered from easiest to most manual.
1680
1781
### 1. Releases
1882

modify-image-in-docker.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
1-
#!/usr/bin/env sh
1+
#!/bin/sh -e
22

3-
set -e
3+
show_help() {
4+
cat <<EOF >&2
5+
6+
Usage: ./${0##*/} [ --lite | --desktop | --full ] [ DOCKER_TAG ]
7+
8+
Defaults: --lite & DOCKER_TAG=raspios-firstboot
9+
10+
Variants --lite, --desktop, --full as per:
11+
https://www.raspberrypi.org/downloads/raspberry-pi-os/
12+
EOF
13+
}
14+
15+
case "$1" in
16+
-h|--help) show_help ; exit 0;;
17+
--lite) VARIANT=lite ; shift ;;
18+
--desktop) VARIANT=desktop ; shift ;;
19+
--full) VARIANT=full ; shift ;;
20+
--*)
21+
>&2 printf "\n ERR: Flag unknown: '%s'\n" "$1"
22+
show_help
23+
exit 1 ;;
24+
esac
425

526
export DOCKER_BUILDKIT=1
627

7-
TAG=raspios-firstboot
28+
TAG="${1:-raspios-firstboot}"
29+
DIR="$(pwd)/images"
830

9-
docker build --progress=plain --tag "$TAG" .
31+
[ -d "$DIR" ] || mkdir "$DIR"
1032

11-
docker run --privileged --rm --volume="$(pwd)/images:/raspios/" "$TAG"
33+
docker build --progress=plain --tag="$TAG" .
34+
exec docker run --privileged --rm --volume="$DIR:/images/" "$TAG" create "${VARIANT:-lite}"

0 commit comments

Comments
 (0)