Progress for: mount-fix
Slowly working on patch to account for new mounts on December firmware
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
Package: sdxpinn-mount-fix
|
Package: sdxpinn-mount-fix
|
||||||
Version: 1.1.0
|
Version: 1.2.0-NOT-READY
|
||||||
Architecture: aarch64_cortex-a53
|
Architecture: aarch64_cortex-a53
|
||||||
Maintainer: Cameron Thompson iamromulan@github.com
|
Maintainer: Cameron Thompson iamromulan@github.com
|
||||||
Description: Creates a usable mount space and overlay for SDXPINN modems. Dependencies bundled: libinotifytools and inotifywait
|
Description: Creates a usable mount space and overlay for SDXPINN modems. Dependencies bundled: libinotifytools and inotifywait
|
||||||
|
|||||||
@@ -62,10 +62,23 @@ chmod +x /etc/init.d/mount-fix /etc/init.d/init-overlay-watchdog /etc/init.d/add
|
|||||||
|
|
||||||
# Enable and start the services
|
# Enable and start the services
|
||||||
echo "Starting services..."
|
echo "Starting services..."
|
||||||
|
|
||||||
service mount-fix enable
|
service mount-fix enable
|
||||||
|
if grep -qs '/usrdata' /proc/mounts; then
|
||||||
|
echo "/usrdata is mounted. Synchronizing mount-fix files to /usrdata..."
|
||||||
|
cp /etc/init.d/mount-fix /usrdata/etc/init.d/mount-fix
|
||||||
|
cp -P /etc/rc.d/S03mount-fix /usrdata/etc/rc.d/S03mount-fix
|
||||||
|
fi
|
||||||
service mount-fix start
|
service mount-fix start
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
service init-overlay-watchdog enable
|
service init-overlay-watchdog enable
|
||||||
|
if grep -qs '/usrdata' /proc/mounts; then
|
||||||
|
echo "/usrdata is mounted. Synchronizing init-overlay-watchdog files to /usrdata..."
|
||||||
|
cp /etc/init.d/init-overlay-watchdog /usrdata/etc/init.d/init-overlay-watchdog
|
||||||
|
cp -P /etc/rc.d/S04init-overlay-watchdog /usrdata/etc/rc.d/S04init-overlay-watchdog
|
||||||
|
fi
|
||||||
service init-overlay-watchdog start
|
service init-overlay-watchdog start
|
||||||
|
|
||||||
echo -e "\e[32m sdxpinn-mount-fix installed! Here is the new file structure! \e[0m"
|
echo -e "\e[32m sdxpinn-mount-fix installed! Here is the new file structure! \e[0m"
|
||||||
@@ -103,7 +116,6 @@ if ! grep -q "Package:" "$INIT_SCRIPT"; then
|
|||||||
else
|
else
|
||||||
# Enable and start the updated add_opkg_status_bundled script
|
# Enable and start the updated add_opkg_status_bundled script
|
||||||
echo "Updated $INIT_SCRIPT with remaining bundled package info."
|
echo "Updated $INIT_SCRIPT with remaining bundled package info."
|
||||||
service add_opkg_status_bundled enable
|
|
||||||
service add_opkg_status_bundled start
|
service add_opkg_status_bundled start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
14
ipk-source/sdxpinn-mount-fix/CONTROL/preinst
Normal file → Executable file
14
ipk-source/sdxpinn-mount-fix/CONTROL/preinst
Normal file → Executable file
@@ -1,5 +1,9 @@
|
|||||||
#!/bin/ash
|
#!/bin/ash
|
||||||
|
|
||||||
|
# Remount original rootfs as read-write
|
||||||
|
echo "Mounting / as read-write"
|
||||||
|
mount -o remount,rw /
|
||||||
|
|
||||||
# Define the location of detected packages file
|
# Define the location of detected packages file
|
||||||
DETECTED_PACKAGES_FILE="/tmp/detected_packages.tmp"
|
DETECTED_PACKAGES_FILE="/tmp/detected_packages.tmp"
|
||||||
LIST_FILE_DELETED=false
|
LIST_FILE_DELETED=false
|
||||||
@@ -49,13 +53,15 @@ if [ "$LIST_FILE_DELETED" = true ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if /etc is mounted
|
# Check if /etc is mounted
|
||||||
if grep -qs '/etc ' /proc/mounts; then
|
if grep -qs '/etc' /proc/mounts; then
|
||||||
echo "Unmounting /etc..."
|
echo "Unmounting /etc..."
|
||||||
umount -lf /etc
|
umount -lf /etc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remount original rootfs as read-write
|
# Check if /usrdata is mounted
|
||||||
echo "Mounting / as read-write"
|
if grep -qs '/usrdata' /proc/mounts; then
|
||||||
mount -o remount,rw /
|
echo "/usrdata is mounted. Unmounting /etc again to access rootfs /etc..."
|
||||||
|
umount -lf /etc
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -2,46 +2,70 @@
|
|||||||
|
|
||||||
START=03
|
START=03
|
||||||
|
|
||||||
|
LOG_FILE="/tmp/mount-fix.log"
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
# Log to tmp
|
# Initialize log
|
||||||
rm /tmp/mount-fix.log >/dev/null 2>&1
|
rm -f "$LOG_FILE" >/dev/null 2>&1
|
||||||
/bin/touch /tmp/mount-fix.log
|
touch "$LOG_FILE"
|
||||||
/bin/echo "Begin mount fix process to make a usable userspace" >> /tmp/mount-fix.log
|
|
||||||
|
# Redirect all output (stdout and stderr) to the log file
|
||||||
|
exec >>"$LOG_FILE" 2>&1
|
||||||
|
|
||||||
|
echo "Begin mount fix process to make a usable userspace."
|
||||||
|
|
||||||
|
# Determine firmware scenario
|
||||||
|
if mount | grep -q "/usrdata"; then
|
||||||
|
echo "New firmware scenario detected (with /usrdata)."
|
||||||
|
handle_new_firmware
|
||||||
|
elif mount | grep -q "/overlay"; then
|
||||||
|
echo "Old firmware scenario detected (with /overlay)."
|
||||||
|
handle_old_firmware
|
||||||
|
else
|
||||||
|
echo "Error: Unable to detect firmware scenario. Neither /usrdata nor /overlay mounts found. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_old_firmware() {
|
||||||
|
# Redirect all output (stdout and stderr) to the log file
|
||||||
|
exec >>"$LOG_FILE" 2>&1
|
||||||
|
/bin/echo "Begin mount fix process to make a usable userspace"
|
||||||
|
|
||||||
# Forcefully unmount /etc
|
# Forcefully unmount /etc
|
||||||
/bin/echo "Unmounting the tiny overlay at /etc" >> /tmp/mount-fix.log
|
/bin/echo "Unmounting the tiny overlay at /etc"
|
||||||
/bin/umount -lf /etc >/dev/null 2>&1
|
/bin/umount -lf /etc >/dev/null 2>&1
|
||||||
|
|
||||||
# Remount root filesystem as read-write
|
# Remount root filesystem as read-write
|
||||||
/bin/echo "Remounting / as read-write" >> /tmp/mount-fix.log
|
/bin/echo "Remounting / as read-write"
|
||||||
/bin/mount -o remount,rw / >> /tmp/mount-fix.log
|
/bin/mount -o remount,rw /
|
||||||
|
|
||||||
# Check if /overlay/etc-upper/merged.done exists
|
# Check if /overlay/etc-upper/merged.done exists
|
||||||
/bin/echo "First time this is ran the stuff you have been putting in the old overlay needs merged." >> /tmp/mount-fix.log
|
/bin/echo "First time this is ran the stuff you have been putting in the old overlay needs merged."
|
||||||
/bin/echo "Looking for evidence that this has already happened..." >> /tmp/mount-fix.log
|
/bin/echo "Looking for evidence that this has already happened..."
|
||||||
if [ ! -f /overlay/etc-upper/merged.done ]; then
|
if [ ! -f /overlay/etc-upper/merged.done ]; then
|
||||||
/bin/echo "/overlay/etc-upper/merged.done not found, merging /overlay/etc-upper/* to /etc/" >> /tmp/mount-fix.log
|
/bin/echo "/overlay/etc-upper/merged.done not found, merging /overlay/etc-upper/* to /etc/"
|
||||||
cp -rf /overlay/etc-upper/* /etc/ >> /tmp/mount-fix.log
|
cp -rf /overlay/etc-upper/* /etc/
|
||||||
/bin/touch /overlay/etc-upper/merged.done >> /tmp/mount-fix.log
|
/bin/touch /overlay/etc-upper/merged.done
|
||||||
else
|
else
|
||||||
/bin/echo "/overlay/etc-upper/merged.done found, skipping merge" >> /tmp/mount-fix.log
|
/bin/echo "/overlay/etc-upper/merged.done found, skipping merge"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Unmount /overlay
|
# Unmount /overlay
|
||||||
/bin/echo "Unmounting the no longer needed /overlay" >> /tmp/mount-fix.log
|
/bin/echo "Unmounting the no longer needed /overlay"
|
||||||
/bin/umount /overlay >> /tmp/mount-fix.log
|
/bin/umount /overlay
|
||||||
|
|
||||||
# Check if /etc/opkg.conf has a line containing "option overlay_root /overlay" and remove it if it exists
|
# Check if /etc/opkg.conf has a line containing "option overlay_root /overlay" and remove it if it exists
|
||||||
/bin/echo "Lets be sure your opkg config isn't using the old overlay" >> /tmp/mount-fix.log
|
/bin/echo "Lets be sure your opkg config isn't using the old overlay"
|
||||||
if grep -q "option overlay_root /overlay" /etc/opkg.conf; then
|
if grep -q "option overlay_root /overlay" /etc/opkg.conf; then
|
||||||
/bin/echo "Removing 'option overlay_root /overlay' from /etc/opkg.conf" >> /tmp/mount-fix.log
|
/bin/echo "Removing 'option overlay_root /overlay' from /etc/opkg.conf"
|
||||||
sed -i '/option overlay_root \/overlay/d' /etc/opkg.conf >> /tmp/mount-fix.log
|
sed -i '/option overlay_root \/overlay/d' /etc/opkg.conf
|
||||||
else
|
else
|
||||||
/bin/echo "'option overlay_root /overlay' not found in /etc/opkg.conf, no changes made" >> /tmp/mount-fix.log
|
/bin/echo "'option overlay_root /overlay' not found in /etc/opkg.conf, no changes made"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure necessary directories exist for overlay and pivot_root
|
# Ensure necessary directories exist for overlay and pivot_root
|
||||||
/bin/echo "Creating new overlay system" >> /tmp/mount-fix.log
|
/bin/echo "Creating new overlay system"
|
||||||
if [ ! -d /data/rootfs ]; then
|
if [ ! -d /data/rootfs ]; then
|
||||||
mkdir -p /data/rootfs
|
mkdir -p /data/rootfs
|
||||||
fi
|
fi
|
||||||
@@ -53,7 +77,7 @@ start() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Mount the new overlay filesystem
|
# Mount the new overlay filesystem
|
||||||
/bin/mount -t overlay overlay -o lowerdir=/,upperdir=/data/rootfs,workdir=/data/rootfs-workdir /rootfs >> /tmp/mount-fix.log
|
/bin/mount -t overlay overlay -o lowerdir=/,upperdir=/data/rootfs,workdir=/data/rootfs-workdir /rootfs
|
||||||
|
|
||||||
# Create the real_rootfs directory in the new root
|
# Create the real_rootfs directory in the new root
|
||||||
if [ ! -d /rootfs/real_rootfs ]; then
|
if [ ! -d /rootfs/real_rootfs ]; then
|
||||||
@@ -61,27 +85,27 @@ start() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Pivot root to the new root
|
# Pivot root to the new root
|
||||||
/bin/echo "Pivoting Root / to /rootfs; Be back soon!!" >> /tmp/mount-fix.log
|
/bin/echo "Pivoting Root / to /rootfs; Be back soon!!"
|
||||||
/sbin/pivot_root /rootfs /rootfs/real_rootfs >/dev/null 2>&1
|
/sbin/pivot_root /rootfs /rootfs/real_rootfs >/dev/null 2>&1
|
||||||
|
|
||||||
# Move the mounted filesystems to the new locations
|
# Move the mounted filesystems to the new locations
|
||||||
/bin/mount --move /real_rootfs/sys /sys >> /tmp/mount-fix.log
|
/bin/mount --move /real_rootfs/sys /sys
|
||||||
/bin/mount --move /real_rootfs/proc /proc >> /tmp/mount-fix.log
|
/bin/mount --move /real_rootfs/proc /proc
|
||||||
/bin/mount --move /real_rootfs/tmp /tmp >> /tmp/mount-fix.log
|
/bin/mount --move /real_rootfs/tmp /tmp
|
||||||
/bin/mount --move /real_rootfs/dev /dev >> /tmp/mount-fix.log
|
/bin/mount --move /real_rootfs/dev /dev
|
||||||
/bin/mount --move /real_rootfs/firmware /firmware >> /tmp/mount-fix.log
|
/bin/mount --move /real_rootfs/firmware /firmware
|
||||||
/bin/mount --move /real_rootfs/persist /persist >> /tmp/mount-fix.log
|
/bin/mount --move /real_rootfs/persist /persist
|
||||||
/bin/mount --move /real_rootfs/cache /cache >> /tmp/mount-fix.log
|
/bin/mount --move /real_rootfs/cache /cache
|
||||||
/bin/mount --move /real_rootfs/data /data >> /tmp/mount-fix.log
|
/bin/mount --move /real_rootfs/data /data
|
||||||
|
|
||||||
# Synchronize /etc/rc.d/ and /real_rootfs/etc/rc.d/
|
# Synchronize /etc/rc.d/ and /real_rootfs/etc/rc.d/
|
||||||
/bin/echo "Synchronizing /etc/rc.d/ and /real_rootfs/etc/rc.d/" >> /tmp/mount-fix.log
|
/bin/echo "Synchronizing /etc/rc.d/ and /real_rootfs/etc/rc.d/"
|
||||||
for link in /etc/rc.d/*; do
|
for link in /etc/rc.d/*; do
|
||||||
if [ -L "$link" ]; then
|
if [ -L "$link" ]; then
|
||||||
link_name=$(basename "$link")
|
link_name=$(basename "$link")
|
||||||
if [ ! -e "/real_rootfs/etc/rc.d/$link_name" ]; then
|
if [ ! -e "/real_rootfs/etc/rc.d/$link_name" ]; then
|
||||||
/bin/echo "Copying $link_name to /real_rootfs/etc/rc.d/" >> /tmp/mount-fix.log
|
/bin/echo "Copying $link_name to /real_rootfs/etc/rc.d/"
|
||||||
cp -a "$link" "/real_rootfs/etc/rc.d/$link_name" >> /tmp/mount-fix.log
|
cp -a "$link" "/real_rootfs/etc/rc.d/$link_name"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -90,40 +114,166 @@ start() {
|
|||||||
if [ -L "$link" ]; then
|
if [ -L "$link" ]; then
|
||||||
link_name=$(basename "$link")
|
link_name=$(basename "$link")
|
||||||
if [ ! -e "/etc/rc.d/$link_name" ]; then
|
if [ ! -e "/etc/rc.d/$link_name" ]; then
|
||||||
/bin/echo "Removing $link_name from /real_rootfs/etc/rc.d/" >> /tmp/mount-fix.log
|
/bin/echo "Removing $link_name from /real_rootfs/etc/rc.d/"
|
||||||
rm "/real_rootfs/etc/rc.d/$link_name" >> /tmp/mount-fix.log
|
rm "/real_rootfs/etc/rc.d/$link_name"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Final logs and remount the original root as read-only
|
# Final logs and remount the original root as read-only
|
||||||
/bin/echo "...and we're back! The original root now lives at /real_rootfs" >> /tmp/mount-fix.log
|
/bin/echo "...and we're back! The original root now lives at /real_rootfs"
|
||||||
/bin/echo "Lets mount it as read-only for now, If you need it just remount it as read-write" >> /tmp/mount-fix.log
|
/bin/echo "Lets mount it as read-only for now, If you need it just remount it as read-write"
|
||||||
/bin/mount -o remount,ro /real_rootfs >/dev/null 2>&1
|
/bin/mount -o remount,ro /real_rootfs >/dev/null 2>&1
|
||||||
/bin/echo "Overlay and pivot_root setup completed" >> /tmp/mount-fix.log
|
/bin/echo "Overlay and pivot_root setup completed"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_new_firmware() {
|
||||||
|
# Redirect all output (stdout and stderr) to the log file
|
||||||
|
exec >>"$LOG_FILE" 2>&1
|
||||||
|
/bin/echo "Begin mount fix process to make a usable userspace"
|
||||||
|
|
||||||
|
# Forcefully unmount /etc
|
||||||
|
/bin/echo "Unmounting the 2 mounts over /etc"
|
||||||
|
/bin/umount -lf /etc >/dev/null 2>&1
|
||||||
|
/bin/umount -lf /etc >/dev/null 2>&1
|
||||||
|
|
||||||
|
# Remount root filesystem as read-write
|
||||||
|
/bin/echo "Remounting / as read-write"
|
||||||
|
/bin/mount -o remount,rw /
|
||||||
|
|
||||||
|
# Begin layer merge checks
|
||||||
|
# Layer 1
|
||||||
|
# Check if /overlay/etc-upper/merged.done exists
|
||||||
|
/bin/echo "First time this is ran the stuff you have been putting in the old overlay and /usrdata/etc needs merged."
|
||||||
|
/bin/echo "Looking for evidence that this has already happened..."
|
||||||
|
if [ ! -f /usrdata/overlay-work/etc-upper/merged.done ]; then
|
||||||
|
/bin/echo "/usrdata/overlay-work/etc-upper/merged.done not found, merging /usrdata/overlay-work/etc-upper/* to /usrdata/etc/"
|
||||||
|
cp -rf /usrdata/overlay-work/etc-upper/* /usrdata/etc/
|
||||||
|
/bin/touch /usrdata/overlay-work/etc-upper/merged.done
|
||||||
|
else
|
||||||
|
/bin/echo "/usrdata/overlay-work/etc-upper/merged.done found, skipping merge"
|
||||||
|
fi
|
||||||
|
# Layer 2
|
||||||
|
# Check if /usrdata/etc/merged.done exists
|
||||||
|
/bin/echo "First time this is ran the stuff you have been putting in /usrdata/etc and /etc needs merged."
|
||||||
|
/bin/echo "Looking for evidence that this has already happened..."
|
||||||
|
if [ ! -f /usrdata/etc/merged.done ]; then
|
||||||
|
/bin/echo "/usrdata/etc/merged.done not found, merging /usrdata/etc/* to /etc/"
|
||||||
|
cp -rf /usrdata/etc/* /etc/
|
||||||
|
/bin/touch /usrdata/etc/merged.done
|
||||||
|
else
|
||||||
|
/bin/echo "/usrdata/etc/merged.done found, skipping merge"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Check if /etc/opkg.conf has a line containing "option overlay_root /overlay" and remove it if it exists
|
||||||
|
/bin/echo "Lets be sure your opkg config isn't using the old overlay"
|
||||||
|
if grep -q "option overlay_root /overlay" /etc/opkg.conf; then
|
||||||
|
/bin/echo "Removing 'option overlay_root /overlay' from /etc/opkg.conf"
|
||||||
|
sed -i '/option overlay_root \/overlay/d' /etc/opkg.conf
|
||||||
|
else
|
||||||
|
/bin/echo "'option overlay_root /overlay' not found in /etc/opkg.conf, no changes made"
|
||||||
|
fi
|
||||||
|
# #
|
||||||
|
# #
|
||||||
|
# Continue Working from here.... #
|
||||||
|
# #
|
||||||
|
# #
|
||||||
|
# #
|
||||||
|
#
|
||||||
|
# Ensure necessary directories exist for overlay and pivot_root
|
||||||
|
/bin/echo "Creating new overlay system"
|
||||||
|
if [ ! -d /data/rootfs ]; then
|
||||||
|
mkdir -p /data/rootfs
|
||||||
|
fi
|
||||||
|
if [ ! -d /data/rootfs-workdir ]; then
|
||||||
|
mkdir -p /data/rootfs-workdir
|
||||||
|
fi
|
||||||
|
if [ ! -d /rootfs ]; then
|
||||||
|
mkdir -p /rootfs
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Mount the new overlay filesystem
|
||||||
|
/bin/mount -t overlay overlay -o lowerdir=/,upperdir=/data/rootfs,workdir=/data/rootfs-workdir /rootfs
|
||||||
|
|
||||||
|
# Create the real_rootfs directory in the new root
|
||||||
|
if [ ! -d /rootfs/real_rootfs ]; then
|
||||||
|
mkdir -p /rootfs/real_rootfs
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Pivot root to the new root
|
||||||
|
/bin/echo "Pivoting Root / to /rootfs; Be back soon!!"
|
||||||
|
/sbin/pivot_root /rootfs /rootfs/real_rootfs >/dev/null 2>&1
|
||||||
|
|
||||||
|
# Move the mounted filesystems to the new locations
|
||||||
|
/bin/mount --move /real_rootfs/sys /sys
|
||||||
|
/bin/mount --move /real_rootfs/proc /proc
|
||||||
|
/bin/mount --move /real_rootfs/tmp /tmp
|
||||||
|
/bin/mount --move /real_rootfs/dev /dev
|
||||||
|
/bin/mount --move /real_rootfs/firmware /firmware
|
||||||
|
/bin/mount --move /real_rootfs/persist /persist
|
||||||
|
/bin/mount --move /real_rootfs/cache /cache
|
||||||
|
/bin/mount --move /real_rootfs/data /data
|
||||||
|
|
||||||
|
# Synchronize /etc/rc.d/ and /real_rootfs/etc/rc.d/
|
||||||
|
/bin/echo "Synchronizing /etc/rc.d/ and /real_rootfs/etc/rc.d/"
|
||||||
|
for link in /etc/rc.d/*; do
|
||||||
|
if [ -L "$link" ]; then
|
||||||
|
link_name=$(basename "$link")
|
||||||
|
if [ ! -e "/real_rootfs/etc/rc.d/$link_name" ]; then
|
||||||
|
/bin/echo "Copying $link_name to /real_rootfs/etc/rc.d/"
|
||||||
|
cp -a "$link" "/real_rootfs/etc/rc.d/$link_name"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for link in /real_rootfs/etc/rc.d/*; do
|
||||||
|
if [ -L "$link" ]; then
|
||||||
|
link_name=$(basename "$link")
|
||||||
|
if [ ! -e "/etc/rc.d/$link_name" ]; then
|
||||||
|
/bin/echo "Removing $link_name from /real_rootfs/etc/rc.d/"
|
||||||
|
rm "/real_rootfs/etc/rc.d/$link_name"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Final logs and remount the original root as read-only
|
||||||
|
/bin/echo "...and we're back! The original root now lives at /real_rootfs"
|
||||||
|
/bin/echo "Lets mount it as read-only for now, If you need it just remount it as read-write"
|
||||||
|
/bin/mount -o remount,ro /real_rootfs >/dev/null 2>&1
|
||||||
|
/bin/echo "Overlay and pivot_root setup completed"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
/bin/echo "Stopping and reverting overlay and pivot_root" >> /tmp/mount-fix.log
|
# Redirect all output (stdout and stderr) to the log file
|
||||||
|
exec >>"$LOG_FILE" 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
stop_handle_old_firmware() {
|
||||||
|
# Redirect all output (stdout and stderr) to the log file
|
||||||
|
exec >>"$LOG_FILE" 2>&1
|
||||||
|
/bin/echo "Stopping and reverting overlay and pivot_root"
|
||||||
|
|
||||||
# Remount the original root filesystem as read-write
|
# Remount the original root filesystem as read-write
|
||||||
/bin/mount -o remount,rw /real_rootfs >> /tmp/mount-fix.log
|
/bin/mount -o remount,rw /real_rootfs
|
||||||
|
|
||||||
# Move the mounted filesystems back to the original locations
|
# Move the mounted filesystems back to the original locations
|
||||||
/bin/mount --move /sys /real_rootfs/sys >> /tmp/mount-fix.log
|
/bin/mount --move /sys /real_rootfs/sys
|
||||||
/bin/mount --move /proc /real_rootfs/proc >> /tmp/mount-fix.log
|
/bin/mount --move /proc /real_rootfs/proc
|
||||||
/bin/mount --move /tmp /real_rootfs/tmp >> /tmp/mount-fix.log
|
/bin/mount --move /tmp /real_rootfs/tmp
|
||||||
/bin/mount --move /dev /real_rootfs/dev >> /tmp/mount-fix.log
|
/bin/mount --move /dev /real_rootfs/dev
|
||||||
/bin/mount --move /firmware /real_rootfs/firmware >> /tmp/mount-fix.log
|
/bin/mount --move /firmware /real_rootfs/firmware
|
||||||
/bin/mount --move /persist /real_rootfs/persist >> /tmp/mount-fix.log
|
/bin/mount --move /persist /real_rootfs/persist
|
||||||
/bin/mount --move /cache /real_rootfs/cache >> /tmp/mount-fix.log
|
/bin/mount --move /cache /real_rootfs/cache
|
||||||
/bin/mount --move /data /real_rootfs/data >> /tmp/mount-fix.log
|
/bin/mount --move /data /real_rootfs/data
|
||||||
|
|
||||||
# Pivot root back to the original root
|
# Pivot root back to the original root
|
||||||
/sbin/pivot_root /real_rootfs /real_rootfs/rootfs >> /tmp/mount-fix.log
|
/sbin/pivot_root /real_rootfs /real_rootfs/rootfs
|
||||||
|
|
||||||
/bin/echo "Reverted pivot_root" >> /tmp/mount-fix.log
|
/bin/echo "Reverted pivot_root"
|
||||||
/bin/echo "Previous root overlay available at /rootfs" >> /tmp/mount-fix.log
|
/bin/echo "Previous root overlay available at /rootfs"
|
||||||
|
|
||||||
# Unmount /rootfs overlay
|
# Unmount /rootfs overlay
|
||||||
/bin/umount -lf /rootfs >/dev/null 2>&1
|
/bin/umount -lf /rootfs >/dev/null 2>&1
|
||||||
@@ -132,12 +282,17 @@ stop() {
|
|||||||
mount -t ubifs /dev/ubi0_3 /overlay
|
mount -t ubifs /dev/ubi0_3 /overlay
|
||||||
|
|
||||||
# Mount the old overlay filesystem back for etc
|
# Mount the old overlay filesystem back for etc
|
||||||
/bin/mount -t overlay overlay -o lowerdir=/etc,upperdir=/overlay/etc-upper,workdir=/overlay/.etc-work /etc >> /tmp/mount-fix.log
|
/bin/mount -t overlay overlay -o lowerdir=/etc,upperdir=/overlay/etc-upper,workdir=/overlay/.etc-work /etc
|
||||||
|
|
||||||
echo -e "\e[31m / is read-write right now. Be careful\e[0m"
|
echo -e "\e[31m / is read-write right now. Be careful\e[0m"
|
||||||
echo -e "\e[31m Reboot or run mount -o remount,ro / \e[0m"
|
echo -e "\e[31m Reboot or run mount -o remount,ro / \e[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stop_handle_new_firmware() {
|
||||||
|
# Redirect all output (stdout and stderr) to the log file
|
||||||
|
exec >>"$LOG_FILE" 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
restart() {
|
restart() {
|
||||||
/bin/echo "This script should only be executed once at boot"
|
/bin/echo "This script should only be executed once at boot"
|
||||||
/bin/echo "Use Stop to undo the pivot"
|
/bin/echo "Use Stop to undo the pivot"
|
||||||
|
|||||||
Reference in New Issue
Block a user