-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.sh
39 lines (26 loc) · 1.62 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash
rm -f ./*.img
rm -f ./*.xz
sudo umount ./mount
rm -rf mount
LATEST_PI_VER=$(curl 'https://downloads.raspberrypi.org/raspios_lite_armhf/images/?C=M;O=A' 2>/dev/null | grep -oP '\d\d\d\d-\d\d-\d\d' | tail -n 1) # holy hell
wget "https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-$LATEST_PI_VER/$LATEST_PI_VER-raspios-bullseye-armhf-lite.img.xz"
xz -d "$LATEST_PI_VER-raspios-bullseye-armhf-lite.img.xz"
DEVFILE=$(sudo kpartx -av "$LATEST_PI_VER-raspios-bullseye-armhf-lite.img" | grep -oP "loop\dp2")
mkdir mount
sudo mount "/dev/mapper/$DEVFILE" ./mount
sudo tar -czf - -C mount . > ./raspi.tar
docker import - pimachinelearning/raspi-os-lite:"$LATEST_PI_VER" < raspi.tar
docker import - pimachinelearning/raspi-os-lite:latest < raspi.tar
docker tag pimachinelearning/raspi-os-lite:"$LATEST_PI_VER" pimachinelearning/raspi-os-lite:"$LATEST_PI_VER"
docker tag pimachinelearning/raspi-os-lite:latest pimachinelearning/raspi-os-lite:latest
docker tag pimachinelearning/raspi-os-lite:"$LATEST_PI_VER" ghcr.io/pimachinelearning/pimachinelearning/pidocker:"$LATEST_PI_VER"
docker tag pimachinelearning/raspi-os-lite:latest ghcr.io/pimachinelearning/pimachinelearning/pidocker:latest
docker push pimachinelearning/raspi-os-lite:"$LATEST_PI_VER"
docker push pimachinelearning/raspi-os-lite:latest
docker push ghcr.io/pimachinelearning/pimachinelearning/pidocker:"$LATEST_PI_VER"
docker push ghcr.io/pimachinelearning/pimachinelearning/pidocker:latest
sudo umount ./mount
sudo kpartx -d "$LATEST_PI_VER-raspios-bullseye-armhf-lite.img"
rm -rf ./mount
rm "$LATEST_PI_VER"-raspios-bullseye-armhf-lite.img