Migrate adding of additional files into OpenWrt image

This commit is contained in:
Albrecht Lohofener
2024-11-11 07:27:35 +01:00
parent c41e1fd23e
commit 5c6c686646
5 changed files with 10 additions and 50 deletions
+10 -6
View File
@@ -74,10 +74,11 @@ RUN echo "Building for platform '$TARGETPLATFORM'" \
&& cd /tmp/noVNC-${NOVNC_VERSION}\
&& mv app core vendor package.json *.html /usr/share/novnc \
&& sed -i 's/^worker_processes.*/worker_processes 1;daemon off;/' /etc/nginx/nginx.conf
COPY ./openwrt_additional /var/vm/openwrt_additional
# Handle different CPUs architectures and choose the correct OpenWrt images
RUN echo "Building for platform '$TARGETPLATFORM'" \
OPKG_EXTRA_ARGS="" \
&& if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
if [ "$OPENWRT_VERSION" = "master" ]; then \
OPENWRT_IMAGE="https://downloads.openwrt.org/snapshots/targets/x86/64/openwrt-x86-64-generic-squashfs-combined.img.gz"; \
@@ -104,8 +105,6 @@ RUN echo "Building for platform '$TARGETPLATFORM'" \
fi \
\
# Get OpenWrt images \
&& mkdir /var/vm \
&& mkdir /var/vm/packages \
&& wget $OPENWRT_IMAGE -O /var/vm/squashfs-combined-${OPENWRT_VERSION}.img.gz \
&& gzip -d /var/vm/squashfs-combined-${OPENWRT_VERSION}.img.gz \
\
@@ -139,9 +138,15 @@ RUN echo "Building for platform '$TARGETPLATFORM'" \
# Add Wireguard support \
&& ssh root@localhost -p 8022 'opkg install wireguard-tools luci-proto-wireguard' \
\
# Add default network config
# Add default network config \
&& ssh root@localhost -p 8022 "uci set network.lan.ipaddr='172.31.1.1'; uci commit network" \
\
# Add some files \
&& ssh root@localhost -p 8022 'opkg install openssh-sftp-server' \
&& chmod +x /var/vm/openwrt_additional/usr/bin/* \
&& scp -P 8022 /var/vm/openwrt_additional/usr/bin/* root@localhost:/usr/bin \
&& ssh root@localhost -p 8022 'opkg remove openssh-sftp-server' \
\
# Sync changes into image and kill qemu
&& ssh root@localhost -p 8022 'sync' \
&& if [ "$TARGETPLATFORM" = "linux/amd64" ]; then \
@@ -160,7 +165,6 @@ RUN echo "Building for platform '$TARGETPLATFORM'" \
COPY --from=builder /usr/local/bin/qemu-openwrt-web-backend /usr/local/bin/qemu-openwrt-web-backend
COPY ./src /run/
COPY ./web-frontend /var/www/
COPY ./openwrt_additional /var/vm/openwrt_additional
RUN chmod +x /run/*.sh
-5
View File
@@ -1,5 +0,0 @@
# Remount rootfs to enable sync
mount -o remount,rw,sync /
exit 0
@@ -1,5 +0,0 @@
#!/bin/sh
uci set network.lan.ipaddr='172.31.1.1'
uci commit network
@@ -1,7 +0,0 @@
#/bin/sh
echo "Get packages list from repo"
opkg update
echo "Restore packages"
grep '\tunknown' /etc/backup/installed_packages.txt | cut -f1 | xargs opkg install
-27
View File
@@ -15,33 +15,6 @@ else
cp /var/vm/squashfs-combined-${OPENWRT_VERSION}.img.gz /storage/squashfs-combined-${OPENWRT_IMAGE_ID}.img.gz
gzip -d /storage/squashfs-combined-${OPENWRT_IMAGE_ID}.img.gz
# info "Inject some additional files into the image"
# mount /storage/squashfs-combined-${OPENWRT_IMAGE_ID}.img /mnt
# # mount -o offset=$((512*262656)) /storage/disk.img /mnt # combined image ext4 partition starts at offset 262656
# chmod +x /var/vm/openwrt_additional/usr/bin/*
# cp /var/vm/openwrt_additional/usr/bin/* /mnt/usr/bin/
# mv /mnt/etc/rc.local /mnt/etc/rc.local.orig
# cp /var/vm/openwrt_additional/etc/rc.local /mnt/etc/rc.local
# chmod +x /mnt/etc/rc.local
# # Add some additional default configurations. Only if we have a fresh container because /storage/current_version is not existing then
# if [ ! -f /storage/current_version ]; then
# chmod +x /var/vm/openwrt_additional/etc/uci-defaults/*
# cp /var/vm/openwrt_additional/etc/uci-defaults/* /mnt/etc/uci-defaults/
# fi
# info "Install additional IPKs into the image"
# mkdir /mnt/var/offline_packages
# cp /var/vm/packages/*.ipk /mnt/var/offline_packages/
# chroot /mnt/ mkdir -p /var/lock
# chroot /mnt/ sh -c 'cd /var/offline_packages/ && opkg install *.ipk'
# rm -rf /mnt/var/offline_packages/
# rm -rf /mnt/var/lock
# umount /mnt
if [ -f "/storage/current_version" ]; then
mv /storage/current_version /storage/old_version
fi