Update rc_sync
This commit is contained in:
@@ -1,15 +1,20 @@
|
|||||||
#!/bin/ash
|
#!/bin/ash
|
||||||
|
|
||||||
# Paths to monitor and synchronize
|
# Paths to monitor and synchronize
|
||||||
WATCH_DIR="/etc/rc.d"
|
WATCH_DIR="/etc/rc.d"
|
||||||
TARGET_DIR1="/real_rootfs/etc/rc.d"
|
TARGET_DIR1="/real_rootfs/etc/rc.d"
|
||||||
TARGET_DIR2="/usrdata/etc/rc.d"
|
TARGET_DIR2="/usrdata/etc/rc.d"
|
||||||
|
|
||||||
|
# Function to check if a path is a mountpoint
|
||||||
|
is_mountpoint() {
|
||||||
|
grep -q " $1 " /proc/mounts
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
# Function to synchronize init scripts
|
# Function to synchronize init scripts
|
||||||
synchronize_init_scripts() {
|
synchronize_init_scripts() {
|
||||||
# Ensure /real_rootfs is writable for updates
|
# Ensure /real_rootfs is writable for updates
|
||||||
mount -o remount,rw /real_rootfs
|
mount -o remount,rw /real_rootfs
|
||||||
|
|
||||||
# Synchronize with TARGET_DIR1
|
# Synchronize with TARGET_DIR1
|
||||||
echo "Synchronizing $WATCH_DIR with $TARGET_DIR1..."
|
echo "Synchronizing $WATCH_DIR with $TARGET_DIR1..."
|
||||||
for link in "$WATCH_DIR"/*; do
|
for link in "$WATCH_DIR"/*; do
|
||||||
@@ -20,7 +25,7 @@ synchronize_init_scripts() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for link in "$TARGET_DIR1"/*; do
|
for link in "$TARGET_DIR1"/*; do
|
||||||
if [ -L "$link" ]; then
|
if [ -L "$link" ]; then
|
||||||
link_name=$(basename "$link")
|
link_name=$(basename "$link")
|
||||||
@@ -30,8 +35,8 @@ synchronize_init_scripts() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Synchronize with TARGET_DIR2 if /usrdata exists
|
# Synchronize with TARGET_DIR2 only if /usrdata is a mountpoint
|
||||||
if [ -d "/usrdata" ]; then
|
if is_mountpoint "/usrdata"; then
|
||||||
echo "Synchronizing $WATCH_DIR with $TARGET_DIR2..."
|
echo "Synchronizing $WATCH_DIR with $TARGET_DIR2..."
|
||||||
for link in "$WATCH_DIR"/*; do
|
for link in "$WATCH_DIR"/*; do
|
||||||
if [ -L "$link" ]; then
|
if [ -L "$link" ]; then
|
||||||
@@ -41,7 +46,7 @@ synchronize_init_scripts() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
for link in "$TARGET_DIR2"/*; do
|
for link in "$TARGET_DIR2"/*; do
|
||||||
if [ -L "$link" ]; then
|
if [ -L "$link" ]; then
|
||||||
link_name=$(basename "$link")
|
link_name=$(basename "$link")
|
||||||
@@ -56,7 +61,6 @@ synchronize_init_scripts() {
|
|||||||
mount -o remount,ro /real_rootfs
|
mount -o remount,ro /real_rootfs
|
||||||
}
|
}
|
||||||
|
|
||||||
# Synchronization
|
# Run synchronization
|
||||||
synchronize_init_scripts
|
synchronize_init_scripts
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user