mount-fix simplification

- No more inotifywait or overlay-init-watchdog

- Instead, real_rootfs rc.d is mounted back on top of the overlay to allow read/write to it. The bootup rc.d and resulting location rc.d become the same and as a result allowing init to behave naturally without extra help.

- Must be on the latest sdxpinn-patch version in order to upgrade this package. The old prerm scripts need removed before upgrading.
This commit is contained in:
Cameron Thompson
2025-01-25 22:33:05 -05:00
parent cd60b7b6db
commit dc16a3c9fe
23 changed files with 472 additions and 508 deletions

View File

@@ -1,60 +0,0 @@
#!/bin/ash /etc/rc.common
USE_PROCD=1
START=99
STOP=15
# Define variables for bundled packages and status file
STATUS_FILE="/usr/lib/opkg/status"
# Bundled package information to be added
BUNDLED_PACKAGES_INFO="
Package: libinotifytools
Version: 3.20.11.0-1
Depends: libc
Status: install user installed
Architecture: aarch64_cortex-a53
Installed-Time: $(date +%s)
Package: inotifywait
Version: 3.20.11.0-1
Depends: libc, libinotifytools
Status: install user installed
Architecture: aarch64_cortex-a53
Installed-Time: $(date +%s)
"
start_service() {
echo "Starting add_opkg_status_bundled service in the background..."
# Run the service in the background using procd
procd_open_instance
procd_set_param command /bin/sh -c "(
echo 'Waiting for 4 seconds...'
sleep 4
# Append the package information to the status file
echo 'Adding bundled package entries to $STATUS_FILE...'
echo \"$BUNDLED_PACKAGES_INFO\" >> \"$STATUS_FILE\"
# Sync filesystem to ensure changes are saved
sync
# Verify if the entries were added correctly
if grep -q 'Package: libinotifytools' \"$STATUS_FILE\" && grep -q 'Package: inotifywait' \"$STATUS_FILE\"; then
echo 'Successfully added bundled package entries to $STATUS_FILE'
else
echo 'Error: Failed to add bundled package entries to $STATUS_FILE'
fi
# Self-remove the init script after execution
echo 'Cleaning up: Removing /etc/init.d/add_opkg_status_bundled'
rm -f /etc/init.d/add_opkg_status_bundled
echo 'add_opkg_status_bundled service completed and removed.'
) &"
procd_close_instance
}
stop_service() {
echo "Stopping add_opkg_status_bundled service (if running)..."
}

View File

@@ -1,20 +0,0 @@
#!/bin/ash /etc/rc.common
START=04
USE_PROCD=1
start_service() {
procd_open_instance
procd_set_param command /usr/sbin/init-overlay-watchdog.sh
procd_set_param respawn 3600 5 5
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param pidfile /var/run/init-overlay-watchdog.pid
procd_set_param tracking
procd_close_instance
}
stop_service() {
echo "Stopping init-overlay-watchdog service"
# `procd` will handle stopping the service and its processes
}

View File

@@ -98,8 +98,12 @@ handle_old_firmware() {
/bin/mount --move /real_rootfs/cache /cache
/bin/mount --move /real_rootfs/data /data
# Synchronize between /etc/rc.d and /real_rootfs/etc/rc.d
synchronize_rc_d "/etc/rc.d" "/real_rootfs/etc/rc.d"
# Synchronize rc.d
synchronize_rc_d "/real_rootfs/etc/rc.d" "/etc/rc.d"
# Bind the orignal rc.d back and make writable
/bin/mount -o bind,rw /real_rootfs/etc/rc.d /etc/rc.d
/bin/mount -o remount,rw /etc/rc.d
# Final logs and remount the original root as read-only
/bin/echo "...and we're back! The original root now lives at /real_rootfs"
@@ -192,12 +196,15 @@ handle_new_firmware() {
/bin/mount --move /real_rootfs/systemrw /systemrw
/bin/mount --move /real_rootfs/persist /persist
# Synchronize between rc.d layer 1 to Final
synchronize_rc_d "/real_rootfs/etc/rc.d" "/etc/rc.d"
# Synchronize between /etc/rc.d and /real_rootfs/etc/rc.d
synchronize_rc_d "/etc/rc.d" "/real_rootfs/etc/rc.d"
# Synchronize between /etc/rc.d and /usrdata/etc/rc.d
synchronize_rc_d "/etc/rc.d" "/usrdata/etc/rc.d"
# Synchronize between rc.d layer 2 to Final
synchronize_rc_d "/usrdata/etc/rc.d" "/etc/rc.d"
# Bind the orignal rc.d back and make writable
/bin/mount -o bind,rw /real_rootfs/etc/rc.d /etc/rc.d
/bin/mount -o remount,rw /etc/rc.d
# Final logs and remount the original root as read-only
/bin/echo "...and we're back! The original root now lives at /real_rootfs"
@@ -211,7 +218,6 @@ handle_new_firmware() {
synchronize_rc_d() {
local source_dir="$1"
local target_dir="$2"
/bin/echo "Synchronizing $source_dir with $target_dir"
for link in "$source_dir"/*; do
if [ -L "$link" ]; then
@@ -222,13 +228,12 @@ synchronize_rc_d() {
fi
fi
done
for link in "$target_dir"/*; do
if [ -L "$link" ]; then
link_name=$(basename "$link")
if [ ! -e "$source_dir/$link_name" ]; then
/bin/echo "Removing $link_name from $target_dir"
rm "$target_dir/$link_name"
/bin/echo "Copying $link_name to $source_dir"
cp -a "$link" "$source_dir/$link_name"
fi
fi
done
@@ -286,7 +291,7 @@ stop_handle_new_firmware() {
/bin/umount -lf /rootfs >/dev/null 2>&1
# Mount layer 2 /etc back
/bin/mount -t ubifs -o rw,relatime,bulk_read,assert=read-only,ubi=2,vol=0 /dev/ubi2_0 /etc
/bin/mount --bind /usrdata/etc /etc
# Mount layer 3 /etc back
/bin/mount -t overlay overlay -o lowerdir=/etc,upperdir=/usrdata/overlay-work/etc-upper,workdir=/usrdata/overlay-work/.etc-work /etc