mount-fix Test

First test with new firmware with updated mount-fix package
This commit is contained in:
Cameron Thompson
2025-01-10 00:29:13 -05:00
parent 47c1ea44ad
commit 0c6194e00c
16 changed files with 144 additions and 77 deletions

0
ipk-source/sdxpinn-mount-fix/root/usr/bin/inotifywait Normal file → Executable file
View File

View File

View File

@@ -2,30 +2,57 @@
# Paths to monitor and synchronize
WATCH_DIR="/etc/rc.d"
TARGET_DIR="/real_rootfs/etc/rc.d"
TARGET_DIR1="/real_rootfs/etc/rc.d"
TARGET_DIR2="/usrdata/etc/rc.d"
# Function to synchronize init scripts
synchronize_init_scripts() {
# Ensure /real_rootfs is writable for updates
mount -o remount,rw /real_rootfs
# Copy new or updated symlinks from WATCH_DIR to TARGET_DIR
# Synchronize with TARGET_DIR1
echo "Synchronizing $WATCH_DIR with $TARGET_DIR1..."
for link in "$WATCH_DIR"/*; do
if [ -L "$link" ]; then
link_name=$(basename "$link")
if [ ! -e "$TARGET_DIR/$link_name" ] || [ "$link" -nt "$TARGET_DIR/$link_name" ]; then
cp -af "$link" "$TARGET_DIR/$link_name"
if [ ! -e "$TARGET_DIR1/$link_name" ] || [ "$link" -nt "$TARGET_DIR1/$link_name" ]; then
cp -af "$link" "$TARGET_DIR1/$link_name"
fi
fi
done
# Remove symlinks in TARGET_DIR that no longer exist in WATCH_DIR
for link in "$TARGET_DIR"/*; do
for link in "$TARGET_DIR1"/*; do
if [ -L "$link" ]; then
link_name=$(basename "$link")
if [ ! -e "$WATCH_DIR/$link_name" ]; then
rm -f "$TARGET_DIR/$link_name"
rm -f "$TARGET_DIR1/$link_name"
fi
fi
done
# Synchronize with TARGET_DIR2 if /usrdata exists
if [ -d "/usrdata" ]; then
echo "Synchronizing $WATCH_DIR with $TARGET_DIR2..."
for link in "$WATCH_DIR"/*; do
if [ -L "$link" ]; then
link_name=$(basename "$link")
if [ ! -e "$TARGET_DIR2/$link_name" ] || [ "$link" -nt "$TARGET_DIR2/$link_name" ]; then
cp -af "$link" "$TARGET_DIR2/$link_name"
fi
fi
done
for link in "$TARGET_DIR2"/*; do
if [ -L "$link" ]; then
link_name=$(basename "$link")
if [ ! -e "$WATCH_DIR/$link_name" ]; then
rm -f "$TARGET_DIR2/$link_name"
fi
fi
done
fi
# Restore /real_rootfs to read-only
mount -o remount,ro /real_rootfs
}
@@ -37,3 +64,4 @@ while true; do
inotifywait -e create,delete,modify,move "$WATCH_DIR"
synchronize_init_scripts
done