mirror of
https://github.com/AlbrechtL/openwrt-docker.git
synced 2026-10-15 00:01:23 +00:00
Change rootfs name in order to migrate the rootfs even when the OpenWrt version didn't change.
This commit is contained in:
+6
-5
@@ -2,8 +2,7 @@ FROM alpine:latest
|
||||
|
||||
ARG NOVNC_VERSION="1.4.0"
|
||||
ARG OPENWRT_VERSION="23.05.2"
|
||||
ARG S6_OVERLAY_VERSION="3.1.6.2"
|
||||
ARG VERSION_ARG "0.1"
|
||||
ARG VERSION_ARG="0.1"
|
||||
|
||||
RUN apk add --no-cache \
|
||||
supervisor \
|
||||
@@ -17,6 +16,7 @@ RUN apk add --no-cache \
|
||||
python3 \
|
||||
py3-pip \
|
||||
py3-virtualenv \
|
||||
uuidgen \
|
||||
&& mkdir -p /usr/share/novnc \
|
||||
&& wget https://github.com/novnc/noVNC/archive/refs/tags/v${NOVNC_VERSION}.tar.gz -O /tmp/novnc.tar.gz -q \
|
||||
&& tar -xf /tmp/novnc.tar.gz -C /tmp/ \
|
||||
@@ -63,9 +63,10 @@ RUN mkdir /var/vm \
|
||||
# Copy downloaded IPKs into the Docker image \
|
||||
&& cp /tmp/openwrt-rootfs/*.ipk /var/vm/packages \
|
||||
&& rm -rf /tmp/openwrt-rootfs \
|
||||
&& rm /tmp/rootfs-${OPENWRT_VERSION}.tar.gz
|
||||
|
||||
ENV OPENWRT_VERSION=${OPENWRT_VERSION}
|
||||
&& rm /tmp/rootfs-${OPENWRT_VERSION}.tar.gz \
|
||||
&& echo "OPENWRT_VERSION=\"${OPENWRT_VERSION}\"" > /var/vm/openwrt_metadata.conf \
|
||||
&& echo "OPENWRT_IMAGE_CREATE_DATETIME=\"`date`\"" >> /var/vm/openwrt_metadata.conf \
|
||||
&& echo "OPENWRT_IMAGE_ID=\"`uuidgen`\"" >> /var/vm/openwrt_metadata.conf
|
||||
|
||||
COPY supervisord.conf /etc/supervisord.conf
|
||||
COPY ./src /run/
|
||||
|
||||
@@ -3,19 +3,20 @@
|
||||
set -Eeuo pipefail
|
||||
trap - ERR
|
||||
|
||||
. /var/vm/openwrt_metadata.conf
|
||||
. /run/helpers.sh
|
||||
|
||||
# Check if rootfs is in volume
|
||||
FILE=/storage/rootfs-${OPENWRT_VERSION}.img
|
||||
FILE=/storage/rootfs-${OPENWRT_IMAGE_ID}.img
|
||||
if [ -f "$FILE" ]; then
|
||||
info "$FILE exists. Nothing to do."
|
||||
else
|
||||
info "$FILE does not exist. Copying rootfs-${OPENWRT_VERSION}.img to storage ..."
|
||||
cp /var/vm/rootfs-${OPENWRT_VERSION}.img.gz /storage/rootfs-${OPENWRT_VERSION}.img.gz
|
||||
gzip -d /storage/rootfs-${OPENWRT_VERSION}.img.gz
|
||||
cp /var/vm/rootfs-${OPENWRT_VERSION}.img.gz /storage/rootfs-${OPENWRT_IMAGE_ID}.img.gz
|
||||
gzip -d /storage/rootfs-${OPENWRT_IMAGE_ID}.img.gz
|
||||
|
||||
info "Inject some additional files into the image"
|
||||
mount /storage/rootfs-${OPENWRT_VERSION}.img /mnt
|
||||
mount /storage/rootfs-${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/bin/*
|
||||
@@ -40,5 +41,5 @@ else
|
||||
fi
|
||||
|
||||
touch /storage/current_version
|
||||
echo "rootfs-${OPENWRT_VERSION}.img" > /storage/current_version
|
||||
echo "rootfs-${OPENWRT_IMAGE_ID}.img" > /storage/current_version
|
||||
fi
|
||||
|
||||
@@ -3,15 +3,16 @@
|
||||
set -Eeuo pipefail
|
||||
trap - ERR
|
||||
|
||||
. /var/vm/openwrt_metadata.conf
|
||||
. /run/helpers.sh
|
||||
|
||||
FILE=/storage/rootfs-${OPENWRT_VERSION}.img
|
||||
FILE=/storage/rootfs-${OPENWRT_IMAGE_ID}.img
|
||||
|
||||
# Migrate settings from old OpenWrt version to new one
|
||||
if [ -f /storage/old_version ]; then
|
||||
OLD_VERSION_ROOTFS=`cat /storage/old_version`
|
||||
|
||||
info "Migrate settings from $OLD_VERSION_ROOTFS to rootfs-${OPENWRT_VERSION}.img."
|
||||
info "Migrate settings from $OLD_VERSION_ROOTFS to rootfs-${OPENWRT_IMAGE_ID}.img."
|
||||
|
||||
mount /storage/$OLD_VERSION_ROOTFS /mnt
|
||||
chroot /mnt/ mkdir -p /var/lock
|
||||
@@ -32,5 +33,5 @@ if [ -f /storage/old_version ]; then
|
||||
rm /storage/old_version
|
||||
rm /storage/config-`basename $OLD_VERSION_ROOTFS .img`.tar.gz
|
||||
else
|
||||
info "rootfs-${OPENWRT_VERSION}.img is up to date. Nothing to do."
|
||||
info "rootfs-${OPENWRT_IMAGE_ID}.img is up to date. Nothing to do."
|
||||
fi
|
||||
|
||||
+2
-1
@@ -4,12 +4,13 @@
|
||||
set -Eeuo pipefail
|
||||
trap - ERR
|
||||
|
||||
. /var/vm/openwrt_metadata.conf
|
||||
. /run/helpers.sh
|
||||
. /run/install_openwrt_rootfs.sh
|
||||
. /run/migrate_openwrt_rootfs.sh
|
||||
|
||||
VERS=$(qemu-system-aarch64 --version | head -n 1 | cut -d '(' -f 1)
|
||||
FILE=/storage/rootfs-${OPENWRT_VERSION}.img
|
||||
FILE=/storage/rootfs-${OPENWRT_IMAGE_ID}.img
|
||||
|
||||
attach_eth_if () {
|
||||
HOST_IF=$1
|
||||
|
||||
Reference in New Issue
Block a user